jgm/citeproc

Reference stripped from the output in cites with position "ibid" and a suffix without a locator

badumont opened this issue · 7 comments

As of pandoc 2.19.2, a citation with a suffix but without a locator that appears immediatly after an occurrence of the same reference can cause one of these two bugs:

  • If its precedent occurrence has a locator, it is handled as if its position were "subsequent";
  • If its precedent occurrence has no locator, the reference is stripped from the output.

Sample MD file:

---
lang: en
references:
- type: article
  author:
  - family: Dummy
    given: John
  title: A dummy article
  issued: 2022
  id: Dummy2022
---

[@Dummy2022, {page 3-6}]

[@Dummy2022, {section 3-6}]

[@Dummy2022 for a more extensive survey]

[@Dummy2022 for additional references]

Minimal CSL file:

<?xml version="1.0" encoding="utf-8"?>
<style
    xmlns="http://purl.org/net/xbiblio/csl"
    class="note"
    version="1.0">
  <info>
    <title>Sub verbo is not abbreviated and sets "position" to "subsequent" instead of "ibid".</title>
    <title-short>testsv</title-short>
    <id>dummy</id>
    <author>
      <name>Bastien Dumont</name>
      <email>bastien.dumont@posteo.net</email>
    </author>
    <category citation-format="note"/>
    <updated>2022-09-06T20:14:27+01:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
    <locale xml:lang="en">
    <terms>
      <term name="sub-verbo" form="short">
        <single>s. v.</single>
        <multiple>s. vv.</multiple>
      </term>
    </terms>
  </locale>
  <citation>
    <layout>
      <group delimiter=", ">
        <choose>
          <if position="ibid-with-locator ibid" match="any">
            <text term="ibid"/>
          </if>
          <else-if position="subsequent">
            <group delimiter=" in note ">
              <text term="cited"/>
	      <text variable="first-reference-note-number"/>
            </group>
          </else-if>
          <else>
            <text variable="title"/>
          </else>
        </choose>
        <group delimiter=" ">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </group>
    </layout>
  </citation>
</style>

Output:

pandoc -v && pandoc -C --csl=test.csl -t plain test-bug-pandoc.md
pandoc 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.2.1
Scripting engine: Lua 5.4
User data directory: /home/bdumont/.local/share/pandoc
Copyright (C) 2006-2022 John MacFarlane. Web:  https://pandoc.org
This is free software; see the source for copying conditions. There is no
warranty, not even for merchantability or fitness for a particular purpose.
[1]

[2]

[3]

[4]

[1] A dummy article, pp. 3–6

[2] Ibid., secs. 3–6

[3] Cited in note 1 for a more extensive survey

[4] For additional references

Expected:

[3] Ibid. for a more extensive survey

[4] Ibid. for additional references
jgm commented

Here's a pure citeproc test case that reproduces this:

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



>>===== RESULT =====>>
<<===== RESULT =====<<


>>===== CITATIONS =====>>
[[ { "id":"Dummy2022", "locator": "Michael", "label": "sub verbo"} ]
,[ { "id":"Dummy2022", "locator": "15", "label": "page" } ]
,[ { "id":"Dummy2022", "suffix": "for a more extensive survey"} ]
,[ { "id":"Dummy2022", "suffix": "for more information"} ]
,[ { "id":"Dummy2022", "locator": "Michael", "label": "sub verbo"} ]]
<<===== CITATIONS =====<<




>>===== CSL =====>>

<?xml version="1.0" encoding="utf-8"?>
<style
    xmlns="http://purl.org/net/xbiblio/csl"
    class="note"
    version="1.0">
  <info>
    <title>Sub verbo is not abbreviated and sets "position" to "subsequent" instead of "ibid".</title>
    <title-short>testsv</title-short>
    <id>dummy</id>
    <author>
      <name>Bastien Dumont</name>
      <email>bastien.dumont@posteo.net</email>
    </author>
    <category citation-format="note"/>
    <updated>2022-09-06T20:14:27+01:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <citation>
    <layout>
      <group delimiter=", ">
        <choose>
          <if position="ibid-with-locator ibid" match="any">
            <text term="ibid"/>
          </if>
          <else-if position="subsequent">
            <group delimiter=" in note ">
              <text term="cited"/>
	      <text variable="first-reference-note-number"/>
            </group>
          </else-if>
          <else>
            <text variable="title"/>
          </else>
        </choose>
        <group delimiter=" ">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </group>
    </layout>
  </citation>
</style>
<<===== CSL =====<<


