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

Citation Key blocks following fields in note

denismaier opened this issue · comments

Depending on where citation-key is in note, later fields may not be recognized by citeproc-js. See retorquere/zotero-better-bibtex#2658 (I first thought it might be a BBT issue, but apparently it is not.)

With the three items and the minimal style below, I'm getting the following results:

  1. Citation Key directly above Event date -> "match" -> Event Date not used
  2. Citation Key last in Extra -> "10. Mai 2001match" -> as expecte
  3. Citation Key first in Extra -> "10. Mai 2001match" -> as expected
<?xml version="1.0" encoding="utf-8"?>
<style xmlns="http://purl.org/net/xbiblio/csl" class="in-text" version="1.0" demote-non-dropping-particle="never">
  <info>
    <title>event-date-test</title>
    <id>http://www.zotero.org/styles/event-date-test</id>
    <link rel="self" href="http://www.zotero.org/styles/event-date-test"/>
    <updated>2023-09-20T12:11:03+00:00</updated>
  </info>
  <citation>
    <layout>
      <date form="text" variable="event-date"/>
    </layout>
  </citation>
  <bibliography>
    <layout>
      <date form="text" variable="event-date"/>
      <choose>
        <if type="performance" match="any">
          <text value="match"/>
        </if>
      </choose>
    </layout>
  </bibliography>
</style>
[
	{
		"id": "nachwilliamshakespeareHamlet2001",
		"type": "graphic",
		"abstract": "Theateraufführung",
		"note": "type: performance\ndirector: Schlingensief || Christoph\npublisher-place: Schauspielhaus Zürich, Pfauen\nevent-date: 2001-05-10",
		"title": "Hamlet nach William Shakespeare",
		"issued": {
			"date-parts": [
				[
					"2001",
					5,
					10
				]
			]
		}
	},
	{
		"id": "HamletNachWilliam2001",
		"type": "graphic",
		"abstract": "Theateraufführung",
		"note": "type: performance\nevent-date: 2001-05-10",
		"title": "Hamlet nach William Shakespeare 2",
		"issued": {
			"date-parts": [
				[
					"2001",
					5,
					10
				]
			]
		}
	},
	{
		"id": "eventDateTest",
		"type": "graphic",
		"abstract": "Theateraufführung",
		"note": "type: performance\nevent-date: 2001-05-10",
		"title": "Hamlet nach William Shakespeare 3",
		"issued": {
			"date-parts": [
				[
					"2001",
					5,
					10
				]
			]
		}
	},
	{
		"id": "nachwilliamshakespeareHamlet2001a",
		"type": "graphic",
		"abstract": "Theateraufführung",
		"note": "event-date: 2001-05-10\ntype: performance\ndirector: Schlingensief || Christoph\npublisher-place: Schauspielhaus Zürich, Pfauen",
		"title": "Hamlet nach William Shakespeare 4",
		"issued": {
			"date-parts": [
				[
					"2001",
					5,
					10
				]
			]
		}
	},
	{
		"id": "schlingensiefHamletNachWilliam2001",
		"type": "graphic",
		"abstract": "Theateraufführung",
		"note": "type: performance\ndirector: Schlingensief || Christoph\nevent-date: 2001-05-10\npublisher-place: Schauspielhaus Zürich, Pfauen",
		"title": "Hamlet nach William Shakespeare 5",
		"issued": {
			"date-parts": [
				[
					"2001",
					5,
					10
				]
			]
		}
	}
]

Or is this a problem with how Zotero hands the data over to citeproc-js rather than a citeproc-js issue proper?

I don't see citation-key (or Citation Key) in the note field of any of the input items? Might be Zotero in that case?

You're right of course. The Citation Key ends up in id. And, interestingly, the other data also seems to be there, but this here doesn't work quite as it should:

grafik

grafik

But:

grafik

grafik

So:

  • Citation Key in the middle -> match on type works, but event-date is not there.
  • Citation Key on top -> match on type works, and event-date is there.

Any ideas?
Maybe @dstillman might be also interested in this.

This might be some leftover behavior from creating alignment with BetterBibTeX? @retorquere

I haven't been able to find anything. Not in citeproc-js, not in the Zotero sources. It's in the translators, but I don't think these are involved.

Okay, I think I've found it. (First off, when exporting to CSL-JSON the Citation Key field is (re)moved, but this is not the case when generating CSL-JSON for citeproc-js). Zotero transforms "Citation Key" to "citation-key", but this field is not recognized as a CSL-JSON field, and the transformation is canceled (code). "Citation Key" is not a valid variable name (docs, code). Citeproc only parses the note contents up to the first line that does not contain a note field, with the exception that the first line can contain anything:

Conforming braced-entries and line-entries must occur at the top of the note field. The set of entries may begin on the first or the second line of the field: parsing stops when the parser encounters a non-empty line after the first that does not fit the descriptions above. Parsed entries are removed from the note field before onward processing.

docs, code

Depending on whether the Citation Key should be available to citeproc or not, the field should either be mapped correctly to citation-key or removed altogether. In general, the behavior of not modifying unrecognized fields can probably lead to problems down the line.

citation-key is a CSL variable. It should be available to citeprocs

I think so (and more broadly we need to add the other new variables in CSL 1.0.2 to that list)

I'll work on it.

Thanks--I noticed that that needed to be updated a week or so ago and haven't found time to track down exactly where

I've added them. It might also be useful to move non-CSL fields to the bottom of the field list (to avoid this confusing behavior for typos etc.) but I can imagine that that could cause other issues.

Thanks.