Juris-M / citeproc-js

A JavaScript implementation of the Citation Style Language (CSL) https://citeproc-js.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

year-suffix-delimiter is not actually used

Circeus opened this issue · comments

I've been futzing around trying desperately to set a year-suffix-delimiter in my style in the online editor. I never managed to, but I figured out why: what actually seems to happen is that when a collapse= attribute it set, cite-group-delimiter is used instead of year-suffix-delimiter, which causes the default to be ", " (that of cite-group-delimiter) instead of the delimiter set in layout (which is the default for year-suffix-delimiter). More importantly, this default will override any explicit values given to year-suffix-delimiter,

You you give a specific example of items showing this problem, a minimal style with the faulty combination of options, the current output, and the expected output?

This is the reference set I've been using to test this:

[
	{
		"id": "http://zotero.org/users/10305383/items/5739YA6H",
		"type": "book",
		"event-place": "London",
		"number-of-pages": "v-xiv, 957",
		"publisher": "The Zoological Society",
		"publisher-place": "London",
		"title": "Nomenclator Zoologicus. A list of the names of genera and subgenera in zoology from the tenth edition of Linnaeus 1758 to the end of 1935.",
		"volume": "Vol. I. A–C.",
		"author": [
			{
				"family": "Neave",
				"given": "S.A."
			}
		],
		"issued": {
			"date-parts": [
				[
					"1939"
				]
			]
		}
	},
	{
		"id": "http://zotero.org/users/10305383/items/YZ7KLMAD",
		"type": "book",
		"event-place": "London",
		"number-of-pages": "1025",
		"publisher": "The Zoological Society",
		"publisher-place": "London",
		"title": "Nomenclator Zoologicus. A list of the names of genera and subgenera in zoology from the tenth edition of Linnaeus 1758 to the end of 1935.",
		"volume": "Vol. II. D–L.",
		"author": [
			{
				"family": "Neave",
				"given": "S.A."
			}
		],
		"issued": {
			"date-parts": [
				[
					"1939"
				]
			]
		}
	},
	{
		"id": "http://zotero.org/users/10305383/items/GLTR6E6I",
		"type": "book",
		"event-place": "London",
		"number-of-pages": "1065",
		"publisher": "The Zoological Society",
		"publisher-place": "London",
		"title": "Nomenclator Zoologicus. A list of the names of genera and subgenera in zoology from the tenth edition of Linnaeus 1758 to the end of 1935.",
		"volume": "Vol. III. M–P.",
		"author": [
			{
				"family": "Neave",
				"given": "S.A."
			}
		],
		"issued": {
			"date-parts": [
				[
					"1940"
				]
			]
		}
	},
	{
		"id": "http://zotero.org/users/10305383/items/8NAW7FT7",
		"type": "book",
		"event-place": "London",
		"number-of-pages": "758",
		"publisher": "The Zoological Society",
		"publisher-place": "London",
		"title": "Nomenclator Zoologicus. A list of the names of genera and subgenera in zoology from the tenth edition of Linnaeus 1758 to the end of 1935.",
		"volume": "Vol. IV. Q–Z",
		"author": [
			{
				"family": "Neave",
				"given": "S.A."
			}
		],
		"issued": {
			"date-parts": [
				[
					"1940"
				]
			]
		}
	}
]

A CSL code is [dashes for exmphasis]

<citation disambiguate-add-year-suffix="true" collapse="year-suffix" year-suffix-delimiter="--">
    <sort>
      <key variable="author"/>
      <key variable="issued"/>
    </sort>
    <layout delimiter="; " prefix="(" suffix=")">
      <group delimiter=":">
        <group delimiter=" ">
          <text macro="author-short" suffix=","/>
          <text macro="issued-year"/>
        </group>
        <text variable="locator"/>
      </group>
    </layout>
  </citation>

With this code, I'd expect (Neave, 1939a--b--1940a--b). What I actually get is (Neave, 1939a, b, 1940a, b).

With

<citation disambiguate-add-year-suffix="true" collapse="year-suffix" year-suffix-delimiter=", " cite-group-delimiter="--">

then I get (Neave, 1939a--b--1940a--b). Which is not supposed to happen at least if I read the spec correctly? The spec clearly implies that cite-group-delimiter and collapse are not supposed to be used together ("Cite grouping can be activated by setting the cite-group-delimiter attribute or the collapse attributes"), but also does not state a behavior if both are defined.

And finally with <citation disambiguate-add-year-suffix="true" collapse="year-suffix"

I should get (Neave, 1939a; b; 1940a; b) according to the spec's own explicit example because the semicolon is set in "layout". What I actually get is (Neave, 1939a, b, 1940a, b), i.e. the default for cite-group-delimiter. At no point in these tests has year-suffix-delimiter ever been applies, or am I fundamentally misunderstanding something?

As a side note, I cannot tell from reading the spec whether you're supposed to be able to specify a distinct delimiter to appear between the collapsed"1939b" and "1940a".

With this code, I'd expect (Neave, 1939a--b--1940a--b). What I actually get is (Neave, 1939a, b, 1940a, b).

With

<citation disambiguate-add-year-suffix="true" collapse="year-suffix" year-suffix-delimiter=", " cite-group-delimiter="--">

then I get (Neave, 1939a--b--1940a--b). Which is not supposed to happen at least if I read the spec correctly? The spec clearly implies that cite-group-delimiter and collapse are not supposed to be used together ("Cite grouping can be activated by setting the cite-group-delimiter attribute or the collapse attributes"), but also does not state a behavior if both are defined.

And finally with <citation disambiguate-add-year-suffix="true" collapse="year-suffix"

