seboettg / citeproc-php

Full-featured CSL 1.0.1 processor for PHP
MIT License
73 stars 38 forks source link

group/label, test chain seems confused on display or not display the <group> #158

Open glorieux-f opened 11 months ago

glorieux-f commented 11 months ago

Bug reports:

citeproc-php

zotero desktop client

Used CSL stylesheet:

apa.csl#L1077

    <else>
      <group>
        <label variable="number-of-volumes" form="short" text-case="capitalize-first" suffix=" "/>
        <text term="page-range-delimiter" prefix="1"/>
        <number variable="number-of-volumes" form="numeric"/>
      </group>
    </else>

Commenting <label variable="number-of-volumes" form="short" text-case="capitalize-first" suffix=" "/> is a quick-and-dirty fix, but there are other configurations of groups containing <label> in apa.csl.

A better fix seems around line Rendering/Group.php#L104, <label> is counted as a reason to display the group, only if a content is generated for the label (here, when number-of volumes is not empty).

        $text = $child->render($data, $citationNumber);
        // …
        if (($child instanceof Label) && !empty($text)) {
            ++$terms;
        }

Used CSL metadata

[
    {
        "id": "n1",
        "type": "book",
        "title": "Bug “1‑”",
        "author": [
            {
                "family": "Doe",
                "given": "John"
            }
        ]
    },
    {
        "id": "n2",
        "type": "book",
        "number-of-volumes": "3",
        "title": "Bug no number-of-volumes",
        "author": [
            {
                "family": "Doe",
                "given": "John"
            }
        ]
    },
{
    "id": "n3",
    "type": "book",
    "title": "Keep “trans.” label",
    "author": [
        {
            "family": "Doe",
            "given": "John"
        }
    ],
    "translator": [
        {
            "family": "Translator",
            "given": "Allan"
        }
    ]
}
]