seboettg / citeproc-php

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

Chicago CSL style throws a fatal error when ecountering "page" values it cannot understand #144

Open xopoc14 opened 1 year ago

xopoc14 commented 1 year ago

Bug reports:

A publication with "E4687-96" pages causes a fatal error when it is rendered:

The website encountered an unexpected error. Please try again later. TypeError: Unsupported operand types: string % int in Seboettg\CiteProc\Util\PageHelper::renderChicago() (line 80 of .../vendor/seboettg/citeproc-php/src/Util/PageHelper.php). Seboettg\CiteProc\Util\PageHelper::renderChicago('E4687', '96') (Line: 43) Seboettg\CiteProc\Util\PageHelper::processPageRangeFormats(Array, Object) (Line: 162) Seboettg\CiteProc\Rendering\Text->renderPage('E4687-96') (Line: 108) Seboettg\CiteProc\Rendering\Text->render(Object, NULL) (Line: 79) Seboettg\CiteProc\Rendering\Choose\ChooseIf->render(Object) (Line: 105) Seboettg\CiteProc\Rendering\Choose\Choose->render(Object, NULL) (Line: 79) Seboettg\CiteProc\Rendering\Choose\ChooseIf->render(Object) (Line: 98) Seboettg\CiteProc\Rendering\Choose\Choose->render(Object, NULL) (Line: 86) Seboettg\CiteProc\Style\Macro->render(Object) (Line: 290) Seboettg\CiteProc\Rendering\Text->renderMacro(Object) (Line: 120) Seboettg\CiteProc\Rendering\Text->render(Object, 0) (Line: 130) Seboettg\CiteProc\Rendering\Layout->renderSingle(Object, 0) (Line: 97) Seboettg\CiteProc\Rendering\Layout->render(Object, NULL) (Line: 76) Seboettg\CiteProc\Style\Bibliography->render(Object) (Line: 137) Seboettg\CiteProc\CiteProc->bibliography(Object) (Line: 183) Seboettg\CiteProc\CiteProc->render(Object) (Line: 64)

Used CSL stylesheet:

chicago-author-date-16th-edition.csl

Used CSL metadata

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

[
    {
        "author": [
            {
                "family": "Doe", 
                "given": "James"
            }
        ], 
        "id": "ITEM-1", 
        "type": "article-journal",
        "title": "Test",
        "page": "E4687-96"
    }
]

The value of pages is totally valid. It is imported from PubMed library. The original article is https://pubmed.ncbi.nlm.nih.gov/25267658/

glorieux-f commented 1 year ago

Same as #159

rbran100 commented 6 months ago

Fix for this is in the PR linked above.