I should get (Neave, 1939a; b; 1940a; b) according to the spec's own explicit example because the semicolon is set in "layout".

The same issue was discussed in citation-style-language/test-suite#50 and the current behavior seems incorrect. Besides, the grouping and collapsing procedures are also discussed in citation-style-language/schema#338.

I check the provided cases by creating a minimal test fixture. One may save it to fixures/local/test_Test.txt and then run cslrun -s test_Test.txt. Note that the author-short and issued-year macros are not provided in the original CSL code. I change them to names and date elements, respectively and they should not cause changes in the output. Unfortunately I don't reproduce all the results. @Circeus Did you get them from Zotero CSL editor or the online editor?

>>===== MODE =====>>
citation
<<===== MODE =====<<


>>===== RESULT =====>>
(Neave, 1939a--b--1940a--b)
<<===== RESULT =====<<


>>===== CITATION-ITEMS =====>>
[
    [
        {
            "id": "ITEM-1"
        },
        {
            "id": "ITEM-2"
        },
        {
            "id": "ITEM-3"
        },
        {
            "id": "ITEM-4"
        }
    ]
]
<<===== CITATION-ITEMS =====<<


>>===== CSL =====>>
<style
      xmlns="http://purl.org/net/xbiblio/csl"
      class="note"
      version="1.0">
  <info>
    <id />
    <title />
    <updated>2009-08-10T04:49:00+09:00</updated>
  </info>
  <citation disambiguate-add-year-suffix="true" collapse="year-suffix" year-suffix-delimiter="--">
    <sort>
      <key variable="author"/>
      <key variable="issued"/>
    </sort>
    <layout delimiter="; " prefix="(" suffix=")">
      <group delimiter=" ">
        <names variable="author" suffix=",">
          <name form="short"/>
        </names>
        <date variable="issued" form="numeric" date-parts="year"/>
      </group>
    </layout>
  </citation>
</style>
<<===== CSL =====<<


>>===== INPUT =====>>
[
    {
        "id": "ITEM-1",
        "type": "book",
        "author": [
            {
                "family": "Neave",
                "given": "S.A."
            }
        ],
        "issued": {
            "date-parts": [
                [
                    "1939"
                ]
            ]
        }
    },
    {
        "id": "ITEM-2",
        "type": "book",
        "author": [
            {
                "family": "Neave",
                "given": "S.A."
            }
        ],
        "issued": {
            "date-parts": [
                [
                    "1939"
                ]
            ]
        }
    },
    {
        "id": "ITEM-3",
        "type": "book",
        "author": [
            {
                "family": "Neave",
                "given": "S.A."
            }
        ],
        "issued": {
            "date-parts": [
                [
                    "1940"
                ]
            ]
        }
    },
    {
        "id": "ITEM-4",
        "type": "book",
        "author": [
            {
                "family": "Neave",
                "given": "S.A."
            }
        ],
        "issued": {
            "date-parts": [
                [
                    "1940"
                ]
            ]
        }
    }
]
<<===== INPUT =====<<

I get the result

      + expected - actual

      -(Neave, 1939a--b; 1940a--b)
      +(Neave, 1939a--b--1940a--b)

The output (Neave, 1939a--b; 1940a--b) seems reasonable but it's not (Neave, 1939a, b, 1940a, b) from @Circeus.

With <citation disambiguate-add-year-suffix="true" collapse="year-suffix" year-suffix-delimiter=", " cite-group-delimiter="--">, the output is exactly the same as (Neave, 1939a--b--1940a--b) and I agree that it's unexpected in the spec.

Finally with <citation disambiguate-add-year-suffix="true" collapse="year-suffix">, I get (Neave, 1939a; b; 1940a; b) which is exactly the expected result but it's not (Neave, 1939a, b, 1940a, b).

faunitaxys.txt

Here's the full code. Changing the year-suffix-delimiter in the online code editor (Zotero editor does not lat you change the code) has no effect, but if it's normal behavior, I haven't been able to figure out where I went wrong!

faunitaxys.txt

Here's the full code. Changing the year-suffix-delimiter in the online code editor (Zotero editor does not lat you change the code) has no effect, but if it's normal behavior, I haven't been able to figure out where I went wrong!

@Circeus Where did you get the citation output (Neave, 1939a, b, 1940a, b)? In the Zotero -> Preferences -> Cite -> Style Editor?

I loaded the CSL style file as well as the provided entries and I get the following results in the Zotero style editor:

  • With collapse="year-suffix" year-suffix-delimiter="--": (Neave, 1939a--b, 1940a--b);
  • With collapse="year-suffix" year-suffix-delimiter=", " cite-group-delimiter="--": (Neave, 1939a--b--1940a--b) (same as yours);
  • With collapse="year-suffix": (Neave, 1939a; b, 1940a; b), which is different from your (Neave, 1939a, b, 1940a, b). I'm surprised it's not the same as in the test fixture. I'll dig into this later.

@Circeus What is your desired output for the style? I'll see if it's possible to implement. Please provide your expected citation for the following case.

  • (Doe, 1938; Jones, 1939a, b, 1940; Smith, 1941)

As I stated above, this is directly from the online editor (https://editor.citationstyles.org/codeEditor/).

I just find the mistake in #215 (comment)'s fixture: the styles class should be "in-text" but it's mistakenly set to "note". After it's corrected, collapse="year-suffix" gives (Neave, 1939a, b, 1940a, b). It seems that citeproc-js treat note and in-text styles differently.

The cite-group-delimiter and year-suffix-delimiter problem here is a bug on the citeproc-js side. I'll try to make a patch.