>>===== INPUT =====>>
[
  {
    "author": [
      {
        "family": "Dummy",
        "given": "John"
      }
    ],
    "id": "Dummy2022",
    "issued": {
      "date-parts": [
        [
          2022
        ]
      ]
    },
    "title": "A dummy article",
    "type": "article"
  }
]

<<===== INPUT =====<<


>>===== VERSION =====>>
1.0
<<===== VERSION =====<<

Output:

+A dummy article, s.v. Michael
+ibid., p. 15
+cited in note 1for a more extensive survey
+for more information
+ibid., s.v. Michael
jgm commented

I'm not sure this is a bug.

CSL spec says this about position:

“ibid”/”ibid-with-locator”/”subsequent”: cites referencing previously cited items have the “subsequent” position. Such cites may also have the “ibid” or “ibid-with-locator” position when:

the current cite immediately follows on another cite, within the same citation, that references the same item
or

the current cite is the first cite in the citation, and the previous citation consists of a single cite referencing the same item

If either requirement is met, the presence of locators determines which position is assigned:

Preceding cite does not have a locator: if the current cite has a locator, the position of the current cite is “ibid-with-locator”. Otherwise the position is “ibid”.
Preceding cite does have a locator: if the current cite has the same locator, the position of the current cite is “ibid”. If the locator differs the position is “ibid-with-locator”. If the current cite lacks a locator its only position is “subsequent”.

IN this case the second requirement is met, so we look at locators to see what the position should be. The second citation has a locator, and the third citation does not, so its only position is "subsequent."

Sorry, I missed this for the third citation. So the only problem is the absence of the reference in the fourth citation.

jgm commented

An updated more minimal test case.

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



>>===== RESULT =====>>
A dummy article, p. 15
cited in note 1 for a more extensive survey
cited in note 1 for more information
<<===== RESULT =====<<


>>===== CITATIONS =====>>
[[ { "id":"Dummy2022", "locator": "15", "label": "page" } ]
,[ { "id":"Dummy2022", "suffix": " for a more extensive survey"} ]
,[ { "id":"Dummy2022", "suffix": " for more information"} ]
]
<<===== CITATIONS =====<<




>>===== CSL =====>>

<?xml version="1.0" encoding="utf-8"?>
<style
    xmlns="http://purl.org/net/xbiblio/csl"
    class="note"
    version="1.0">
  <info>
    <title>Sub verbo is not abbreviated and sets "position" to "subsequent" instead of "ibid".</title>
    <title-short>testsv</title-short>
    <id>dummy</id>
    <author>
      <name>Bastien Dumont</name>
      <email>bastien.dumont@posteo.net</email>
    </author>
    <category citation-format="note"/>
    <updated>2022-09-06T20:14:27+01:00</updated>
    <rights license="http://creativecommons.org/licenses/by-sa/3.0/">This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 License</rights>
  </info>
  <citation>
    <layout>
      <group delimiter=", ">
        <choose>
          <if position="ibid-with-locator ibid" match="any">
            <text term="ibid"/>
          </if>
          <else-if position="subsequent">
            <group delimiter=" in note ">
              <text term="cited"/>
	      <text variable="first-reference-note-number"/>
            </group>
          </else-if>
          <else>
            <text variable="title"/>
          </else>
        </choose>
        <group delimiter=" ">
          <label variable="locator" form="short"/>
          <text variable="locator"/>
        </group>
      </group>
    </layout>
  </citation>
</style>
<<===== CSL =====<<


>>===== INPUT =====>>
[
  {
    "author": [
      {
        "family": "Dummy",
        "given": "John"
      }
    ],
    "id": "Dummy2022",
    "issued": {
      "date-parts": [
        [
          2022
        ]
      ]
    },
    "title": "A dummy article",
    "type": "article"
  }
]

<<===== INPUT =====<<


>>===== VERSION =====>>
1.0
<<===== VERSION =====<<

Diff in running test:

 cited in note 1 for a more extensive survey
-ibid. for more information
+for more information

(Is this the correct expected output?)

Yes! I change the title of the issue accordingly.

jgm commented

Have you tried this style with Zotero?

It seems to me that the output may actually be according to spec, but maybe there's something I don't understand. Spec says that a group is suppressed if it directly or indirectly calls at least one variable but all of the variables it calls are empty. Well, your style has a group that calls (indirectly) "locator"; when locator is empty, as in this case, the group is suppressed.

You could rewrite the style without the surrounding group; instead, put a prefix ", " on the group with the locator. (The whole group will be suppressed if this is empty.)

Oh yes, you are perfectly right. I should have tested it a bit more and figured it out myself. Sorry for having wasted your time and thank you very much for the solution.