zepinglee / citeproc-lua

A Lua implementation of the Citation Style Language (CSL)
MIT License
62 stars 7 forks source link

<span class=“nocase”>\{}noopsort</span> and <span class=“nocase”> printed #27

Closed bwakkie closed 1 year ago

bwakkie commented 1 year ago

Hi,

I have the following author problem: bib (Zotero BBT export):

@article{vansteenis1998c,
  title = {Description of and key to the {{European}} females of the {{{\emph{Platycheirus}}}} {\emph{peltatus}} sub-group ({{Diptera}}, {{Syrphidae}}), with a description of the male and female of {{P}}. {\emph{islandicus}} {{Ringdahl}}, 1930, stat. n},
  author = {{\noopsort{steenis}}{van Steenis}, J. and {Goeldlin de Tiefenau}, P.},
  year = {1998},
  journal = {Bulletin de la Société Entomologique Suisse},
  volume = {71},
  pages = {187--199},
  keywords = {⛔ No DOI found},
  groups = {taxofly},
  timestamp = {2022-10-29T12:36:46Z}
}
@preamble{ "\providecommand{\noopsort}[1]{} " }

tex

\documentclass[english]{article}
\usepackage{citation-style-language}
\cslsetup{style = zootaxa}
\addbibresource{../../taxofly.bib}
\begin{document}
\section{Citing Example}
Lorem ipsum dolor sit amet laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu \cite[some text]{vansteenis1998c} fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\nocite{*}
\printbibliography
\end{document}

Prints:

Lorem ipsum dolor sit amet laboris nisi ut aliquip ex ea commodo consequat.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore
eu J. <span class=“nocase”>\{}noopsort</span><span class=“nocase”>stee-
nis</span><span class=“nocase”>van Steenis</span>, <span class=“nocase”>Goeldlin
de Tiefenau</span>, et al. (1998), some text fugiat nulla pariatur. Excepteur
sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.

Problem: Some how the <span ..> are printed and should not be? ..or howe to get rid of them?

zepinglee commented 1 year ago

I suggest exporting from Zotero directly to CSL-JSON format and \addbibresource{foo.json}. This format is preferred because the data in other formats are converted to CSL-JSON for internal processing.

In this case, the \noopsort command is not handled correctly. The current version of citeproc-lua converts the .bib data to the following CSL-JSON data.

[
    {
        "author": [
            {
                "family": "Steenis</span>",
                "given": "J.",
                "non-dropping-particle": "<span class=\"nocase\">\\noopsort</span><span class=\"nocase\">steenis</span><span class=\"nocase\">van"
            },
            {
                "family": "Tiefenau</span>",
                "given": "P.",
                "non-dropping-particle": "<span class=\"nocase\">Goeldlin de"
            }
        ],
        "container-title": "Bulletin de la Soci\u00e9t\u00e9 Entomologique Suisse",
        "id": "vansteenis1998c",
        "issued": {
            "date-parts": [
                [
                    1998
                ]
            ]
        },
        "page": "187-199",
        "title": "Description of and key to the <span class=\"nocase\"><span class=\"nocase\">European</span></span> females of the <span class=\"nocase\"><span class=\"nocase\"><i>Platycheirus</i></span></span> <i><span class=\"nocase\">peltatus</span></i> sub-group (<span class=\"nocase\"><span class=\"nocase\">Diptera</span></span>, <span class=\"nocase\"><span class=\"nocase\">Syrphidae</span></span>), with a description of the male and female of <span class=\"nocase\"><span class=\"nocase\">P</span></span>. <i><span class=\"nocase\">islandicus</span></i> <span class=\"nocase\"><span class=\"nocase\">Ringdahl</span></span>, 1930, stat. n",
        "type": "article-journal",
        "volume": "71"
    }
]

The <span class="nocase"> and </span> tags are add for case protection like the {foo} in BibTeX fields. However the tags in von part and family part are incorrectly separated and unpaired.

BTW, does the BBT exporter add \noopsort command?

bwakkie commented 1 year ago

With the CSL JSON export it seems to work in the citing part, but the reference part gives the below error:


...scripts/citation-style-language/citeproc-node-locale.lua:129: attempt to comp
are nil with number
stack traceback:
    ...scripts/citation-style-language/citeproc-node-locale.lua:129: in method 'get
_ordinal_term'
    ...xmf/scripts/citation-style-language/citeproc-element.lua:466: in method 'for
mat_ordinal_number_parts'
    ...xmf/scripts/citation-style-language/citeproc-element.lua:380: in method 'for
mat_number'
    ...scripts/citation-style-language/citeproc-node-number.lua:54: in method 'buil
d_ir'
    ...xmf/scripts/citation-style-language/citeproc-element.lua:171: in method 'bui
ld_group_ir'
    .../scripts/citation-style-language/citeproc-node-group.lua:29: in method 'buil
d_ir'
    ...scripts/citation-style-language/citeproc-node-choose.lua:137: in method 'bui
ld_children_ir'
    ...scripts/citation-style-language/citeproc-node-choose.lua:181: in method 'bui
ld_ir'
    ...scripts/citation-style-language/citeproc-node-choose.lua:32: in method 'buil
d_ir'
    ...xmf/scripts/citation-style-language/citeproc-element.lua:171: in method 'bui
ld_group_ir'
    ...
    ...scripts/citation-style-language/citeproc-node-choose.lua:137: in method 'bui
ld_children_ir'
    ...scripts/citation-style-language/citeproc-node-choose.lua:181: in method 'bui
ld_ir'
    ...scripts/citation-style-language/citeproc-node-choose.lua:32: in method 'buil
d_ir'
    ...xmf/scripts/citation-style-language/citeproc-element.lua:136: in method 'bui
ld_children_ir'
    ...scripts/citation-style-language/citeproc-node-layout.lua:28: in method 'buil
d_ir'
    ...s/citation-style-language/citeproc-node-bibliography.lua:106: in method 'bui
ld_ir'
    ...s/citation-style-language/citeproc-node-bibliography.lua:85: in method 'buil
d_bibliography_str'
    ...exmf/scripts/citation-style-language/citeproc-engine.lua:560: in method 'mak
eBibliography'
    .../scripts/citation-style-language/citeproc-latex-core.lua:265: in function 'c
iteproc-latex-core.make_bibliography'
    ...texmf/scripts/citation-style-language/citeproc-latex.lua:146: in function 'c
iteproc-latex.bibliography'
    [\directlua]:1: in main chunk.
\lua_now:e #1->\__lua_now:n {#1}

l.13 \end
       {document}
The lua interpreter ran into a problem, so the
remainder of this lua chunk will be ignored.

[1

I uploaded my Zotero CSL JSON export which gives the above error.

BTW, does the BBT exporter add \noopsort command?

Only when I select "Disregard name prefixes when sorting" option n the automatic export preferences setting taxofly-zotero-csl.json.txt

zepinglee commented 1 year ago

I've created a patch to make the current data run successfully without errors but there are some problems.

  1. In bruns1984a, the value of number-of-pages is 91–129. This number-of-pages variable (or # of Pages in Zotero) is expected to be the total number of pages of the book rather than a specific range of pages.
  2. The page range delimiter in Zotero raw data is hyphen rather than en dash. It is converted to en dash or other symbols by the citeproc engine according to the given CSL style.
  3. The edition in stubbs2002a is 2nd. I suggest using arabic form because it can be converted to roman numeral or locale-specific ordinal according to the CSL style. Directly using 2nd may limit this conversion.
bwakkie commented 1 year ago

Super thangs for the quick fix. I also fixed the problems in the json file in the mean time.