seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
75 stars 39 forks source link

“Homer, .”: name with family and and empty given #161

Open glorieux-f opened 1 year ago

glorieux-f commented 1 year ago

Please follow the general troubleshooting steps first:

Bug reports:

The default CSL export of Zotero desktop output an empty given ("given": "") when a name has no given.

citeproc-php display it with an empty string after a comma.

Zotero desktop export

Fix, find the right test where given should be not empty. Candidate Rendering/Name/Name.php#L187,

   if ($useInitials && isset($nameItem->given) && !empty($nameItem->given)) {…}

Used CSL stylesheet:

apa.csl

Used CSL metadata

Please replace these lines with your used metadata, for instance:

[
    {
        "id": "id03",
        "type": "book",
        "title": "Odyssey  (family, given='')",
        "author": [
            {
                "family": "Homer",
                "given": ""
            }
        ]
    },
    {
        "id": "id02",
        "type": "book",
        "title": "Odyssey (family)",
        "author": [
            {
                "family": "Homer"
            }
        ]
    }
]
rbran100 commented 1 year ago

@glorieux-f I can confirm that this fix works for me, it was the main issue I was having along with #169

Can I suggest an additional change, pass "$nameItem->given" through trim before passing it to initializeBySpaceOrHyphen, while it is not strictly cite-procs wheelhouse it prevents "First " from becoming "F. ."