seboettg / citeproc-php

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

Punctuation with quotes #101

Open ctgraham opened 3 years ago

ctgraham commented 3 years ago

Please follow the general troubleshooting steps first:

Bug reports:

C.f. #50, but without the tag <style-options punctuation-in-quote="true"/>. Also tried adding the style-options to the CSL, but no change in output. Reproduced the unexpected behavior in citeproc-php 2.2.5, but not in Zotero's or ExLibris Primo's interpretation of the MLA stylesheet.

Expected:

“Colonizing Other Planets Is a Bad Idea.” <i>Futures</i>, vol. 110,

Actual:

“Colonizing Other Planets Is a Bad Idea”. <i>Futures</i>, vol. 110,

Used CSL stylesheet:

modern-language-association.csl 7140f39

Used CSL metadata

[
    {
        "DOI": "10.1016/j.futures.2019.02.020",
        "URL": "https://linkinghub.elsevier.com/retrieve/pii/S0016328718303136",
        "accessed": {
            "date-parts": [
                [
                    2021,
                    5,
                    24
                ]
            ]
        },
        "author": [
            {
                "family": "Billings",
                "given": "Linda"
            }
        ],
        "container-title": "Futures",
        "id": "10653761/QB9CKGG4",
        "issued": {
            "date-parts": [
                [
                    "2019"
                ]
            ]
        },
        "journalAbbreviation": "Futures",
        "language": "en",
        "page": "44-46",
        "title": "Colonizing other planets is a bad idea",
        "type": "article-journal",
        "volume": "110"
    }
]
ctgraham commented 3 years ago

@seboettg , do you have any feedback on this?

ewhanson commented 2 years ago

I have also encountered the same issue. I was able to reproduce this with chicago-author-date.csl.

In the case @ctgraham describes, it looks like the . is added as a prefix to the journal title, e.g. . <i>Futures</I> so <style-options punctuation-in-quote="true"/> for the article title wouldn't capture it since . is a prefix to a separate Text node.

seboettg commented 2 years ago

Hi @ctgraham! Sorry for my late response. Unfortunately I have no good news regarding this issue. I have no idea how to solve this. The problem is the structure of the Stylesheet and the way how citeproc-php handles that. citeproc-php interprets a stylesheet as a tree and it travers through the branches and executes the "instructions" of the respective branch step by step.

In short, the structure of the stylesheet looks like this:

<style>
    <bibliography>
        <layout suffix=".">
            <group delimiter=". ">
                <text macro="author"/>
                <text macro="title"/>
                <text macro="container-title"/>
            </group>
        </layout>
    </bibliography>
    <macro name="title">
        <text variable="title" quotes="true" text-case="title"/>
    </macro>
    <macro name="author">
        <names variable="author">
            <name name-as-sort-order="first" and="text" delimiter-precedes-last="always" delimiter-precedes-et-al="always" initialize="false" initialize-with=". "/>
        </names>
    </macro>
    <macro name="container-title">
        <text variable="container-title" font-style="italic" text-case="title"/>
    </macro>
</style>

citeproc travers the style as follows: style > bibliography > group. Afterwards it renders each macro that is linked within this group (author, title, container-title) and remembers the results. Once citeproc is finished with each macro, it concatinates the results and separates them with the defined group delimiter ". " from <group delimiter=". ">. At this point citeproc has already finished the rendering of the title including quotes and other style defintions of the title and doesn't care about quotes and even doesn't know about quotes.

I've encountered similar problems over and over again reagrding the specification of CSL. Most problems I could solve by more or less hacky workaround approaches but in this special case I have no idea how to make a workaround.

You may change the stylesheet by removing delimiter=". " from group and add suffix=". " at text and name tags of the affected macros. I think this would solve your issue.