seboettg / citeproc-php

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

Labels are not respecting their position before or after cs:name (if form is 'verb' or 'verb-short') #115

Closed urshofer closed 2 years ago

urshofer commented 2 years ago

Please follow the general troubleshooting steps first:

Bug reports:

This is the macro "translator" of the official chicago-fullnote stylesheet:

  <macro name="translator">
    <names variable="translator">
      <name name-as-sort-order="first" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
      <label form="verb-short" prefix=", "/>
    </names>
  </macro>

The label should be printed after the name, not before. According to the specs:

The position of cs:label relative to cs:name determines the order of the name and label in the rendered text.

In most cases, this bug is not visible, but if there's no author, the order of the label is important.

Used CSL stylesheet:

chicago-fullnote-bibliography-16th-edition.csl

Used CSL metadata

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

[
  {
    "type": "book",
    "id": "martin_hypnerotomachie_1546",
    "citation-label": "martin_hypnerotomachie_1546",
    "issued": {
        "date-parts": [
            [
                1546
            ]
        ]
    },
    "publisher-place": "Paris",
    "publisher": "Jaques Kerver",
    "title": "Hypnerotomachie, ou, discours du songe de Poliphile: Deduisant comme amour le combat à l’occasion de Polia",
    "translator": [
        {
            "given": "Jean",
            "family": "Martin"
        }
    ]
  }
]
urshofer commented 2 years ago

A follow up:

The problem is the following appendLabel function:

    private function appendLabel($data, $var, $name)
    {
        $this->label->setVariable($var);
        if (in_array($this->label->getForm(), ["verb", "verb-short"])) {
            $name = $this->label->render($data).$name;
        } else {
            $name .= $this->label->render($data);
        }
        return $name;
    }

The above mentionend 'bug' is obviously a feature. 'verb' and 'verb-short' are always prefixed and therfore not respecting their position within the stylesheet. I'm not sure if this behaviour is following the specs, i doubt it.