diff options
Diffstat (limited to 'Master')
17 files changed, 3484 insertions, 2414 deletions
diff --git a/Master/texmf-dist/doc/latex/citation-style-language/CHANGELOG.md b/Master/texmf-dist/doc/latex/citation-style-language/CHANGELOG.md index e351714b3a9..6dd051a601f 100644 --- a/Master/texmf-dist/doc/latex/citation-style-language/CHANGELOG.md +++ b/Master/texmf-dist/doc/latex/citation-style-language/CHANGELOG.md @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v0.2.1] - 2022-09-18 + +### Changed + +- Rewrite BibTeX parser with `lpeg`. The accent letters are now converted to unicode. + +### Fixed + +- Fix redundant warning `entry "*" not found`. + ## [v0.2.0] - 2022-08-18 ### Added @@ -46,7 +56,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Initial CTAN release. -[Unreleased]: https://github.com/zepinglee/citeproc-lua/compare/v0.2.0...HEAD +[Unreleased]: https://github.com/zepinglee/citeproc-lua/compare/v0.2.1...HEAD +[v0.2.1]: https://github.com/zepinglee/citeproc-lua/compare/v0.2.0...0.2.1 [v0.2.0]: https://github.com/zepinglee/citeproc-lua/compare/v0.1.1...0.2.0 [v0.1.1]: https://github.com/zepinglee/citeproc-lua/compare/v0.1.0...v0.1.1 [v0.1.0]: https://github.com/zepinglee/citeproc-lua/releases/tag/v0.1.0 diff --git a/Master/texmf-dist/doc/latex/citation-style-language/DEPENDS.txt b/Master/texmf-dist/doc/latex/citation-style-language/DEPENDS.txt index 3d0edb73de8..8e08eb5388a 100644 --- a/Master/texmf-dist/doc/latex/citation-style-language/DEPENDS.txt +++ b/Master/texmf-dist/doc/latex/citation-style-language/DEPENDS.txt @@ -1,10 +1,11 @@ # The format of this file is described in https://www.tug.org/texlive/pkgcontrib.html#deps. -hard luatex -hard l3kernel -hard l3packages hard filehook -hard url -hard luaxml +hard l3kernel +hard l3packages # xparse +hard lpeg hard lua-uca -hard lualibs +hard lualibs # JSON parser +hard luatex +hard luaxml +hard url diff --git a/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.pdf b/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.pdf Binary files differindex af42980a811..6a7dd5f03fc 100644 --- a/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.pdf +++ b/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.pdf diff --git a/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.tex b/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.tex index 1dda26c5fa9..e4f9ea43761 100644 --- a/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.tex +++ b/Master/texmf-dist/doc/latex/citation-style-language/citation-style-language-doc.tex @@ -26,7 +26,7 @@ \lstset{ basicstyle = \ttfamily\small, basewidth = 0.51em, - gobble = 2, + % gobble = 2, language = bash, } }{} @@ -49,7 +49,7 @@ }% } -\date{2022-08-18 v0.2.0} +\date{2022-09-18 v0.2.1} \maketitle @@ -77,6 +77,38 @@ are not implemented yet. Comments, suggestions, and bug reports are welcome. +\section{Installation} + +This package is available from TeX Live 2022 or later versions. +For most users, the easiest way is to install it via |tlmgr|. +If you want to install the GitHub develop version of this package, +you may follow the steps below. + +The \pkg{citation-style-language} requires the following packages: +\pkg{filehook}, \pkg{l3kernel}, \pkg{l3packages}, \pkg{lua-uca}, \pkg{lualibs}, +\pkg{luatex}, \pkg{luaxml}, and \pkg{url}. +\pkg{l3build} is also required for actually performing the installation. +Make sure they are already installed in the TeX distribution. + +\begin{bash} + git clone https://github.com/zepinglee/citeproc-lua # Clone the repository + cd citeproc-lua + git submodule update --init --remote # Fetch submodules + l3build install +\end{bash} + +These commands install the package files to |TEXMFHOME| which is usually +|~/texmf| on Linux or |~/Library/texmf| on macOS. +Besides, the |citeproc-lua| executable needs to be copied to some directory in +the |PATH| environmental variable so that it can be called directly in the shell. +For example provided |~/bin| is in |PATH|: + +\begin{bash} + cp citeproc/citeproc-lua.lua "~/bin/citeproc-lua" +\end{bash} + +To uninstall the package from |TEXMFHOME|, just run |l3build uninstall|. + \section{Getting started} An example of using \pkg{citation-style-language} package is as follows. @@ -107,12 +139,12 @@ which is the same as documents with cross references. \paragraph{Other engines} -For engines other than LuaTeX, the \file{citeproc} executable is required +For engines other than LuaTeX, the \file{citeproc-lua} executable is required to run on the \file{.aux} file to generate the citations and bibliography. The general procedure is similar to the traditional BibTeX workflow. \begin{enumerate} \item Run \file{latex} on \file{example.tex}. - \item Run \file{citeproc} on \file{example.aux}. + \item Run \file{citeproc-lua} on \file{example.aux}. The engine reads the \file{.csl} style, CSL locale files, and \file{.bib} database and then writes the processed citations and bibliography to \file{example.bbl}. diff --git a/Master/texmf-dist/doc/man/man1/citeproc-lua.man1.pdf b/Master/texmf-dist/doc/man/man1/citeproc-lua.man1.pdf Binary files differindex 93a4090cd09..2f68a15b246 100644 --- a/Master/texmf-dist/doc/man/man1/citeproc-lua.man1.pdf +++ b/Master/texmf-dist/doc/man/man1/citeproc-lua.man1.pdf diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-bib-data.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bib-data.lua deleted file mode 100644 index dafd3d05b44..00000000000 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-bib-data.lua +++ /dev/null @@ -1,1759 +0,0 @@ --- This file is generated from citeproc-bib-data.json by update-bib-date.py - -return { - ["description"] = "Bib CSL mapping", - ["types"] = { - ["archival"] = { - ["csl"] = "collection", - }, - ["archive"] = { - ["csl"] = "collection", - }, - ["article"] = { - ["csl"] = "article-journal", - }, - ["artifactdataset"] = { - ["csl"] = "dataset", - }, - ["artifactsoftware"] = { - ["csl"] = "software", - }, - ["artwork"] = { - ["csl"] = "graphic", - }, - ["atlas"] = { - ["csl"] = nil, - }, - ["audio"] = { - ["csl"] = "song", - }, - ["bachelor"] = { - ["csl"] = "thesis", - }, - ["bibnote"] = { - ["csl"] = nil, - }, - ["book"] = { - ["csl"] = "book", - }, - ["bookinbook"] = { - ["csl"] = "chapter", - }, - ["booklet"] = { - ["csl"] = "pamphlet", - }, - ["brochure"] = { - ["csl"] = "pamphlet", - }, - ["cconference"] = { - ["csl"] = nil, - }, - ["collection"] = { - ["csl"] = "book", - }, - ["comment"] = { - ["csl"] = nil, - }, - ["commentary"] = { - ["csl"] = "book", - }, - ["commented"] = { - ["csl"] = nil, - }, - ["conference"] = { - ["csl"] = "paper-conference", - }, - ["ctan"] = { - ["csl"] = "software", - }, - ["customa"] = { - ["csl"] = nil, - }, - ["customb"] = { - ["csl"] = nil, - }, - ["customc"] = { - ["csl"] = nil, - }, - ["customd"] = { - ["csl"] = nil, - }, - ["custome"] = { - ["csl"] = nil, - }, - ["customf"] = { - ["csl"] = nil, - }, - ["database"] = { - ["csl"] = "dataset", - }, - ["dataset"] = { - ["csl"] = "dataset", - }, - ["dictionary"] = { - ["csl"] = "book", - }, - ["docthesis"] = { - ["csl"] = "thesis", - }, - ["electronic"] = { - ["csl"] = "webpage", - }, - ["eulegislation"] = { - ["csl"] = "legislation", - }, - ["footnote"] = { - ["csl"] = nil, - }, - ["game"] = { - ["csl"] = "software", - }, - ["govpub"] = { - ["csl"] = "regulation", - }, - ["habthesis"] = { - ["csl"] = "thesis", - }, - ["heading"] = { - ["csl"] = nil, - }, - ["hidden"] = { - ["csl"] = nil, - }, - ["image"] = { - ["csl"] = "graphic", - }, - ["inbook"] = { - ["csl"] = "chapter", - }, - ["incollection"] = { - ["csl"] = "chapter", - }, - ["inloosecollection"] = { - ["csl"] = "chapter", - }, - ["inpress"] = { - ["csl"] = "article", - }, - ["inproceedings"] = { - ["csl"] = "paper-conference", - }, - ["inreference"] = { - ["csl"] = "entry", - }, - ["inserialcollection"] = { - ["csl"] = nil, - }, - ["internet"] = { - ["csl"] = "webpage", - }, - ["journalpart"] = { - ["csl"] = nil, - }, - ["journals"] = { - ["csl"] = "periodical", - }, - ["jurisdiction"] = { - ["csl"] = nil, - }, - ["jurthesis"] = { - ["csl"] = "thesis", - }, - ["legal"] = { - ["csl"] = "treaty", - }, - ["legislation"] = { - ["csl"] = "legislation", - }, - ["letter"] = { - ["csl"] = "personal_communication", - }, - ["lexicon"] = { - ["csl"] = "book", - }, - ["majorthesis"] = { - ["csl"] = "thesis", - }, - ["manual"] = { - ["csl"] = "report", - }, - ["map"] = { - ["csl"] = "map", - }, - ["mastersthesis"] = { - ["csl"] = "thesis", - }, - ["masterthesis"] = { - ["csl"] = "thesis", - }, - ["minorthesis"] = { - ["csl"] = "thesis", - }, - ["misc"] = { - ["csl"] = "document", - }, - ["monograph"] = { - ["csl"] = "book", - }, - ["monography"] = { - ["csl"] = "book", - }, - ["movie"] = { - ["csl"] = "motion_picture", - }, - ["music"] = { - ["csl"] = "song", - }, - ["mvbook"] = { - ["csl"] = "book", - }, - ["mvcollection"] = { - ["csl"] = "book", - }, - ["mvproceedings"] = { - ["csl"] = "book", - }, - ["mvreference"] = { - ["csl"] = "book", - }, - ["news"] = { - ["csl"] = "article-newspaper", - }, - ["newspaper"] = { - ["csl"] = "article-newspaper", - }, - ["online"] = { - ["csl"] = "webpage", - }, - ["other"] = { - ["csl"] = nil, - }, - ["patent"] = { - ["csl"] = "patent", - }, - ["performance"] = { - ["csl"] = "performance", - }, - ["periodical"] = { - ["csl"] = "periodical", - }, - ["phdthesis"] = { - ["csl"] = "thesis", - }, - ["preamble"] = { - ["csl"] = nil, - }, - ["preprint"] = { - ["csl"] = "article", - }, - ["presentation"] = { - ["csl"] = "speech", - }, - ["proceedings"] = { - ["csl"] = "book", - }, - ["program"] = { - ["csl"] = "software", - }, - ["reference"] = { - ["csl"] = "book", - }, - ["report"] = { - ["csl"] = "report", - }, - ["repository"] = { - ["csl"] = nil, - }, - ["review"] = { - ["csl"] = "review", - }, - ["set"] = { - ["csl"] = nil, - }, - ["setup"] = { - ["csl"] = nil, - }, - ["software"] = { - ["csl"] = "software", - }, - ["standard"] = { - ["csl"] = "standard", - }, - ["string"] = { - ["csl"] = nil, - }, - ["suppbook"] = { - ["csl"] = "chapter", - }, - ["suppcollection"] = { - ["csl"] = "chapter", - }, - ["suppperiodical"] = { - ["csl"] = "article", - }, - ["techreport"] = { - ["csl"] = "report", - }, - ["techstandard"] = { - ["csl"] = "standard", - }, - ["thesis"] = { - ["csl"] = "thesis", - }, - ["uklegislation"] = { - ["csl"] = "legislation", - }, - ["unpublished"] = { - ["csl"] = "manuscript", - }, - ["video"] = { - ["csl"] = "motion_picture", - }, - ["webpage"] = { - ["csl"] = "webpage", - }, - ["website"] = { - ["csl"] = nil, - }, - ["www"] = { - ["csl"] = "webpage", - }, - ["xdata"] = { - ["csl"] = nil, - }, - }, - ["fields"] = { - ["abstract"] = { - ["csl"] = "abstract", - ["type"] = "literal", - }, - ["account"] = { - ["csl"] = nil, - }, - ["acronym"] = { - ["csl"] = nil, - }, - ["add"] = { - ["csl"] = nil, - }, - ["add1"] = { - ["csl"] = nil, - }, - ["addendum"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["address"] = { - ["csl"] = "publisher-place", - ["type"] = "literal", - }, - ["adsurl"] = { - ["csl"] = nil, - }, - ["advisor"] = { - ["csl"] = nil, - }, - ["afterword"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["annotate"] = { - ["csl"] = "note", - }, - ["annotation"] = { - ["csl"] = "note", - ["type"] = "literal", - }, - ["annotator"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["annote"] = { - ["csl"] = "note", - ["type"] = "literal", - }, - ["annotelanguage"] = { - ["csl"] = nil, - }, - ["applicant"] = { - ["csl"] = nil, - }, - ["archive"] = { - ["csl"] = "archive", - }, - ["archiveprefix"] = { - ["csl"] = "archive", - ["type"] = "literal", - }, - ["archname"] = { - ["csl"] = "archive", - }, - ["articleno"] = { - ["csl"] = nil, - }, - ["arxiv"] = { - ["csl"] = nil, - }, - ["assignee"] = { - ["csl"] = nil, - }, - ["author"] = { - ["csl"] = "author", - ["type"] = "name", - }, - ["authorcountry"] = { - ["csl"] = nil, - }, - ["authorfa"] = { - ["csl"] = nil, - }, - ["authortype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["bibsource"] = { - ["csl"] = nil, - }, - ["biburl"] = { - ["csl"] = nil, - }, - ["binding"] = { - ["csl"] = nil, - }, - ["birthday"] = { - ["csl"] = nil, - }, - ["birthyear"] = { - ["csl"] = nil, - }, - ["bookaddress"] = { - ["csl"] = nil, - }, - ["bookauthor"] = { - ["csl"] = "container-author", - ["type"] = "name", - }, - ["booklanguage"] = { - ["csl"] = nil, - }, - ["bookpages"] = { - ["csl"] = nil, - }, - ["bookpagination"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["booksubtitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["booktitle"] = { - ["csl"] = "container-title", - ["type"] = "literal", - }, - ["booktitleaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["caption"] = { - ["csl"] = nil, - }, - ["caption1"] = { - ["csl"] = nil, - }, - ["cartographer"] = { - ["csl"] = nil, - }, - ["casenumber"] = { - ["csl"] = nil, - }, - ["category"] = { - ["csl"] = nil, - }, - ["cellular"] = { - ["csl"] = nil, - }, - ["chair"] = { - ["csl"] = nil, - }, - ["chapter"] = { - ["csl"] = "chapter-number", - ["type"] = "literal", - }, - ["citedate"] = { - ["csl"] = nil, - }, - ["city"] = { - ["csl"] = nil, - }, - ["code"] = { - ["csl"] = nil, - }, - ["coden"] = { - ["csl"] = nil, - }, - ["collaboration"] = { - ["csl"] = nil, - }, - ["collator"] = { - ["csl"] = nil, - }, - ["commentator"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["commit"] = { - ["csl"] = nil, - }, - ["compiler"] = { - ["csl"] = nil, - }, - ["condition"] = { - ["csl"] = nil, - }, - ["conference-location"] = { - ["csl"] = nil, - }, - ["conference-number"] = { - ["csl"] = nil, - }, - ["conference-year"] = { - ["csl"] = nil, - }, - ["copy"] = { - ["csl"] = nil, - }, - ["country"] = { - ["csl"] = nil, - }, - ["credits"] = { - ["csl"] = nil, - }, - ["crossref"] = { - ["csl"] = nil, - ["type"] = "entrykey", - }, - ["ctrl-article-title"] = { - ["csl"] = nil, - }, - ["ctrl-chapter-title"] = { - ["csl"] = nil, - }, - ["ctrl-doi"] = { - ["csl"] = nil, - }, - ["ctrl-etal-firstonly"] = { - ["csl"] = nil, - }, - ["ctrl-etal-number"] = { - ["csl"] = nil, - }, - ["ctrl-link-doi"] = { - ["csl"] = nil, - }, - ["ctrl-use-doi-all"] = { - ["csl"] = nil, - }, - ["ctrl-use-title"] = { - ["csl"] = nil, - }, - ["dataset"] = { - ["csl"] = nil, - }, - ["date"] = { - ["csl"] = "issued", - ["type"] = "date", - }, - ["day"] = { - ["csl"] = nil, - }, - ["dayfiled"] = { - ["csl"] = nil, - }, - ["definition"] = { - ["csl"] = nil, - }, - ["department"] = { - ["csl"] = nil, - }, - ["description"] = { - ["csl"] = nil, - }, - ["designator"] = { - ["csl"] = nil, - }, - ["dimensions"] = { - ["csl"] = nil, - }, - ["dissyear"] = { - ["csl"] = nil, - }, - ["doi"] = { - ["csl"] = "DOI", - ["type"] = "verbatim", - }, - ["dticnumber"] = { - ["csl"] = nil, - }, - ["dummy"] = { - ["csl"] = nil, - }, - ["edition"] = { - ["csl"] = "edition", - ["type"] = "literal", - }, - ["editor"] = { - ["csl"] = "editor", - ["type"] = "name", - }, - ["editora"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["editoratype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["editorb"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["editorbtype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["editorc"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["editorctype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["editortype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["eid"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["email"] = { - ["csl"] = nil, - }, - ["endnumber"] = { - ["csl"] = nil, - }, - ["endvolume"] = { - ["csl"] = nil, - }, - ["endyear"] = { - ["csl"] = nil, - }, - ["englishtitle"] = { - ["csl"] = nil, - }, - ["entryset"] = { - ["csl"] = nil, - ["type"] = "entrykey", - }, - ["entrysubtype"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["epilog"] = { - ["csl"] = nil, - }, - ["eprint"] = { - ["csl"] = nil, - ["type"] = "verbatim", - }, - ["eprintclass"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["eprints"] = { - ["csl"] = nil, - }, - ["eprinttype"] = { - ["csl"] = "archive", - ["type"] = "literal", - }, - ["erratumeid"] = { - ["csl"] = nil, - }, - ["erratumgermanpages"] = { - ["csl"] = nil, - }, - ["erratumnumpages"] = { - ["csl"] = nil, - }, - ["erratumpages"] = { - ["csl"] = nil, - }, - ["erratumvolume"] = { - ["csl"] = nil, - }, - ["erratumyear"] = { - ["csl"] = nil, - }, - ["eventdate"] = { - ["csl"] = "event-date", - ["type"] = "date", - }, - ["eventtitle"] = { - ["csl"] = "event-title", - ["type"] = "literal", - }, - ["eventtitleaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["eventyear"] = { - ["csl"] = nil, - }, - ["execute"] = { - ["csl"] = nil, - ["type"] = "code", - }, - ["faddress"] = { - ["csl"] = nil, - }, - ["fakeset"] = { - ["csl"] = nil, - }, - ["fax"] = { - ["csl"] = nil, - }, - ["file"] = { - ["csl"] = nil, - ["type"] = "verbatim", - }, - ["firstkey"] = { - ["csl"] = nil, - }, - ["fjournal"] = { - ["csl"] = nil, - }, - ["flanguage"] = { - ["csl"] = nil, - }, - ["font"] = { - ["csl"] = nil, - }, - ["foreword"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["founder"] = { - ["csl"] = nil, - }, - ["fpublisher"] = { - ["csl"] = nil, - }, - ["ftitle"] = { - ["csl"] = nil, - }, - ["furtherresp"] = { - ["csl"] = nil, - }, - ["fyear"] = { - ["csl"] = nil, - }, - ["gender"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["germanpages"] = { - ["csl"] = nil, - }, - ["group"] = { - ["csl"] = nil, - }, - ["heading"] = { - ["csl"] = nil, - }, - ["hereafter"] = { - ["csl"] = nil, - }, - ["holder"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["howcited"] = { - ["csl"] = nil, - }, - ["howpublished"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["hyphenation"] = { - ["csl"] = "language", - ["type"] = "literal", - }, - ["ids"] = { - ["csl"] = nil, - ["type"] = "entrykey", - }, - ["illustrated"] = { - ["csl"] = nil, - }, - ["illustrations"] = { - ["csl"] = nil, - }, - ["illustrator"] = { - ["csl"] = nil, - }, - ["indexsorttitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["indextitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["institution"] = { - ["csl"] = "publisher", - ["type"] = "literal", - }, - ["introduction"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["intype"] = { - ["csl"] = nil, - }, - ["inventor"] = { - ["csl"] = nil, - }, - ["ipc"] = { - ["csl"] = nil, - }, - ["isan"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["isbn"] = { - ["csl"] = "ISBN", - ["type"] = "literal", - }, - ["ismn"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["iso-abbreviation"] = { - ["csl"] = nil, - }, - ["iso-author-punctuation"] = { - ["csl"] = nil, - }, - ["iso-date-place"] = { - ["csl"] = nil, - }, - ["isrn"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["issn"] = { - ["csl"] = "ISSN", - ["type"] = "literal", - }, - ["issue"] = { - ["csl"] = "issue", - ["type"] = "literal", - }, - ["issuesubtitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["issuetitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["issuetitleaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["iswc"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["jfmnumber"] = { - ["csl"] = nil, - }, - ["journal"] = { - ["csl"] = "container-title", - ["type"] = "literal", - }, - ["journalsubtitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["journaltie"] = { - ["csl"] = nil, - }, - ["journaltitle"] = { - ["csl"] = "container-title", - ["type"] = "literal", - }, - ["journaltitleaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["juraauthor"] = { - ["csl"] = nil, - }, - ["juratitle"] = { - ["csl"] = nil, - }, - ["key"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["keywords"] = { - ["csl"] = nil, - ["type"] = "keyword", - }, - ["label"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["lang"] = { - ["csl"] = nil, - }, - ["langid"] = { - ["csl"] = "language", - ["type"] = "literal", - }, - ["langidopts"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["language"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["lastaccessed"] = { - ["csl"] = "accessed", - }, - ["lastchecked"] = { - ["csl"] = "accessed", - }, - ["lccn"] = { - ["csl"] = nil, - }, - ["library"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["lista"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["listb"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["listc"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["listd"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["liste"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["listf"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["littype"] = { - ["csl"] = nil, - }, - ["location"] = { - ["csl"] = "publisher-place", - ["type"] = "literal", - }, - ["madadurltest"] = { - ["csl"] = nil, - }, - ["main"] = { - ["csl"] = nil, - }, - ["main1"] = { - ["csl"] = nil, - }, - ["mainsubtitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["maintitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["maintitleaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["majorcode"] = { - ["csl"] = nil, - }, - ["marginnote"] = { - ["csl"] = nil, - }, - ["mark"] = { - ["csl"] = nil, - }, - ["max.best.papers"] = { - ["csl"] = nil, - }, - ["mcitetail"] = { - ["csl"] = nil, - }, - ["media"] = { - ["csl"] = "medium", - }, - ["medium"] = { - ["csl"] = "medium", - }, - ["meeting"] = { - ["csl"] = nil, - }, - ["misctitle"] = { - ["csl"] = nil, - }, - ["miscyear"] = { - ["csl"] = nil, - }, - ["mobile"] = { - ["csl"] = nil, - }, - ["modifydate"] = { - ["csl"] = nil, - }, - ["month"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["monthfiled"] = { - ["csl"] = nil, - }, - ["mrnumber"] = { - ["csl"] = nil, - }, - ["name"] = { - ["csl"] = nil, - }, - ["namea"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["nameaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["nameatype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["nameb"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["namebtype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["namec"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["namectype"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["nationality"] = { - ["csl"] = nil, - }, - ["nbirthday"] = { - ["csl"] = nil, - }, - ["newpage"] = { - ["csl"] = nil, - }, - ["newspaper"] = { - ["csl"] = "container-title", - }, - ["nickname"] = { - ["csl"] = nil, - }, - ["nihms"] = { - ["csl"] = nil, - }, - ["noed"] = { - ["csl"] = nil, - }, - ["nolink"] = { - ["csl"] = nil, - }, - ["normal"] = { - ["csl"] = nil, - }, - ["normalauthor"] = { - ["csl"] = nil, - }, - ["normaleditor"] = { - ["csl"] = nil, - }, - ["note"] = { - ["csl"] = "note", - ["type"] = "literal", - }, - ["nowarning"] = { - ["csl"] = nil, - }, - ["number"] = { - ["csl"] = "number", - ["type"] = "literal", - }, - ["numpages"] = { - ["csl"] = nil, - }, - ["oaddress"] = { - ["csl"] = nil, - }, - ["options"] = { - ["csl"] = nil, - ["type"] = "option", - }, - ["opublisher"] = { - ["csl"] = nil, - }, - ["org-short"] = { - ["csl"] = nil, - }, - ["organization"] = { - ["csl"] = "publisher", - ["type"] = "literal", - }, - ["origdate"] = { - ["csl"] = "original-date", - ["type"] = "date", - }, - ["originaladdress"] = { - ["csl"] = "original-publisher-place", - }, - ["originalbooktitle"] = { - ["csl"] = nil, - }, - ["originaledition"] = { - ["csl"] = nil, - }, - ["originaleditor"] = { - ["csl"] = nil, - }, - ["originaljournal"] = { - ["csl"] = nil, - }, - ["originalnumber"] = { - ["csl"] = nil, - }, - ["originalpages"] = { - ["csl"] = nil, - }, - ["originalpublisher"] = { - ["csl"] = "original-publisher", - }, - ["originalvolume"] = { - ["csl"] = nil, - }, - ["originalyear"] = { - ["csl"] = "original-date", - }, - ["origlanguage"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["origlocation"] = { - ["csl"] = "original-publisher-place", - ["type"] = "literal", - }, - ["origpublisher"] = { - ["csl"] = "original-publisher", - ["type"] = "literal", - }, - ["origtitle"] = { - ["csl"] = "original-title", - ["type"] = "literal", - }, - ["oyear"] = { - ["csl"] = nil, - }, - ["pagename"] = { - ["csl"] = nil, - }, - ["pages"] = { - ["csl"] = "page", - ["type"] = "range", - }, - ["pagetotal"] = { - ["csl"] = "number-of-pages", - ["type"] = "literal", - }, - ["pagination"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["paper"] = { - ["csl"] = nil, - }, - ["part"] = { - ["csl"] = "part", - ["type"] = "literal", - }, - ["patentid"] = { - ["csl"] = nil, - }, - ["pdf"] = { - ["csl"] = nil, - ["type"] = "verbatim", - }, - ["phone"] = { - ["csl"] = nil, - }, - ["pid"] = { - ["csl"] = nil, - }, - ["pii"] = { - ["csl"] = nil, - }, - ["pmcid"] = { - ["csl"] = "PMCID", - }, - ["prebibitem"] = { - ["csl"] = nil, - }, - ["preface"] = { - ["csl"] = nil, - }, - ["preprint"] = { - ["csl"] = nil, - }, - ["presort"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["price"] = { - ["csl"] = nil, - }, - ["primaryclass"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["printing"] = { - ["csl"] = nil, - }, - ["prioritycountry"] = { - ["csl"] = nil, - }, - ["prioritydate"] = { - ["csl"] = nil, - }, - ["prioritynumber"] = { - ["csl"] = nil, - }, - ["pseudonym"] = { - ["csl"] = nil, - }, - ["publication"] = { - ["csl"] = nil, - }, - ["publicationdate"] = { - ["csl"] = nil, - }, - ["publisher"] = { - ["csl"] = "publisher", - ["type"] = "literal", - }, - ["pubmed"] = { - ["csl"] = "PMID", - }, - ["pubstate"] = { - ["csl"] = nil, - ["type"] = "key", - }, - ["related"] = { - ["csl"] = nil, - ["type"] = "entrykey", - }, - ["relatedoptions"] = { - ["csl"] = nil, - ["type"] = "option", - }, - ["relatedstring"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["relatedtype"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["reprinted-from"] = { - ["csl"] = nil, - }, - ["reprinted-text"] = { - ["csl"] = nil, - }, - ["reprinttitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["requestdate"] = { - ["csl"] = nil, - }, - ["requestnumber"] = { - ["csl"] = nil, - }, - ["responsible"] = { - ["csl"] = nil, - }, - ["review"] = { - ["csl"] = nil, - }, - ["revision"] = { - ["csl"] = nil, - }, - ["school"] = { - ["csl"] = "publisher", - ["type"] = "literal", - }, - ["score"] = { - ["csl"] = nil, - }, - ["section"] = { - ["csl"] = nil, - }, - ["series"] = { - ["csl"] = "collection-title", - ["type"] = "literal", - }, - ["seriesedition"] = { - ["csl"] = nil, - }, - ["short"] = { - ["csl"] = nil, - }, - ["shortarchive"] = { - ["csl"] = nil, - }, - ["shortauthor"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["shorteditor"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["shorthand"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["shorthandintro"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["shortjournal"] = { - ["csl"] = "container-title-short", - ["type"] = "literal", - }, - ["shortseries"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["shortsubarchive"] = { - ["csl"] = nil, - }, - ["shorttitle"] = { - ["csl"] = "title-short", - ["type"] = "literal", - }, - ["shorturl"] = { - ["csl"] = nil, - }, - ["sig1"] = { - ["csl"] = nil, - }, - ["sig2"] = { - ["csl"] = nil, - }, - ["sig3"] = { - ["csl"] = nil, - }, - ["sig4"] = { - ["csl"] = nil, - }, - ["size"] = { - ["csl"] = nil, - }, - ["slaccitation"] = { - ["csl"] = nil, - }, - ["sort-short"] = { - ["csl"] = nil, - }, - ["sort-word"] = { - ["csl"] = nil, - }, - ["sortas"] = { - ["csl"] = nil, - }, - ["sortkey"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["sortname"] = { - ["csl"] = nil, - ["type"] = "name", - }, - ["sortshorthand"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["sorttitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["sortyear"] = { - ["csl"] = nil, - ["type"] = "integer", - }, - ["source1"] = { - ["csl"] = nil, - }, - ["specialitycode"] = { - ["csl"] = nil, - }, - ["ssedition"] = { - ["csl"] = nil, - }, - ["standard"] = { - ["csl"] = nil, - }, - ["startnumber"] = { - ["csl"] = nil, - }, - ["startvolume"] = { - ["csl"] = nil, - }, - ["startyear"] = { - ["csl"] = nil, - }, - ["state"] = { - ["csl"] = nil, - }, - ["status"] = { - ["csl"] = nil, - }, - ["stdcode"] = { - ["csl"] = nil, - }, - ["stitle"] = { - ["csl"] = nil, - }, - ["street"] = { - ["csl"] = nil, - }, - ["subarchive"] = { - ["csl"] = nil, - }, - ["subtitle"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["symposium"] = { - ["csl"] = nil, - }, - ["text"] = { - ["csl"] = nil, - }, - ["timestamp"] = { - ["csl"] = nil, - }, - ["title"] = { - ["csl"] = "title", - ["type"] = "literal", - }, - ["titleaddon"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["titlenote"] = { - ["csl"] = nil, - }, - ["totalpages"] = { - ["csl"] = nil, - }, - ["transissue"] = { - ["csl"] = nil, - }, - ["transjournal"] = { - ["csl"] = nil, - }, - ["translation"] = { - ["csl"] = nil, - }, - ["translator"] = { - ["csl"] = "translator", - ["type"] = "name", - }, - ["transnumber"] = { - ["csl"] = nil, - }, - ["transpages"] = { - ["csl"] = nil, - }, - ["transsection"] = { - ["csl"] = nil, - }, - ["transvolume"] = { - ["csl"] = nil, - }, - ["transyear"] = { - ["csl"] = nil, - }, - ["type"] = { - ["csl"] = "genre", - ["type"] = "key", - }, - ["typeoflit"] = { - ["csl"] = nil, - }, - ["umfnumber"] = { - ["csl"] = nil, - }, - ["updated"] = { - ["csl"] = nil, - }, - ["url"] = { - ["csl"] = "URL", - ["type"] = "uri", - }, - ["urlaccessdate"] = { - ["csl"] = "accessed", - }, - ["urldate"] = { - ["csl"] = "accessed", - ["type"] = "date", - }, - ["urlnewline"] = { - ["csl"] = nil, - }, - ["urltype"] = { - ["csl"] = nil, - }, - ["urlyear"] = { - ["csl"] = nil, - }, - ["urn"] = { - ["csl"] = nil, - }, - ["usera"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["userb"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["userc"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["userd"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["usere"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["userf"] = { - ["csl"] = nil, - ["type"] = "literal", - }, - ["value"] = { - ["csl"] = nil, - }, - ["venue"] = { - ["csl"] = "event-place", - ["type"] = "literal", - }, - ["verba"] = { - ["csl"] = nil, - ["type"] = "verbatim", - }, - ["verbb"] = { - ["csl"] = nil, - ["type"] = "verbatim", - }, - ["verbc"] = { - ["csl"] = nil, - ["type"] = "verbatim", - }, - ["version"] = { - ["csl"] = "version", - ["type"] = "literal", - }, - ["versiontype"] = { - ["csl"] = nil, - }, - ["volformat"] = { - ["csl"] = nil, - }, - ["volume"] = { - ["csl"] = "volume", - ["type"] = "integer", - }, - ["volumes"] = { - ["csl"] = "number-of-volumes", - ["type"] = "integer", - }, - ["volumetitle"] = { - ["csl"] = nil, - }, - ["word"] = { - ["csl"] = nil, - }, - ["xdata"] = { - ["csl"] = nil, - ["type"] = "entrykey", - }, - ["xid"] = { - ["csl"] = nil, - }, - ["xref"] = { - ["csl"] = nil, - ["type"] = "entrykey", - }, - ["year"] = { - ["csl"] = nil, - ["type"] = "date", - }, - ["year-presented"] = { - ["csl"] = nil, - }, - ["yearcomp"] = { - ["csl"] = nil, - }, - ["yearfiled"] = { - ["csl"] = nil, - }, - ["zblnumber"] = { - ["csl"] = nil, - }, - ["zip"] = { - ["csl"] = nil, - }, - }, - ["macros"] = { - ["jan"] = { - ["value"] = "1", - }, - ["feb"] = { - ["value"] = "2", - }, - ["mar"] = { - ["value"] = "3", - }, - ["apr"] = { - ["value"] = "4", - }, - ["may"] = { - ["value"] = "5", - }, - ["jun"] = { - ["value"] = "6", - }, - ["jul"] = { - ["value"] = "7", - }, - ["aug"] = { - ["value"] = "8", - }, - ["sep"] = { - ["value"] = "9", - }, - ["oct"] = { - ["value"] = "10", - }, - ["nov"] = { - ["value"] = "11", - }, - ["dec"] = { - ["value"] = "12", - }, - ["acmcs"] = { - ["value"] = "ACM Computing Surveys", - }, - ["acta"] = { - ["value"] = "Acta Informatica", - }, - ["cacm"] = { - ["value"] = "Communications of the ACM", - }, - ["ibmjrd"] = { - ["value"] = "IBM Journal of Research and Development", - }, - ["ibmsj"] = { - ["value"] = "IBM Systems Journal", - }, - ["ieeese"] = { - ["value"] = "IEEE Transactions on Software Engineering", - }, - ["ieeetc"] = { - ["value"] = "IEEE Transactions on Computers", - }, - ["ieeetcad"] = { - ["value"] = "IEEE Transactions on Computer-Aided Design of Integrated Circuits", - }, - ["ipl"] = { - ["value"] = "Information Processing Letters", - }, - ["jacm"] = { - ["value"] = "Journal of the ACM", - }, - ["jcss"] = { - ["value"] = "Journal of Computer and System Sciences", - }, - ["scp"] = { - ["value"] = "Science of Computer Programming", - }, - ["sicomp"] = { - ["value"] = "SIAM Journal on Computing", - }, - ["tocs"] = { - ["value"] = "ACM Transactions on Computer Systems", - }, - ["tods"] = { - ["value"] = "ACM Transactions on Database Systems", - }, - ["tog"] = { - ["value"] = "ACM Transactions on Graphics", - }, - ["toms"] = { - ["value"] = "ACM Transactions on Mathematical Software", - }, - ["toois"] = { - ["value"] = "ACM Transactions on Office Information Systems", - }, - ["toplas"] = { - ["value"] = "ACM Transactions on Programming Languages and Systems", - }, - ["tcs"] = { - ["value"] = "Theoretical Computer Science", - }, - }, -}
\ No newline at end of file diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-bib.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bib.lua deleted file mode 100644 index 7e24b1a6a54..00000000000 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-bib.lua +++ /dev/null @@ -1,522 +0,0 @@ --- --- Copyright (c) 2021-2022 Zeping Lee --- Released under the MIT license. --- Repository: https://github.com/zepinglee/citeproc-lua --- - ---[[ - A naive implementation of a Bib(La)TeX dateabase (.bib) parser - References: - - http://mirrors.ctan.org/biblio/bibtex/base/btxdoc.pdf - - http://mirrors.ctan.org/info/bibtex/tamethebeast/ttb_en.pdf - - https://github.com/brechtm/citeproc-py/blob/master/citeproc/source/bibtex/bibparse.py - - http://maverick.inria.fr/~Xavier.Decoret/resources/xdkbibtex/bibtex_summary.html - - https://github.com/pcooksey/bibtex-js/blob/master/src/bibtex_js.js ---]] - -local bib = {} - -local unicode = require("unicode") -bib.bib_data = require("citeproc-bib-data") - -local util = require("citeproc-util") - - -function bib.parse(contents) - local items = {} - for item_contents in string.gmatch(contents, "(@%w+%b{})") do - local item = bib.parse_item(item_contents) - table.insert(items, item) - end - return items -end - -function bib.parse_item(contents) - contents = string.gsub(contents, "%s*\r?\n%s*", " ") - local bib_type, id - bib_type, id, contents = string.match(contents, "^@(%w+){([^%s,]+),%s*(.*)}$") - if not id then - return nil - end - - local item = {id = id, ["citation-key"] = id} - - bib_type = string.lower(bib_type) - local type_data = bib.bib_data.types[bib_type] - if type_data and type_data.csl then - item.type = type_data.csl - else - item.type = "document" - end - - local bib_fields = bib.parse_fields(contents) - -- util.debug(bib_fields) - - for bib_field, value in pairs(bib_fields) do - local csl_field, csl_value = bib.convert_field(bib_field, value) - - if csl_field and not item[csl_field] then - item[csl_field] = csl_value - end - end - - bib.process_special_fields(item, bib_fields) - - return item -end - -function bib.parse_fields(contents) - local fields = {} - local field_patterns = { - "^([^,}%s]+)%s*=%s*(%b{}),?%s*(.-)$", - '^([^,}%s]+)%s*=%s*"([^"]*)",?%s*(.-)$', - "^([^,}%s]+)%s*=%s*(%w+),?%s*(.-)$", - } - - while #contents > 0 do - local field, value, rest - -- This pattern may fail in the case of `title = {foo\}bar}`. - for pattern_index, pattern in ipairs(field_patterns) do - field, value, rest = string.match(contents, pattern) - if value then - field = string.lower(field) - if pattern_index == 1 then - -- Strip braces "{}" - value = string.sub(value, 2, -2) - elseif pattern_index == 3 then - if not string.match(value, "^%d+$") then - local string_name = value - local macro = bib.bib_data.macros[string_name] - if macro then - value = macro.value - else - util.warning(string.format('String name "%s" is undefined', string_name)) - end - end - end - fields[field] = value - break - end - end - if value then - contents = rest - else - break - end - end - return fields -end - -function bib.convert_field(bib_field, value) - local field_data = bib.bib_data.fields[bib_field] - if not field_data then - return nil, nil - end - local csl_field = field_data.csl - if not csl_field then - return nil, nil - end - - value = bib.unescape(bib_field, value) - - local field_type = field_data.type - if field_type == "name" then - value = bib.parse_names(value) - elseif field_type == "date" then - value = bib.parse_date(value) - end - - if bib_field == "title" or bib_field == "booktitle" then - -- TODO: check if the original title is in sentence case - value = bib.convert_sentence_case(value) - end - - if bib_field == "volume" or bib_field == "pages" then - value = string.gsub(value, util.unicode["en dash"], "-") - end - - return csl_field, value -end - -function bib.unescape(field, str) - str = string.gsub(str, "%-%-%-", util.unicode["em dash"]) - str = string.gsub(str, "%-%-", util.unicode["en dash"]) - str = string.gsub(str, "``", util.unicode["left double quotation mark"]) - str = string.gsub(str, "''", util.unicode["right double quotation mark"]) - str = string.gsub(str, "`", util.unicode["left single quotation mark"]) - str = string.gsub(str, "'", util.unicode["right single quotation mark"]) - -- TODO: unicode chars like \"{o} - str = string.gsub(str, "\\#", "#") - str = string.gsub(str, "\\%$", "$") - str = string.gsub(str, "\\%%", "%") - str = string.gsub(str, "\\&", "&") - str = string.gsub(str, "\\{", "{") - str = string.gsub(str, "\\}", "}") - str = string.gsub(str, "\\_", "_") - if field ~= "url" then - str = string.gsub(str, "~", util.unicode["no-break space"]) - end - str = string.gsub(str, "\\quad%s+", util.unicode["em space"]) - return str -end - -function bib.convert_sentence_case(str) - local res = "" - local to_lower = false - local brace_level = 0 - for _, code_point in utf8.codes(str) do - local char = utf8.char(code_point) - if to_lower and brace_level == 0 then - char = unicode.utf8.lower(char) - end - if string.match(char, "%S") then - to_lower = true - end - if char == "{" then - brace_level = brace_level + 1 - char = "" - elseif char == "}" then - brace_level = brace_level - 1 - char = "" - elseif char == ":" then - to_lower = false - end - res = res .. char - end - return res -end - -function bib.parse_names(str) - -- "{International Federation of Library Association and Institutions}" - local names = {} - local brace_level = 0 - local name = "" - local last_word = "" - for i = 1, #str do - local char = string.sub(str, i, i) - if char == " " then - if brace_level == 0 and last_word == "and" then - table.insert(names, name) - name = "" - else - if name ~= "" then - name = name .. " " - end - name = name .. last_word - end - last_word = "" - else - last_word = last_word .. char - if char == "{" then - brace_level = brace_level + 1 - elseif char == "}" then - brace_level = brace_level - 1 - end - end - end - - if name ~= "" then - name = name .. " " - end - name = name .. last_word - table.insert(names, name) - - for i, name in ipairs(names) do - names[i] = bib.parse_single_name(name) - end - return names -end - -function bib.parse_single_name(str) - local literal = string.match(str, "^{(.*)}$") - if literal then - return { - literal = literal, - } - end - - local name_parts = util.split(str, ",%s*") - if #name_parts > 1 then - return bib.parse_revesed_name(name_parts) - else - return bib.parse_non_revesed_name(str) - end -end - -function bib.parse_revesed_name(name_parts) - local name = {} - local von, last, jr, first - if #name_parts == 2 then - first = name_parts[2] - elseif #name_parts >= 3 then - jr = name_parts[2] - first = name_parts[3] - end - if first and first ~= "" then - name.given = first - end - if jr and jr ~= "" then - name.suffix = jr - end - - last = name_parts[1] - local words = util.split(last) - local index = #words - 1 - while index > 0 and string.match(words[index], "^%L") do - index = index - 1 - end - name.family = util.concat(util.slice(words, index + 1), " ") - if index >= 1 then - von = util.concat(util.slice(words, 1, index), " ") - name["non-dropping-particle"] = von - end - return name -end - -function bib.parse_non_revesed_name(str) - local name = {} - local words = util.split(str) - - local index = 1 - -- TODO: case determination for pseudo-characters (e.g., "\bb{BB}") - while index < #words and string.match(words[index], "^%L") do - index = index + 1 - end - if index > 1 then - name.given = util.concat(util.slice(words, 1, index - 1), " ") - end - - local particle_start_index = index - index = #words - 1 - while index >= particle_start_index and string.match(words[index], "^%L") do - index = index - 1 - end - if index >= particle_start_index then - local particles = util.slice(words, particle_start_index, index) - -- TODO: distiguish dropping and non-dropping particles - name["non-dropping-particle"] = util.concat(particles, " ") - end - name.family = util.concat(util.slice(words, index + 1), " ") - - return name -end - -function bib.parse_date(str) - local date_range = util.split(str, "/") - if #date_range == 1 then - date_range = util.split(str, util.unicode["en dash"]) - end - - local literal = { literal = str } - - if #date_range > 2 then - return literal - end - - local date = {} - date["date-parts"] = {} - for _, date_part in ipairs(date_range) do - local date_ = bib.parse_single_date(date_part) - if not date_ then - return literal - end - table.insert(date["date-parts"], date_) - end - return date -end - -function bib.parse_single_date(str) - local date = {} - for _, date_part in ipairs(util.split(str, "%-")) do - if not string.match(date_part, "^%d+$") then - return nil - end - table.insert(date, tonumber(date_part)) - end - return date -end - - -function bib.process_special_fields(item, bib_fields) - -- Default entry type `document` - if item.type == "document" then - if item.URL then - item.type = "webpage" - else - item.type = "article" - end - end - - -- event-title: for compatibility with CSL v1.0.1 and earlier versions - if item["event-title"] then - item.event = item["event-title"] - end - - -- issued date - if bib_fields.year and not item.issued then - item.issued = bib.parse_date(bib_fields.year) - end - local month = bib_fields.month - if month and string.match(month, "^%d+$") then - if item.issued and item.issued["date-parts"] and - item.issued["date-parts"][1] and - item.issued["date-parts"][1][2] == nil then - item.issued["date-parts"][1][2] = tonumber(month) - end - end - - -- language: convert `babel` language to ISO 639-1 language code - if not item.language and bib_fields.language then - item.language = bib_fields.language - end - if item.language then - local language_code = bib.babel_locale_mapping[item.language] - if language_code then - item.language = language_code - end - end - -- if not item.language then - -- if util.has_cjk_char(item.title) then - -- item.language = "zh" - -- end - -- end - - -- number - if item.number then - if item.type == "article-journal" or item.type == "article-magazine" or item.type == "article-newspaper" or item.type == "periodical" then - if not item.issue then - item.issue = item.number - item.number = nil - end - elseif item["collection-title"] and not item["collection-number"] then - item["collection-number"] = item.number - item.number = nil - end - end - - -- PMID - if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then - item.PMID = bib_fields.eprint - end - -end - - -bib.babel_locale_mapping = { - acadian = "fr-CA", - american = "en-US", - australian = "en-AU", - afrikaans = "af-ZA", - albanian = "sq-AL", - amharic = "am-ET", - arabic = "ar", - armenian = "hy-AM", - asturian = "ast-ES", - austrian = "de-AT", - bahasa = "id-ID", - bahasai = "id-ID", - bahasam = "id-ID", - basque = "eu-ES", - bengali = "bn-BD", - bgreek = "el-GR", - brazil = "pt-BR", - brazilian = "pt-BR", - breton = "br-FR", - british = "en-GB", - bulgarian = "bg-BG", - canadian = "en-CA", - canadien = "fr-CA", - catalan = "ca-AD", - coptic = "cop", - croatian = "hr-HR", - czech = "cs-CZ", - danish = "da-DK", - divehi = "dv-MV", - dutch = "nl-NL", - english = "en-US", - esperanto = "eo-001", - estonian = "et-EE", - ethiopia = "am-ET", - farsi = "fa-IR", - finnish = "fi-FI", - francais = "fr-FR", - french = "fr-FR", - frenchle = "fr-FR", - friulan = "fur-IT", - galician = "gl-ES", - german = "de-DE", - germanb = "de-DE", - greek = "el-GR", - hebrew = "he-IL", - hindi = "hi-IN", - ibygreek = "el-CY", - icelandic = "is-IS", - indon = "id-ID", - indonesia = "id-ID", - interlingua = "ia-FR", - irish = "ga-IE", - italian = "it-IT", - japanese = "ja-JP", - kannada = "kn-IN", - lao = "lo-LA", - latin = "la-Latn", - latvian = "lv-LV", - lithuanian = "lt-LT", - lowersorbian = "dsb-DE", - lsorbian = "dsb-DE", - magyar = "hu-HU", - malay = "id-ID", - malayalam = "ml-IN", - marathi = "mr-IN", - meyalu = "id-ID", - mongolian = "mn-Cyrl", - naustrian = "de-AT", - newzealand = "en-NZ", - ngerman = "de-DE", - nko = "ha-NG", - norsk = "nb-NO", - norwegian = "nn-NO", - nynorsk = "nn-NO", - occitan = "oc-FR", - piedmontese = "pms-IT", - pinyin = "pny", - polish = "pl-PL", - polutonikogreek = "el-GR", - portuges = "pt-PT", - portuguese = "pt-PT", - romanian = "ro-RO", - romansh = "rm-CH", - russian = "ru-RU", - samin = "se-NO", - sanskrit = "sa-IN", - scottish = "gd-GB", - serbian = "sr-Latn", - serbianc = "sr-Cyrl", - slovak = "sk-SK", - slovene = "sl-SI", - slovenian = "sl-SI", - spanish = "es-ES", - swedish = "sv-SE", - swiss = "de-CH", - swissgerman = "de-CH", - nswissgerman = "de-CH", - syriac = "syc", - tamil = "ta-IN", - telugu = "te-IN", - thai = "th-TH", - thaicjk = "th-TH", - tibetan = "bo-CN", - turkish = "tr-TR", - turkmen = "tk-TM", - ukrainian = "uk-UA", - urdu = "ur-IN", - UKenglish = "en-UK", - uppersorbian = "hsb-DE", - USenglish = "en-US", - usorbian = "hsb-DE", - vietnamese = "vi-VN", - welsh = "cy-GB", -} - - -return bib diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-data.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-data.lua new file mode 100644 index 00000000000..c7b2ff13063 --- /dev/null +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-data.lua @@ -0,0 +1,2570 @@ +-- This file is generated from citeproc-bibtex-data.json by tools/update-bibtex-data.py + +return { + description = "BibTeX CSL mapping", + types = { + archival = { + csl = "collection", + }, + archive = { + csl = "collection", + }, + article = { + csl = "article-journal", + }, + artifactdataset = { + csl = "dataset", + }, + artifactsoftware = { + csl = "software", + }, + artwork = { + csl = "graphic", + }, + atlas = { + csl = nil, + }, + audio = { + csl = "song", + }, + bachelor = { + csl = "thesis", + }, + bibnote = { + csl = nil, + }, + book = { + csl = "book", + }, + bookinbook = { + csl = "chapter", + }, + booklet = { + csl = "pamphlet", + }, + brochure = { + csl = "pamphlet", + }, + cconference = { + csl = nil, + }, + collection = { + csl = "book", + }, + comment = { + csl = nil, + }, + commentary = { + csl = "book", + }, + commented = { + csl = nil, + }, + conference = { + csl = "paper-conference", + }, + ctan = { + csl = "software", + }, + customa = { + csl = nil, + }, + customb = { + csl = nil, + }, + customc = { + csl = nil, + }, + customd = { + csl = nil, + }, + custome = { + csl = nil, + }, + customf = { + csl = nil, + }, + database = { + csl = "dataset", + }, + dataset = { + csl = "dataset", + }, + dictionary = { + csl = "book", + }, + docthesis = { + csl = "thesis", + }, + electronic = { + csl = "webpage", + }, + eulegislation = { + csl = "legislation", + }, + footnote = { + csl = nil, + }, + game = { + csl = "software", + }, + govpub = { + csl = "regulation", + }, + habthesis = { + csl = "thesis", + }, + heading = { + csl = nil, + }, + hidden = { + csl = nil, + }, + image = { + csl = "graphic", + }, + inbook = { + csl = "chapter", + }, + incollection = { + csl = "chapter", + }, + inloosecollection = { + csl = "chapter", + }, + inpress = { + csl = "article", + }, + inproceedings = { + csl = "paper-conference", + }, + inreference = { + csl = "entry", + }, + inserialcollection = { + csl = nil, + }, + internet = { + csl = "webpage", + }, + journalpart = { + csl = nil, + }, + journals = { + csl = "periodical", + }, + jurisdiction = { + csl = nil, + }, + jurthesis = { + csl = "thesis", + }, + legal = { + csl = "treaty", + }, + legislation = { + csl = "legislation", + }, + letter = { + csl = "personal_communication", + }, + lexicon = { + csl = "book", + }, + majorthesis = { + csl = "thesis", + }, + manual = { + csl = "report", + }, + map = { + csl = "map", + }, + mastersthesis = { + csl = "thesis", + }, + masterthesis = { + csl = "thesis", + }, + minorthesis = { + csl = "thesis", + }, + misc = { + csl = "document", + }, + monograph = { + csl = "book", + }, + monography = { + csl = "book", + }, + movie = { + csl = "motion_picture", + }, + music = { + csl = "song", + }, + mvbook = { + csl = "book", + }, + mvcollection = { + csl = "book", + }, + mvproceedings = { + csl = "book", + }, + mvreference = { + csl = "book", + }, + news = { + csl = "article-newspaper", + }, + newspaper = { + csl = "article-newspaper", + }, + online = { + csl = "webpage", + }, + other = { + csl = nil, + }, + patent = { + csl = "patent", + }, + performance = { + csl = "performance", + }, + periodical = { + csl = "periodical", + }, + phdthesis = { + csl = "thesis", + }, + preamble = { + csl = nil, + }, + preprint = { + csl = "article", + }, + presentation = { + csl = "speech", + }, + proceedings = { + csl = "book", + }, + program = { + csl = "software", + }, + reference = { + csl = "book", + }, + report = { + csl = "report", + }, + repository = { + csl = nil, + }, + review = { + csl = "review", + }, + set = { + csl = nil, + }, + setup = { + csl = nil, + }, + software = { + csl = "software", + }, + standard = { + csl = "standard", + }, + string = { + csl = nil, + }, + suppbook = { + csl = "chapter", + }, + suppcollection = { + csl = "chapter", + }, + suppperiodical = { + csl = "article", + }, + techreport = { + csl = "report", + }, + techstandard = { + csl = "standard", + }, + thesis = { + csl = "thesis", + }, + uklegislation = { + csl = "legislation", + }, + unpublished = { + csl = "manuscript", + }, + video = { + csl = "motion_picture", + }, + webpage = { + csl = "webpage", + }, + website = { + csl = nil, + }, + www = { + csl = "webpage", + }, + xdata = { + csl = nil, + }, + }, + fields = { + abstract = { + csl = "abstract", + type = "literal", + }, + account = { + csl = nil, + }, + acronym = { + csl = nil, + }, + add = { + csl = nil, + }, + add1 = { + csl = nil, + }, + addendum = { + csl = nil, + type = "literal", + }, + address = { + csl = "publisher-place", + type = "literal", + }, + adsurl = { + csl = nil, + }, + advisor = { + csl = nil, + }, + afterword = { + csl = nil, + type = "name", + }, + annotate = { + csl = "note", + }, + annotation = { + csl = "note", + type = "literal", + }, + annotator = { + csl = nil, + type = "name", + }, + annote = { + csl = "note", + type = "literal", + }, + annotelanguage = { + csl = nil, + }, + applicant = { + csl = nil, + }, + archive = { + csl = "archive", + }, + archiveprefix = { + csl = "archive", + type = "literal", + }, + archname = { + csl = "archive", + }, + articleno = { + csl = nil, + }, + arxiv = { + csl = nil, + }, + assignee = { + csl = nil, + }, + author = { + csl = "author", + type = "name", + }, + authorcountry = { + csl = nil, + }, + authorfa = { + csl = nil, + }, + authortype = { + csl = nil, + type = "key", + }, + bibsource = { + csl = nil, + }, + biburl = { + csl = nil, + }, + binding = { + csl = nil, + }, + birthday = { + csl = nil, + }, + birthyear = { + csl = nil, + }, + bookaddress = { + csl = nil, + }, + bookauthor = { + csl = "container-author", + type = "name", + }, + booklanguage = { + csl = nil, + }, + bookpages = { + csl = nil, + }, + bookpagination = { + csl = nil, + type = "key", + }, + booksubtitle = { + csl = nil, + type = "literal", + }, + booktitle = { + csl = "container-title", + type = "literal", + }, + booktitleaddon = { + csl = nil, + type = "literal", + }, + caption = { + csl = nil, + }, + caption1 = { + csl = nil, + }, + cartographer = { + csl = nil, + }, + casenumber = { + csl = nil, + }, + category = { + csl = nil, + }, + cellular = { + csl = nil, + }, + chair = { + csl = nil, + }, + chapter = { + csl = "chapter-number", + type = "literal", + }, + citedate = { + csl = nil, + }, + city = { + csl = nil, + }, + code = { + csl = nil, + }, + coden = { + csl = nil, + }, + collaboration = { + csl = nil, + }, + collator = { + csl = nil, + }, + commentator = { + csl = nil, + type = "name", + }, + commit = { + csl = nil, + }, + compiler = { + csl = nil, + }, + condition = { + csl = nil, + }, + ["conference-location"] = { + csl = nil, + }, + ["conference-number"] = { + csl = nil, + }, + ["conference-year"] = { + csl = nil, + }, + copy = { + csl = nil, + }, + country = { + csl = nil, + }, + credits = { + csl = nil, + }, + crossref = { + csl = nil, + type = "entrykey", + }, + ["ctrl-article-title"] = { + csl = nil, + }, + ["ctrl-chapter-title"] = { + csl = nil, + }, + ["ctrl-doi"] = { + csl = nil, + }, + ["ctrl-etal-firstonly"] = { + csl = nil, + }, + ["ctrl-etal-number"] = { + csl = nil, + }, + ["ctrl-link-doi"] = { + csl = nil, + }, + ["ctrl-use-doi-all"] = { + csl = nil, + }, + ["ctrl-use-title"] = { + csl = nil, + }, + dataset = { + csl = nil, + }, + date = { + csl = "issued", + type = "date", + }, + day = { + csl = nil, + }, + dayfiled = { + csl = nil, + }, + definition = { + csl = nil, + }, + department = { + csl = nil, + }, + description = { + csl = nil, + }, + designator = { + csl = nil, + }, + dimensions = { + csl = nil, + }, + dissyear = { + csl = nil, + }, + doi = { + csl = "DOI", + type = "verbatim", + }, + dticnumber = { + csl = nil, + }, + dummy = { + csl = nil, + }, + edition = { + csl = "edition", + type = "literal", + }, + editor = { + csl = "editor", + type = "name", + }, + editora = { + csl = nil, + type = "name", + }, + editoratype = { + csl = nil, + type = "key", + }, + editorb = { + csl = nil, + type = "name", + }, + editorbtype = { + csl = nil, + type = "key", + }, + editorc = { + csl = nil, + type = "name", + }, + editorctype = { + csl = nil, + type = "key", + }, + editortype = { + csl = nil, + type = "key", + }, + eid = { + csl = nil, + type = "literal", + }, + email = { + csl = nil, + }, + endnumber = { + csl = nil, + }, + endvolume = { + csl = nil, + }, + endyear = { + csl = nil, + }, + englishtitle = { + csl = nil, + }, + entryset = { + csl = nil, + type = "entrykey", + }, + entrysubtype = { + csl = nil, + type = "literal", + }, + epilog = { + csl = nil, + }, + eprint = { + csl = nil, + type = "verbatim", + }, + eprintclass = { + csl = nil, + type = "literal", + }, + eprints = { + csl = nil, + }, + eprinttype = { + csl = "archive", + type = "literal", + }, + erratumeid = { + csl = nil, + }, + erratumgermanpages = { + csl = nil, + }, + erratumnumpages = { + csl = nil, + }, + erratumpages = { + csl = nil, + }, + erratumvolume = { + csl = nil, + }, + erratumyear = { + csl = nil, + }, + eventdate = { + csl = "event-date", + type = "date", + }, + eventtitle = { + csl = "event-title", + type = "literal", + }, + eventtitleaddon = { + csl = nil, + type = "literal", + }, + eventyear = { + csl = nil, + }, + execute = { + csl = nil, + type = "code", + }, + faddress = { + csl = nil, + }, + fakeset = { + csl = nil, + }, + fax = { + csl = nil, + }, + file = { + csl = nil, + type = "verbatim", + }, + firstkey = { + csl = nil, + }, + fjournal = { + csl = nil, + }, + flanguage = { + csl = nil, + }, + font = { + csl = nil, + }, + foreword = { + csl = nil, + type = "name", + }, + founder = { + csl = nil, + }, + fpublisher = { + csl = nil, + }, + ftitle = { + csl = nil, + }, + furtherresp = { + csl = nil, + }, + fyear = { + csl = nil, + }, + gender = { + csl = nil, + type = "literal", + }, + germanpages = { + csl = nil, + }, + group = { + csl = nil, + }, + heading = { + csl = nil, + }, + hereafter = { + csl = nil, + }, + holder = { + csl = nil, + type = "name", + }, + howcited = { + csl = nil, + }, + howpublished = { + csl = nil, + type = "literal", + }, + hyphenation = { + csl = "language", + type = "literal", + }, + ids = { + csl = nil, + type = "entrykey", + }, + illustrated = { + csl = nil, + }, + illustrations = { + csl = nil, + }, + illustrator = { + csl = nil, + }, + indexsorttitle = { + csl = nil, + type = "literal", + }, + indextitle = { + csl = nil, + type = "literal", + }, + institution = { + csl = "publisher", + type = "literal", + }, + introduction = { + csl = nil, + type = "name", + }, + intype = { + csl = nil, + }, + inventor = { + csl = nil, + }, + ipc = { + csl = nil, + }, + isan = { + csl = nil, + type = "literal", + }, + isbn = { + csl = "ISBN", + type = "literal", + }, + ismn = { + csl = nil, + type = "literal", + }, + ["iso-abbreviation"] = { + csl = nil, + }, + ["iso-author-punctuation"] = { + csl = nil, + }, + ["iso-date-place"] = { + csl = nil, + }, + isrn = { + csl = nil, + type = "literal", + }, + issn = { + csl = "ISSN", + type = "literal", + }, + issue = { + csl = "issue", + type = "literal", + }, + issuesubtitle = { + csl = nil, + type = "literal", + }, + issuetitle = { + csl = nil, + type = "literal", + }, + issuetitleaddon = { + csl = nil, + type = "literal", + }, + iswc = { + csl = nil, + type = "literal", + }, + jfmnumber = { + csl = nil, + }, + journal = { + csl = "container-title", + type = "literal", + }, + journalsubtitle = { + csl = nil, + type = "literal", + }, + journaltie = { + csl = nil, + }, + journaltitle = { + csl = "container-title", + type = "literal", + }, + journaltitleaddon = { + csl = nil, + type = "literal", + }, + juraauthor = { + csl = nil, + }, + juratitle = { + csl = nil, + }, + key = { + csl = nil, + type = "literal", + }, + keywords = { + csl = nil, + type = "keyword", + }, + label = { + csl = nil, + type = "literal", + }, + lang = { + csl = nil, + }, + langid = { + csl = "language", + type = "literal", + }, + langidopts = { + csl = nil, + type = "literal", + }, + language = { + csl = nil, + type = "key", + }, + lastaccessed = { + csl = "accessed", + }, + lastchecked = { + csl = "accessed", + }, + lccn = { + csl = nil, + }, + library = { + csl = nil, + type = "literal", + }, + lista = { + csl = nil, + type = "literal", + }, + listb = { + csl = nil, + type = "literal", + }, + listc = { + csl = nil, + type = "literal", + }, + listd = { + csl = nil, + type = "literal", + }, + liste = { + csl = nil, + type = "literal", + }, + listf = { + csl = nil, + type = "literal", + }, + littype = { + csl = nil, + }, + location = { + csl = "publisher-place", + type = "literal", + }, + madadurltest = { + csl = nil, + }, + main = { + csl = nil, + }, + main1 = { + csl = nil, + }, + mainsubtitle = { + csl = nil, + type = "literal", + }, + maintitle = { + csl = nil, + type = "literal", + }, + maintitleaddon = { + csl = nil, + type = "literal", + }, + majorcode = { + csl = nil, + }, + marginnote = { + csl = nil, + }, + mark = { + csl = nil, + }, + ["max.best.papers"] = { + csl = nil, + }, + mcitetail = { + csl = nil, + }, + media = { + csl = "medium", + }, + medium = { + csl = "medium", + }, + meeting = { + csl = nil, + }, + misctitle = { + csl = nil, + }, + miscyear = { + csl = nil, + }, + mobile = { + csl = nil, + }, + modifydate = { + csl = nil, + }, + month = { + csl = nil, + type = "literal", + }, + monthfiled = { + csl = nil, + }, + mrnumber = { + csl = nil, + }, + name = { + csl = nil, + }, + namea = { + csl = nil, + type = "name", + }, + nameaddon = { + csl = nil, + type = "literal", + }, + nameatype = { + csl = nil, + type = "key", + }, + nameb = { + csl = nil, + type = "name", + }, + namebtype = { + csl = nil, + type = "key", + }, + namec = { + csl = nil, + type = "name", + }, + namectype = { + csl = nil, + type = "key", + }, + nationality = { + csl = nil, + }, + nbirthday = { + csl = nil, + }, + newpage = { + csl = nil, + }, + newspaper = { + csl = "container-title", + }, + nickname = { + csl = nil, + }, + nihms = { + csl = nil, + }, + noed = { + csl = nil, + }, + nolink = { + csl = nil, + }, + normal = { + csl = nil, + }, + normalauthor = { + csl = nil, + }, + normaleditor = { + csl = nil, + }, + note = { + csl = "note", + type = "literal", + }, + nowarning = { + csl = nil, + }, + number = { + csl = "number", + type = "literal", + }, + numpages = { + csl = nil, + }, + oaddress = { + csl = nil, + }, + options = { + csl = nil, + type = "option", + }, + opublisher = { + csl = nil, + }, + ["org-short"] = { + csl = nil, + }, + organization = { + csl = "publisher", + type = "literal", + }, + origdate = { + csl = "original-date", + type = "date", + }, + originaladdress = { + csl = "original-publisher-place", + }, + originalbooktitle = { + csl = nil, + }, + originaledition = { + csl = nil, + }, + originaleditor = { + csl = nil, + }, + originaljournal = { + csl = nil, + }, + originalnumber = { + csl = nil, + }, + originalpages = { + csl = nil, + }, + originalpublisher = { + csl = "original-publisher", + }, + originalvolume = { + csl = nil, + }, + originalyear = { + csl = "original-date", + }, + origlanguage = { + csl = nil, + type = "key", + }, + origlocation = { + csl = "original-publisher-place", + type = "literal", + }, + origpublisher = { + csl = "original-publisher", + type = "literal", + }, + origtitle = { + csl = "original-title", + type = "literal", + }, + oyear = { + csl = nil, + }, + pagename = { + csl = nil, + }, + pages = { + csl = "page", + type = "range", + }, + pagetotal = { + csl = "number-of-pages", + type = "literal", + }, + pagination = { + csl = nil, + type = "key", + }, + paper = { + csl = nil, + }, + part = { + csl = "part", + type = "literal", + }, + patentid = { + csl = nil, + }, + pdf = { + csl = nil, + type = "verbatim", + }, + phone = { + csl = nil, + }, + pid = { + csl = nil, + }, + pii = { + csl = nil, + }, + pmcid = { + csl = "PMCID", + }, + prebibitem = { + csl = nil, + }, + preface = { + csl = nil, + }, + preprint = { + csl = nil, + }, + presort = { + csl = nil, + type = "literal", + }, + price = { + csl = nil, + }, + primaryclass = { + csl = nil, + type = "literal", + }, + printing = { + csl = nil, + }, + prioritycountry = { + csl = nil, + }, + prioritydate = { + csl = nil, + }, + prioritynumber = { + csl = nil, + }, + pseudonym = { + csl = nil, + }, + publication = { + csl = nil, + }, + publicationdate = { + csl = nil, + }, + publisher = { + csl = "publisher", + type = "literal", + }, + pubmed = { + csl = "PMID", + }, + pubstate = { + csl = nil, + type = "key", + }, + related = { + csl = nil, + type = "entrykey", + }, + relatedoptions = { + csl = nil, + type = "option", + }, + relatedstring = { + csl = nil, + type = "literal", + }, + relatedtype = { + csl = nil, + type = "literal", + }, + ["reprinted-from"] = { + csl = nil, + }, + ["reprinted-text"] = { + csl = nil, + }, + reprinttitle = { + csl = nil, + type = "literal", + }, + requestdate = { + csl = nil, + }, + requestnumber = { + csl = nil, + }, + responsible = { + csl = nil, + }, + review = { + csl = nil, + }, + revision = { + csl = nil, + }, + school = { + csl = "publisher", + type = "literal", + }, + score = { + csl = nil, + }, + section = { + csl = nil, + }, + series = { + csl = "collection-title", + type = "literal", + }, + seriesedition = { + csl = nil, + }, + short = { + csl = nil, + }, + shortarchive = { + csl = nil, + }, + shortauthor = { + csl = nil, + type = "name", + }, + shorteditor = { + csl = nil, + type = "name", + }, + shorthand = { + csl = nil, + type = "literal", + }, + shorthandintro = { + csl = nil, + type = "literal", + }, + shortjournal = { + csl = "container-title-short", + type = "literal", + }, + shortseries = { + csl = nil, + type = "literal", + }, + shortsubarchive = { + csl = nil, + }, + shorttitle = { + csl = "title-short", + type = "literal", + }, + shorturl = { + csl = nil, + }, + sig1 = { + csl = nil, + }, + sig2 = { + csl = nil, + }, + sig3 = { + csl = nil, + }, + sig4 = { + csl = nil, + }, + size = { + csl = nil, + }, + slaccitation = { + csl = nil, + }, + ["sort-short"] = { + csl = nil, + }, + ["sort-word"] = { + csl = nil, + }, + sortas = { + csl = nil, + }, + sortkey = { + csl = nil, + type = "literal", + }, + sortname = { + csl = nil, + type = "name", + }, + sortshorthand = { + csl = nil, + type = "literal", + }, + sorttitle = { + csl = nil, + type = "literal", + }, + sortyear = { + csl = nil, + type = "integer", + }, + source1 = { + csl = nil, + }, + specialitycode = { + csl = nil, + }, + ssedition = { + csl = nil, + }, + standard = { + csl = nil, + }, + startnumber = { + csl = nil, + }, + startvolume = { + csl = nil, + }, + startyear = { + csl = nil, + }, + state = { + csl = nil, + }, + status = { + csl = nil, + }, + stdcode = { + csl = nil, + }, + stitle = { + csl = nil, + }, + street = { + csl = nil, + }, + subarchive = { + csl = nil, + }, + subtitle = { + csl = nil, + type = "literal", + }, + symposium = { + csl = nil, + }, + text = { + csl = nil, + }, + timestamp = { + csl = nil, + }, + title = { + csl = "title", + type = "literal", + }, + titleaddon = { + csl = nil, + type = "literal", + }, + titlenote = { + csl = nil, + }, + totalpages = { + csl = nil, + }, + transissue = { + csl = nil, + }, + transjournal = { + csl = nil, + }, + translation = { + csl = nil, + }, + translator = { + csl = "translator", + type = "name", + }, + transnumber = { + csl = nil, + }, + transpages = { + csl = nil, + }, + transsection = { + csl = nil, + }, + transvolume = { + csl = nil, + }, + transyear = { + csl = nil, + }, + type = { + csl = "genre", + type = "key", + }, + typeoflit = { + csl = nil, + }, + umfnumber = { + csl = nil, + }, + updated = { + csl = nil, + }, + url = { + csl = "URL", + type = "uri", + }, + urlaccessdate = { + csl = "accessed", + }, + urldate = { + csl = "accessed", + type = "date", + }, + urlnewline = { + csl = nil, + }, + urltype = { + csl = nil, + }, + urlyear = { + csl = nil, + }, + urn = { + csl = nil, + }, + usera = { + csl = nil, + type = "literal", + }, + userb = { + csl = nil, + type = "literal", + }, + userc = { + csl = nil, + type = "literal", + }, + userd = { + csl = nil, + type = "literal", + }, + usere = { + csl = nil, + type = "literal", + }, + userf = { + csl = nil, + type = "literal", + }, + value = { + csl = nil, + }, + venue = { + csl = "event-place", + type = "literal", + }, + verba = { + csl = nil, + type = "verbatim", + }, + verbb = { + csl = nil, + type = "verbatim", + }, + verbc = { + csl = nil, + type = "verbatim", + }, + version = { + csl = "version", + type = "literal", + }, + versiontype = { + csl = nil, + }, + volformat = { + csl = nil, + }, + volume = { + csl = "volume", + type = "integer", + }, + volumes = { + csl = "number-of-volumes", + type = "integer", + }, + volumetitle = { + csl = nil, + }, + word = { + csl = nil, + }, + xdata = { + csl = nil, + type = "entrykey", + }, + xid = { + csl = nil, + }, + xref = { + csl = nil, + type = "entrykey", + }, + year = { + csl = nil, + type = "date", + }, + ["year-presented"] = { + csl = nil, + }, + yearcomp = { + csl = nil, + }, + yearfiled = { + csl = nil, + }, + zblnumber = { + csl = nil, + }, + zip = { + csl = nil, + }, + }, + macros = { + jan = { + value = "1", + }, + feb = { + value = "2", + }, + mar = { + value = "3", + }, + apr = { + value = "4", + }, + may = { + value = "5", + }, + jun = { + value = "6", + }, + jul = { + value = "7", + }, + aug = { + value = "8", + }, + sep = { + value = "9", + }, + oct = { + value = "10", + }, + nov = { + value = "11", + }, + dec = { + value = "12", + }, + acmcs = { + value = "ACM Computing Surveys", + }, + acta = { + value = "Acta Informatica", + }, + cacm = { + value = "Communications of the ACM", + }, + ibmjrd = { + value = "IBM Journal of Research and Development", + }, + ibmsj = { + value = "IBM Systems Journal", + }, + ieeese = { + value = "IEEE Transactions on Software Engineering", + }, + ieeetc = { + value = "IEEE Transactions on Computers", + }, + ieeetcad = { + value = "IEEE Transactions on Computer-Aided Design of Integrated Circuits", + }, + ipl = { + value = "Information Processing Letters", + }, + jacm = { + value = "Journal of the ACM", + }, + jcss = { + value = "Journal of Computer and System Sciences", + }, + scp = { + value = "Science of Computer Programming", + }, + sicomp = { + value = "SIAM Journal on Computing", + }, + tocs = { + value = "ACM Transactions on Computer Systems", + }, + tods = { + value = "ACM Transactions on Database Systems", + }, + tog = { + value = "ACM Transactions on Graphics", + }, + toms = { + value = "ACM Transactions on Mathematical Software", + }, + toois = { + value = "ACM Transactions on Office Information Systems", + }, + toplas = { + value = "ACM Transactions on Programming Languages and Systems", + }, + tcs = { + value = "Theoretical Computer Science", + }, + }, + language_code_map = { + acadian = "fr-CA", + afrikaans = "af-ZA", + albanian = "sq-AL", + american = "en-US", + amharic = "am-ET", + arabic = "ar", + armenian = "hy-AM", + australian = "en-AU", + austrian = "de-AT", + bahasa = "id-ID", + bahasai = "id-ID", + bahasam = "id-ID", + basque = "eu-ES", + bengali = "bn-BD", + bgreek = "el-GR", + brazil = "pt-BR", + brazilian = "pt-BR", + breton = "br-FR", + british = "en-GB", + bulgarian = "bg-BG", + canadian = "en-CA", + canadien = "fr-CA", + catalan = "ca-AD", + chinese = "zh", + croatian = "hr-HR", + czech = "cs-CZ", + danish = "da-DK", + divehi = "dv-MV", + dutch = "nl-NL", + english = "en-US", + esperanto = "eo", + estonian = "et-EE", + ethiopia = "am-ET", + farsi = "fa-IR", + finnish = "fi-FI", + francais = "fr-FR", + french = "fr-FR", + frenchle = "fr-FR", + galician = "gl-ES", + german = "de-DE", + germanb = "de-DE", + greek = "el-GR", + hebrew = "he-IL", + hindi = "hi-IN", + ibygreek = "el-CY", + icelandic = "is-IS", + indon = "id-ID", + indonesia = "id-ID", + interlingua = "ia-FR", + irish = "ga-IE", + italian = "it-IT", + japanese = "ja-JP", + kannada = "kn-IN", + lao = "lo-LA", + latin = "la", + latvian = "lv-LV", + lithuanian = "lt-LT", + magyar = "hu-HU", + malay = "id-ID", + malayalam = "ml-IN", + marathi = "mr-IN", + meyalu = "id-ID", + mongolian = "mn", + naustrian = "de-AT", + newzealand = "en-NZ", + ngerman = "de-DE", + nko = "ha-NG", + norsk = "nb-NO", + norwegian = "nn-NO", + nswissgerman = "de-CH", + nynorsk = "nn-NO", + occitan = "oc-FR", + polish = "pl-PL", + polutonikogreek = "el-GR", + portuges = "pt-PT", + portuguese = "pt-PT", + romanian = "ro-RO", + romansh = "rm-CH", + russian = "ru-RU", + samin = "se-NO", + sanskrit = "sa-IN", + scottish = "gd-GB", + serbian = "sr", + slovak = "sk-SK", + slovene = "sl-SI", + slovenian = "sl-SI", + spanish = "es-ES", + swedish = "sv-SE", + swiss = "de-CH", + swissgerman = "de-CH", + tamil = "ta-IN", + telugu = "te-IN", + thai = "th-TH", + thaicjk = "th-TH", + tibetan = "bo-CN", + turkish = "tr-TR", + turkmen = "tk-TM", + UKenglish = "en-GB", + ukrainian = "uk-UA", + urdu = "ur-IN", + USenglish = "en-US", + vietnamese = "vi-VN", + welsh = "cy-GB", + }, + unicode = { + ["005C"] = "\\textbackslash", + ["00A0"] = "\\nobreakspace", + ["00A1"] = "\\textexclamdown", + ["00A2"] = "\\textcent", + ["00A3"] = "\\textsterling", + ["00A4"] = "\\textcurrency", + ["00A5"] = "\\textyen", + ["00A6"] = "\\textbrokenbar", + ["00A7"] = "\\textsection", + ["00A8"] = "\\textasciidieresis", + ["00A9"] = "\\textcopyright", + ["00AA"] = "\\textordfeminine", + ["00AB"] = "\\guillemetleft", + ["00AC"] = "\\textlnot", + ["00AD"] = "\\-", + ["00AE"] = "\\textregistered", + ["00AF"] = "\\textasciimacron", + ["00B0"] = "\\textdegree", + ["00B1"] = "\\textpm", + ["00B2"] = "\\texttwosuperior", + ["00B3"] = "\\textthreesuperior", + ["00B4"] = "\\textasciiacute", + ["00B5"] = "\\textmu", + ["00B6"] = "\\textparagraph", + ["00B7"] = "\\textperiodcentered", + ["00B8"] = "\\c\\ ", + ["00B9"] = "\\textonesuperior", + ["00BA"] = "\\textordmasculine", + ["00BB"] = "\\guillemetright", + ["00BC"] = "\\textonequarter", + ["00BD"] = "\\textonehalf", + ["00BE"] = "\\textthreequarters", + ["00BF"] = "\\textquestiondown", + ["00C0"] = "\\`A", + ["00C1"] = "\\'A", + ["00C2"] = "\\^A", + ["00C3"] = "\\~A", + ["00C4"] = "\\\"A", + ["00C5"] = "\\r A", + ["00C6"] = "\\AE", + ["00C7"] = "\\c C", + ["00C8"] = "\\`E", + ["00C9"] = "\\'E", + ["00CA"] = "\\^E", + ["00CB"] = "\\\"E", + ["00CC"] = "\\`I", + ["00CD"] = "\\'I", + ["00CE"] = "\\^I", + ["00CF"] = "\\\"I", + ["00D0"] = "\\DH", + ["00D1"] = "\\~N", + ["00D2"] = "\\`O", + ["00D3"] = "\\'O", + ["00D4"] = "\\^O", + ["00D5"] = "\\~O", + ["00D6"] = "\\\"O", + ["00D7"] = "\\texttimes", + ["00D8"] = "\\O", + ["00D9"] = "\\`U", + ["00DA"] = "\\'U", + ["00DB"] = "\\^U", + ["00DC"] = "\\\"U", + ["00DD"] = "\\'Y", + ["00DE"] = "\\TH", + ["00DF"] = "\\ss", + ["00E0"] = "\\`a", + ["00E1"] = "\\'a", + ["00E2"] = "\\^a", + ["00E3"] = "\\~a", + ["00E4"] = "\\\"a", + ["00E5"] = "\\r a", + ["00E6"] = "\\ae", + ["00E7"] = "\\c c", + ["00E8"] = "\\`e", + ["00E9"] = "\\'e", + ["00EA"] = "\\^e", + ["00EB"] = "\\\"e", + ["00EC"] = "\\`\\i", + ["00ED"] = "\\'\\i", + ["00EE"] = "\\^\\i", + ["00EF"] = "\\\"\\i", + ["00F0"] = "\\dh", + ["00F1"] = "\\~n", + ["00F2"] = "\\`o", + ["00F3"] = "\\'o", + ["00F4"] = "\\^o", + ["00F5"] = "\\~o", + ["00F6"] = "\\\"o", + ["00F7"] = "\\textdiv", + ["00F8"] = "\\o", + ["00F9"] = "\\`u", + ["00FA"] = "\\'u", + ["00FB"] = "\\^u", + ["00FC"] = "\\\"u", + ["00FD"] = "\\'y", + ["00FE"] = "\\th", + ["00FF"] = "\\\"y", + ["0100"] = "\\=A", + ["0101"] = "\\=a", + ["0102"] = "\\u A", + ["0103"] = "\\u a", + ["0104"] = "\\k A", + ["0105"] = "\\k a", + ["0106"] = "\\'C", + ["0107"] = "\\'c", + ["0108"] = "\\^C", + ["0109"] = "\\^c", + ["010A"] = "\\.C", + ["010B"] = "\\.c", + ["010C"] = "\\v C", + ["010D"] = "\\v c", + ["010E"] = "\\v D", + ["010F"] = "\\v d", + ["0110"] = "\\DJ", + ["0111"] = "\\dj", + ["0112"] = "\\=E", + ["0113"] = "\\=e", + ["0114"] = "\\u E", + ["0115"] = "\\u e", + ["0116"] = "\\.E", + ["0117"] = "\\.e", + ["0118"] = "\\k E", + ["0119"] = "\\k e", + ["011A"] = "\\v E", + ["011B"] = "\\v e", + ["011C"] = "\\^G", + ["011D"] = "\\^g", + ["011E"] = "\\u G", + ["011F"] = "\\u g", + ["0120"] = "\\.G", + ["0121"] = "\\.g", + ["0122"] = "\\c G", + ["0123"] = "\\c g", + ["0124"] = "\\^H", + ["0125"] = "\\^h", + ["0128"] = "\\~I", + ["0129"] = "\\~\\i", + ["012A"] = "\\=I", + ["012B"] = "\\=\\i", + ["012C"] = "\\u I", + ["012D"] = "\\u\\i", + ["012E"] = "\\k I", + ["012F"] = "\\k i", + ["0130"] = "\\.I", + ["0131"] = "\\i", + ["0132"] = "\\IJ", + ["0133"] = "\\ij", + ["0134"] = "\\^J", + ["0135"] = "\\^\\j", + ["0136"] = "\\c K", + ["0137"] = "\\c k", + ["0139"] = "\\'L", + ["013A"] = "\\'l", + ["013B"] = "\\c L", + ["013C"] = "\\c l", + ["013D"] = "\\v L", + ["013E"] = "\\v l", + ["0141"] = "\\L", + ["0142"] = "\\l", + ["0143"] = "\\'N", + ["0144"] = "\\'n", + ["0145"] = "\\c N", + ["0146"] = "\\c n", + ["0147"] = "\\v N", + ["0148"] = "\\v n", + ["014A"] = "\\NG", + ["014B"] = "\\ng", + ["014C"] = "\\=O", + ["014D"] = "\\=o", + ["014E"] = "\\u O", + ["014F"] = "\\u o", + ["0150"] = "\\H O", + ["0151"] = "\\H o", + ["0152"] = "\\OE", + ["0153"] = "\\oe", + ["0154"] = "\\'R", + ["0155"] = "\\'r", + ["0156"] = "\\c R", + ["0157"] = "\\c r", + ["0158"] = "\\v R", + ["0159"] = "\\v r", + ["015A"] = "\\'S", + ["015B"] = "\\'s", + ["015C"] = "\\^S", + ["015D"] = "\\^s", + ["015E"] = "\\c S", + ["015F"] = "\\c s", + ["0160"] = "\\v S", + ["0161"] = "\\v s", + ["0162"] = "\\c T", + ["0163"] = "\\c t", + ["0164"] = "\\v T", + ["0165"] = "\\v t", + ["0168"] = "\\~U", + ["0169"] = "\\~u", + ["016A"] = "\\=U", + ["016B"] = "\\=u", + ["016C"] = "\\u U", + ["016D"] = "\\u u", + ["016E"] = "\\r U", + ["016F"] = "\\r u", + ["0170"] = "\\H U", + ["0171"] = "\\H u", + ["0172"] = "\\k U", + ["0173"] = "\\k u", + ["0174"] = "\\^W", + ["0175"] = "\\^w", + ["0176"] = "\\^Y", + ["0177"] = "\\^y", + ["0178"] = "\\\"Y", + ["0179"] = "\\'Z", + ["017A"] = "\\'z", + ["017B"] = "\\.Z", + ["017C"] = "\\.z", + ["017D"] = "\\v Z", + ["017E"] = "\\v z", + ["0192"] = "\\textflorin", + ["01CD"] = "\\v A", + ["01CE"] = "\\v a", + ["01CF"] = "\\v I", + ["01D0"] = "\\v \\i", + ["01D1"] = "\\v O", + ["01D2"] = "\\v o", + ["01D3"] = "\\v U", + ["01D4"] = "\\v u", + ["01E2"] = "\\=\\AE", + ["01E3"] = "\\=\\ae", + ["01E6"] = "\\v G", + ["01E7"] = "\\v g", + ["01E8"] = "\\v K", + ["01E9"] = "\\v k", + ["01EA"] = "\\k O", + ["01EB"] = "\\k o", + ["01F0"] = "\\v\\j", + ["01F4"] = "\\'G", + ["01F5"] = "\\'g", + ["0218"] = "\\textcommabelow S", + ["0219"] = "\\textcommabelow s", + ["021A"] = "\\textcommabelow T", + ["021B"] = "\\textcommabelow t", + ["0232"] = "\\=Y", + ["0233"] = "\\=y", + ["0237"] = "\\j", + ["02C6"] = "\\textasciicircum", + ["02C7"] = "\\textasciicaron", + ["02D8"] = "\\textasciibreve", + ["02D9"] = "\\.{}", + ["02DB"] = "\\k{}", + ["02DC"] = "\\textasciitilde", + ["02DD"] = "\\textacutedbl", + ["0E3F"] = "\\textbaht", + ["1E02"] = "\\.B", + ["1E03"] = "\\.b", + ["1E0D"] = "\\d d", + ["1E1E"] = "\\.F", + ["1E1F"] = "\\.f", + ["1E20"] = "\\=G", + ["1E21"] = "\\=g", + ["1E25"] = "\\d h", + ["1E30"] = "\\'K", + ["1E31"] = "\\'k", + ["1E37"] = "\\d l", + ["1E43"] = "\\d m", + ["1E45"] = "\\.n", + ["1E47"] = "\\d n", + ["1E5B"] = "\\d r", + ["1E63"] = "\\d s", + ["1E6D"] = "\\d t", + ["1E8E"] = "\\.Y", + ["1E8F"] = "\\.y", + ["1E90"] = "\\^Z", + ["1E91"] = "\\^z", + ["1E9E"] = "\\SS", + ["1EF2"] = "\\`Y", + ["1EF3"] = "\\`y", + ["2003"] = "\\quad", + ["200C"] = "\\textcompwordmark", + ["2011"] = "\\mbox{-}", + ["2012"] = "\\textendash", + ["2013"] = "\\textendash", + ["2014"] = "\\textemdash", + ["2015"] = "\\textemdash", + ["2016"] = "\\textbardbl", + ["2018"] = "\\textquoteleft", + ["2019"] = "\\textquoteright", + ["201A"] = "\\quotesinglbase", + ["201C"] = "\\textquotedblleft", + ["201D"] = "\\textquotedblright", + ["201E"] = "\\quotedblbase", + ["2020"] = "\\textdagger", + ["2021"] = "\\textdaggerdbl", + ["2022"] = "\\textbullet", + ["2026"] = "\\textellipsis", + ["2030"] = "\\textperthousand", + ["2031"] = "\\textpertenthousand", + ["2039"] = "\\guilsinglleft", + ["203A"] = "\\guilsinglright", + ["203B"] = "\\textreferencemark", + ["203D"] = "\\textinterrobang", + ["2044"] = "\\textfractionsolidus", + ["204E"] = "\\textasteriskcentered", + ["2052"] = "\\textdiscount", + ["20A1"] = "\\textcolonmonetary", + ["20A4"] = "\\textlira", + ["20A6"] = "\\textnaira", + ["20A9"] = "\\textwon", + ["20AB"] = "\\textdong", + ["20AC"] = "\\texteuro", + ["20B1"] = "\\textpeso", + ["2103"] = "\\textcelsius", + ["2116"] = "\\textnumero", + ["2117"] = "\\textcircledP", + ["211E"] = "\\textrecipe", + ["2120"] = "\\textservicemark", + ["2122"] = "\\texttrademark", + ["2126"] = "\\textohm", + ["2127"] = "\\textmho", + ["212E"] = "\\textestimated", + ["2190"] = "\\textleftarrow", + ["2191"] = "\\textuparrow", + ["2192"] = "\\textrightarrow", + ["2193"] = "\\textdownarrow", + ["2329"] = "\\textlangle", + ["232A"] = "\\textrangle", + ["2422"] = "\\textblank", + ["2423"] = "\\textvisiblespace", + ["25E6"] = "\\textopenbullet", + ["25EF"] = "\\textbigcircle", + ["266A"] = "\\textmusicalnote", + ["27E8"] = "\\textlangle", + ["27E9"] = "\\textrangle", + ["3008"] = "\\textlangle", + ["3009"] = "\\textrangle", + FEFF = "\\nobreak", + }, + unicode_commands = { + ["\\\""] = { + A = "00C4", + E = "00CB", + I = "00CF", + O = "00D6", + U = "00DC", + Y = "0178", + ["\\i"] = "00EF", + a = "00E4", + e = "00EB", + i = "00EF", + o = "00F6", + u = "00FC", + y = "00FF", + }, + ["\\'"] = { + A = "00C1", + C = "0106", + E = "00C9", + G = "01F4", + I = "00CD", + K = "1E30", + L = "0139", + N = "0143", + O = "00D3", + R = "0154", + S = "015A", + U = "00DA", + Y = "00DD", + Z = "0179", + ["\\i"] = "00ED", + a = "00E1", + c = "0107", + e = "00E9", + g = "01F5", + i = "00ED", + k = "1E31", + l = "013A", + n = "0144", + o = "00F3", + r = "0155", + s = "015B", + u = "00FA", + y = "00FD", + z = "017A", + }, + ["\\-"] = "00AD", + ["\\."] = { + B = "1E02", + C = "010A", + E = "0116", + F = "1E1E", + G = "0120", + I = "0130", + Y = "1E8E", + Z = "017B", + b = "1E03", + c = "010B", + e = "0117", + f = "1E1F", + g = "0121", + n = "1E45", + y = "1E8F", + z = "017C", + ["{}"] = "02D9", + }, + ["\\="] = { + A = "0100", + E = "0112", + G = "1E20", + I = "012A", + O = "014C", + U = "016A", + Y = "0232", + ["\\AE"] = "01E2", + ["\\ae"] = "01E3", + ["\\i"] = "012B", + a = "0101", + e = "0113", + g = "1E21", + i = "012B", + o = "014D", + u = "016B", + y = "0233", + }, + ["\\AE"] = "00C6", + ["\\DH"] = "00D0", + ["\\DJ"] = "0110", + ["\\H"] = { + O = "0150", + U = "0170", + o = "0151", + u = "0171", + }, + ["\\IJ"] = "0132", + ["\\L"] = "0141", + ["\\NG"] = "014A", + ["\\O"] = "00D8", + ["\\OE"] = "0152", + ["\\SS"] = "1E9E", + ["\\TH"] = "00DE", + ["\\^"] = { + A = "00C2", + C = "0108", + E = "00CA", + G = "011C", + H = "0124", + I = "00CE", + J = "0134", + O = "00D4", + S = "015C", + U = "00DB", + W = "0174", + Y = "0176", + Z = "1E90", + ["\\i"] = "00EE", + ["\\j"] = "0135", + a = "00E2", + c = "0109", + e = "00EA", + g = "011D", + h = "0125", + i = "00EE", + o = "00F4", + s = "015D", + u = "00FB", + w = "0175", + y = "0177", + z = "1E91", + }, + ["\\`"] = { + A = "00C0", + E = "00C8", + I = "00CC", + O = "00D2", + U = "00D9", + Y = "1EF2", + ["\\i"] = "00EC", + a = "00E0", + e = "00E8", + i = "00EC", + o = "00F2", + u = "00F9", + y = "1EF3", + }, + ["\\ae"] = "00E6", + ["\\c"] = { + C = "00C7", + G = "0122", + K = "0136", + L = "013B", + N = "0145", + R = "0156", + S = "015E", + T = "0162", + ["\\ "] = "00B8", + c = "00E7", + g = "0123", + k = "0137", + l = "013C", + n = "0146", + r = "0157", + s = "015F", + t = "0163", + }, + ["\\d"] = { + d = "1E0D", + h = "1E25", + l = "1E37", + m = "1E43", + n = "1E47", + r = "1E5B", + s = "1E63", + t = "1E6D", + }, + ["\\dh"] = "00F0", + ["\\dj"] = "0111", + ["\\guillemetleft"] = "00AB", + ["\\guillemetright"] = "00BB", + ["\\guilsinglleft"] = "2039", + ["\\guilsinglright"] = "203A", + ["\\i"] = "0131", + ["\\ij"] = "0133", + ["\\j"] = "0237", + ["\\k"] = { + A = "0104", + E = "0118", + I = "012E", + O = "01EA", + U = "0172", + a = "0105", + e = "0119", + i = "012F", + o = "01EB", + u = "0173", + ["{}"] = "02DB", + }, + ["\\l"] = "0142", + ["\\mbox"] = { + ["{-}"] = "2011", + }, + ["\\ng"] = "014B", + ["\\nobreak"] = "FEFF", + ["\\nobreakspace"] = "00A0", + ["\\o"] = "00F8", + ["\\oe"] = "0153", + ["\\quad"] = "2003", + ["\\quotedblbase"] = "201E", + ["\\quotesinglbase"] = "201A", + ["\\r"] = { + A = "00C5", + U = "016E", + a = "00E5", + u = "016F", + }, + ["\\ss"] = "00DF", + ["\\textacutedbl"] = "02DD", + ["\\textasciiacute"] = "00B4", + ["\\textasciibreve"] = "02D8", + ["\\textasciicaron"] = "02C7", + ["\\textasciicircum"] = "02C6", + ["\\textasciidieresis"] = "00A8", + ["\\textasciimacron"] = "00AF", + ["\\textasciitilde"] = "02DC", + ["\\textasteriskcentered"] = "204E", + ["\\textbackslash"] = "005C", + ["\\textbaht"] = "0E3F", + ["\\textbardbl"] = "2016", + ["\\textbigcircle"] = "25EF", + ["\\textblank"] = "2422", + ["\\textbrokenbar"] = "00A6", + ["\\textbullet"] = "2022", + ["\\textcelsius"] = "2103", + ["\\textcent"] = "00A2", + ["\\textcircledP"] = "2117", + ["\\textcolonmonetary"] = "20A1", + ["\\textcommabelow"] = { + S = "0218", + T = "021A", + s = "0219", + t = "021B", + }, + ["\\textcompwordmark"] = "200C", + ["\\textcopyright"] = "00A9", + ["\\textcurrency"] = "00A4", + ["\\textdagger"] = "2020", + ["\\textdaggerdbl"] = "2021", + ["\\textdegree"] = "00B0", + ["\\textdiscount"] = "2052", + ["\\textdiv"] = "00F7", + ["\\textdong"] = "20AB", + ["\\textdownarrow"] = "2193", + ["\\textellipsis"] = "2026", + ["\\textemdash"] = "2014", + ["\\textendash"] = "2013", + ["\\textestimated"] = "212E", + ["\\texteuro"] = "20AC", + ["\\textexclamdown"] = "00A1", + ["\\textflorin"] = "0192", + ["\\textfractionsolidus"] = "2044", + ["\\textinterrobang"] = "203D", + ["\\textlangle"] = "2329", + ["\\textleftarrow"] = "2190", + ["\\textlira"] = "20A4", + ["\\textlnot"] = "00AC", + ["\\textmho"] = "2127", + ["\\textmu"] = "00B5", + ["\\textmusicalnote"] = "266A", + ["\\textnaira"] = "20A6", + ["\\textnumero"] = "2116", + ["\\textohm"] = "2126", + ["\\textonehalf"] = "00BD", + ["\\textonequarter"] = "00BC", + ["\\textonesuperior"] = "00B9", + ["\\textopenbullet"] = "25E6", + ["\\textordfeminine"] = "00AA", + ["\\textordmasculine"] = "00BA", + ["\\textparagraph"] = "00B6", + ["\\textperiodcentered"] = "00B7", + ["\\textpertenthousand"] = "2031", + ["\\textperthousand"] = "2030", + ["\\textpeso"] = "20B1", + ["\\textpm"] = "00B1", + ["\\textquestiondown"] = "00BF", + ["\\textquotedblleft"] = "201C", + ["\\textquotedblright"] = "201D", + ["\\textquoteleft"] = "2018", + ["\\textquoteright"] = "2019", + ["\\textrangle"] = "232A", + ["\\textrecipe"] = "211E", + ["\\textreferencemark"] = "203B", + ["\\textregistered"] = "00AE", + ["\\textrightarrow"] = "2192", + ["\\textsection"] = "00A7", + ["\\textservicemark"] = "2120", + ["\\textsterling"] = "00A3", + ["\\textthreequarters"] = "00BE", + ["\\textthreesuperior"] = "00B3", + ["\\texttimes"] = "00D7", + ["\\texttrademark"] = "2122", + ["\\texttwosuperior"] = "00B2", + ["\\textuparrow"] = "2191", + ["\\textvisiblespace"] = "2423", + ["\\textwon"] = "20A9", + ["\\textyen"] = "00A5", + ["\\th"] = "00FE", + ["\\u"] = { + A = "0102", + E = "0114", + G = "011E", + I = "012C", + O = "014E", + U = "016C", + ["\\i"] = "012D", + a = "0103", + e = "0115", + g = "011F", + i = "012D", + o = "014F", + u = "016D", + }, + ["\\v"] = { + A = "01CD", + C = "010C", + D = "010E", + E = "011A", + G = "01E6", + I = "01CF", + K = "01E8", + L = "013D", + N = "0147", + O = "01D1", + R = "0158", + S = "0160", + T = "0164", + U = "01D3", + Z = "017D", + ["\\i"] = "01D0", + ["\\j"] = "01F0", + a = "01CE", + c = "010D", + d = "010F", + e = "011B", + g = "01E7", + i = "01D0", + k = "01E9", + l = "013E", + n = "0148", + o = "01D2", + r = "0159", + s = "0161", + t = "0165", + u = "01D4", + z = "017E", + }, + ["\\~"] = { + A = "00C3", + I = "0128", + N = "00D1", + O = "00D5", + U = "0168", + ["\\i"] = "0129", + a = "00E3", + i = "0129", + n = "00F1", + o = "00F5", + u = "0169", + }, + }, +} diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex.lua new file mode 100644 index 00000000000..645fb5384bc --- /dev/null +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex.lua @@ -0,0 +1,713 @@ +-- +-- Copyright (c) 2021-2022 Zeping Lee +-- Released under the MIT license. +-- Repository: https://github.com/zepinglee/citeproc-lua +-- + +--[[ + A PEG-based implementation of a Bib(La)TeX dateabase (.bib) parser + References notes: tools/bibtex-parser-notes.md +--]] + +local bibtex = {} + +local lpeg = require("lpeg") +local unicode = require("unicode") +local bibtex_data = require("citeproc-bibtex-data") +local util = require("citeproc-util") + +local P = lpeg.P +local R = lpeg.R +local S = lpeg.S +local C = lpeg.C +local Cc = lpeg.Cc +local Cf = lpeg.Cf +local Cg = lpeg.Cg +local Cmt = lpeg.Cmt +local Cp = lpeg.Cp +local Ct = lpeg.Ct +local V = lpeg.V + +bibtex.strings = {} -- Stores all the @STRINGs +for key, value in pairs(bibtex_data.macros) do + bibtex.strings[key] = value.value +end + + +-- Parse BibTeX content and convert to CSL-JSON +function bibtex.parse(str) + local bibliography = bibtex.parse_bibtex(str, bibtex.strings) + local csl_json_items = bibtex.convert_csl_json(bibliography) + return csl_json_items +end + + +-- The case-insensitivity trick is taken from <http://boston.conman.org/2020/06/05.1>. +local function ignore_case(str) + local char = R("AZ", "az") / function (c) return P(c:lower()) + P(c:upper()) end + + P(1) / function (c) return P(c) end + return Cf(char^1, function (a, b) return a * b end):match(str) +end + + local function normalize_white_space(str) + local res = string.gsub(str, "%s+", " ") + return res + end + +-- Based on the grammar described at <https://github.com/aclements/biblib>. +function bibtex.get_bibtex_grammar() + local comment = (1 - P"@")^0 + local space = S(" \t\r\n")^0 + local comment_cmd = ignore_case("comment") + local balanced = P{ "{" * V(1)^0 * "}" + (1 - S"{}") } + local ident = (- R"09") * (R"\x20\x7F" - S" \t\"#%'(),={}")^1 + + local piece = (P"{" * (balanced^0 / normalize_white_space) * P"}") + + (P'"' * ((balanced - P'"')^0 / normalize_white_space) * P'"') + + C(R("09")^1) + + C(ident) / function (name) + return { + category = "string", + name = string.lower(name), + } + end + local value = Ct(piece * (space * P"#" * space * piece)^0) + + local string_body = Cg(ident / string.lower, "name") * space * P"=" * space * Cg(value, "contents") + local string_cmd = Ct(Cg(Cc"string", "category") * ignore_case("string") * space * ( + P"{" * space * string_body * space * P"}" + + P"(" * space * string_body * space * P")" + )) + + local preamble_body = Cg(value, "contents") + local preamble_cmd = Ct(Cg(Cc"preamble", "category") * ignore_case("preamble") * space * ( + P"{" * space * preamble_body * space * P"}" + + P"(" * space * preamble_body * space * P")" + )) + + local key = (1 - S", \t}\r\n")^0 + local key_paren = (1 - S", \t\r\n")^0 + local field_value_pair = (ident / string.lower) * space * P"=" * space * value -- * record_success_position() + + local entry_body = Cf(Ct"" * (P"," * space * Cg(field_value_pair))^0 * (P",")^-1, rawset) + local entry = Ct(Cg(Cc"entry", "category") * Cg(ident / string.lower, "type") * space * ( + P"{" * space * Cg(key, "key") * space * Cg(entry_body, "fields")^-1 * space * (P"}") + + P"(" * space * Cg(key_paren, "key") * space * Cg(entry_body, "fields")^-1 * space * (P")") + )) + + local command_or_entry = P"@" * space * (comment_cmd + preamble_cmd + string_cmd + entry) + + -- The P(-1) causes nil parsing result in case of error. + local bibtex_grammar = Ct(comment * (command_or_entry * comment)^0) * P(-1) + + return bibtex_grammar +end + + +bibtex.bibtex_grammar = bibtex.get_bibtex_grammar() + + +-- Return a list of entries, strings, preamble +function bibtex.parse_bibtex_objects(str) + return bibtex.bibtex_grammar:match(str) +end + + +local function concat_strings(pieces, strings) + local value = "" + for _, piece in ipairs(pieces) do + if type(piece) == "string" then + value = value .. piece + elseif type(piece) == "table" and piece.category == "string" then + local piece_str = strings[piece.name] + if piece_str then + value = value .. piece_str + else + util.warning(string.format('String name "%s" is undefined."', piece.name)) + end + end + end + value = normalize_white_space(value) + return value +end + + +function bibtex.parse_bibtex(content, strings) + if strings then + strings = setmetatable({}, {__index = strings}) + else + strings = setmetatable({}, {__index = bibtex.strings}) + end + local bib_objects = bibtex.parse_bibtex_objects(content) + + local res = { + entries = {}, + strings = {}, + preamble = "", + } + local exceptions = {} + for _, object in ipairs(bib_objects) do + if object.category == "entry" then + object.category = nil + for field, value in pairs(object.fields) do + local value_str = concat_strings(value, strings) + if field ~= "url" then + value_str = bibtex.to_unicode(value_str) + end + object.fields[field] = value_str + end + table.insert(res.entries, object) + + elseif object.category == "string" then + local string_value = concat_strings(object.contents, strings) + strings[object.name] = string_value + res.strings[object.name] = string_value + + elseif object.category == "preamble" then + res.preamble = res.preamble .. concat_strings(object.contents, strings) + + -- elseif object.category == "comment" then + -- Is this really needed? + + elseif object.category == "exception" then + -- TODO + + end + end + + return res +end + + +local function get_line_number(str, position) + local line_number = 1 + for i = 1, position do + if string.sub(str, i, i) == "\n" then + line_number = line_number + 1 + end + end + return line_number +end + + +function bibtex.get_latex_grammar() + local space = S(" \t\r\n")^0 + local specials = P"\\$" / "$" + + P"\\%" / "%" + + P"\\&" / "&" + + P"\\#" / "#" + + P"\\_" / "_" + + P"\\{" / "{" + + P"\\}" / "}" + + P"~" / util.unicode["no-break space"] + local control_sequence = C(P"\\" * (R("AZ", "az")^1 + 1) * space) / function (cs) + return { + type = "control_sequence", + name = util.rstrip(cs), + raw = cs, + } + end + local math = P"$" * C((P"\\$" + 1 - S"$")^0) * P"$" / function (math_text) + return { + type = "math", + contents = math_text, + } + end + local ligatures = P"``" / util.unicode["left double quotation mark"] + + P"`" / util.unicode["left single quotation mark"] + + P"''" / util.unicode["right double quotation mark"] + + P"'" / util.unicode["right single quotation mark"] + + P"---" / util.unicode["em dash"] + + P"--" / util.unicode["en dash"] + local plain_text = C(1 - S"{}$\\") + local latex_grammar = P{ + "latex_text"; + latex_text = Ct((specials + control_sequence + math + ligatures + specials + V"group" + plain_text)^0), + group = P"{" * V"latex_text" * P"}" / function (group_contents) + return { + type = "group", + contents = group_contents, + } + end, + } + return latex_grammar +end + +bibtex.latex_grammar = bibtex.get_latex_grammar() + + +function bibtex.to_unicode(str) + local tokens = bibtex.latex_grammar:match(str) + local res = bibtex.unescape_tokens(tokens, 0) + return res +end + +local format_commands_with_argment = { + ["\\textrm"] = {'<span class="nodecor">', '</span>'}, + ["\\textbf"] = {'<b>', '</b>'}, + ["\\textit"] = {'<i>', '</i>'}, + ["\\textsl"] = {'<i>', '</i>'}, + ["\\emph"] = {'<i>', '</i>'}, + ["\\textsc"] = {'<span style="font-variant: small-caps;">', '</span>'}, + ["\\textsuperscript"] = {'<sup>', '</sup>'}, + ["\\textsubscript"] = {'<sub>', '</sub>'}, +} + +local format_commands_without_argment = { + ["\\rm"] = {'<span class="nodecor">', '</span>'}, + ["\\upshape"] = {'<span class="nodecor">', '</span>'}, + ["\\bf"] = {'<b>', '</b>'}, + ["\\bfseries"] = {'<b>', '</b>'}, + ["\\it"] = {'<i>', '</i>'}, + ["\\itshape"] = {'<i>', '</i>'}, + ["\\sl"] = {'<i>', '</i>'}, + ["\\slshape"] = {'<i>', '</i>'}, + ["\\em"] = {'<i>', '</i>'}, + ["\\scshape"] = {'<span style="font-variant: small-caps;">', '</span>'}, + ["\\sc"] = {'<span style="font-variant: small-caps;">', '</span>'}, +} + + +function bibtex.unescape_tokens(tokens, brace_level) + local res = "" + local skip_token = false + for i, token in ipairs(tokens) do + if skip_token then + skip_token = false + else + if type(token) == "string" then + res = res .. token + elseif type(token) == "table" then + if token.type == "control_sequence" then + local code_point = bibtex_data.unicode_commands[token.name] + if code_point then + local unicode_char + if type(code_point) == "string" then + unicode_char = utf8.char(tonumber(code_point, 16)) + elseif type(code_point) == "table" then + -- The command takes an argument (\"{o}) + local arg + if i < #tokens then + local next_token = tokens[i + 1] + if type(next_token) == "string" then + arg = next_token + skip_token = true + elseif type(next_token) == "table" then + if next_token.type == "control_sequence" then + arg = next_token.name + skip_token = true + elseif next_token.type == "group" then + if #next_token.contents == 0 then + arg = "{}" + skip_token = true + elseif #next_token.contents == 1 then + next_token = next_token.contents[1] + if type(next_token) == "string" then + arg = next_token + skip_token = true + elseif type(next_token) == "table" then + arg = next_token.name + skip_token = true + end + end + end + end + end + if arg and code_point[arg] then + unicode_char = utf8.char(tonumber(code_point[arg], 16)) + end + end + if unicode_char then + res = res .. unicode_char + else + res = res .. '<span class="nocase">' .. token.raw .. '</span>' + end + + elseif format_commands_with_argment[token.name] then + -- Commands like `\textbf` + if i < #tokens then + local next_token = tokens[i + 1] + if type(next_token) == "table" and next_token.type == "group" then + local tags = format_commands_with_argment[token.name] + if brace_level == 0 then + res = res .. tags[1] .. '<span class="nocase">' .. bibtex.unescape_tokens(next_token.contents, brace_level + 1) .. '</span>' .. tags[2] + else + res = res .. tags[1] .. bibtex.unescape_tokens(next_token.contents, brace_level + 1) .. tags[2] + end + skip_token = true + else + res = res .. '<span class="nocase">' .. token.raw .. '</span>' + end + else + res = res .. '<span class="nocase">' .. token.raw .. '</span>' + end + + else + res = res .. '<span class="nocase">' .. token.raw .. '</span>' + + end + + elseif token.type == "math" then + -- res = res .. "$" .. token .. "$" + res = res .. '<span class="nocase">' .. token.raw .. '</span>' + + elseif token.type == "group" then + local first_token = token.contents[1] + if type(first_token) == "table" and first_token.type == "control_sequence" then + local tags = format_commands_without_argment[first_token.name] + if tags then + table.remove(token.contents, 1) + res = res .. tags[1] .. bibtex.unescape_tokens(token.contents, brace_level) .. tags[2] + else + res = res .. bibtex.unescape_tokens(token.contents, brace_level) + end + else + if brace_level == 0 then + res = res .. '<span class="nocase">' .. bibtex.unescape_tokens(token.contents, brace_level + 1) .. '</span>' + else + res = res .. '<span class="nocase">' .. bibtex.unescape_tokens(token.contents, brace_level + 1) .. '</span>' + end + end + + end + end + end + end + return res +end + +-- function bibtex.format_syntanx_error(str, position, file_path) +-- local line_number = 1 +-- local line_start = 1 +-- local column_number = 0 +-- for i = 1, position do +-- column_number = column_number + 1 +-- if string.sub(str, i, i) == "\n" then +-- line_number = line_number + 1 +-- line_start = i + 1 +-- column_number = 0 +-- end +-- end +-- -- return line_number, column_number + +-- local res +-- if file_path then +-- res = string.format('File "%s", line %d\n', file_path, line_number) +-- else +-- res = string.format('Line %d\n', line_number) +-- end +-- local line_end = position +-- while line_end < #str + 1 and string.sub(str, line_end, line_end) ~= "\n" do +-- line_end = line_end + 1 +-- end +-- res = res .. " " .. string.sub(str, line_start, line_end - 1) .. "\n" +-- res = res .. "Syntax Error" +-- return res +-- end + + +function bibtex.convert_csl_json(bibliography) + local csl_json_data = {} + for _, entry in ipairs(bibliography.entries) do + local item = { -- CSL-JSON item + id = entry.key, + type = "document", + } + + -- CSL types + local type_data = bibtex_data.types[entry.type] + if type_data and type_data.csl then + item.type = type_data.csl + end + + for field, value in pairs(entry.fields) do + local csl_field, csl_value = bibtex.convert_field(field, value) + + if csl_field and csl_value and not item[csl_field] then + item[csl_field] = csl_value + end + end + + bibtex.process_special_fields(item, entry.fields) + + table.insert(csl_json_data, item) + end + + return csl_json_data +end + + +function bibtex.convert_field(bib_field, value) + local field_data = bibtex_data.fields[bib_field] + if not field_data then + return nil, nil + end + local csl_field = field_data.csl + if not csl_field then + return nil, nil + end + + local field_type = field_data.type + if field_type == "name" then + value = bibtex.parse_names(value) + + elseif field_type == "date" then + value = bibtex.parse_date(value) + + -- elseif bib_field == "title" or bib_field == "booktitle" then + -- value = bibtex.convert_sentence_case(value) + + elseif bib_field == "volume" or bib_field == "pages" then + value = string.gsub(value, util.unicode["en dash"], "-") + end + + return csl_field, value +end + + +function bibtex.parse_names(str) + -- "{International Federation of Library Association and Institutions}" + local names = {} + local brace_level = 0 + local name = "" + local last_word = "" + for i = 1, #str do + local char = string.sub(str, i, i) + if char == " " then + if brace_level == 0 and last_word == "and" then + table.insert(names, name) + name = "" + else + if name ~= "" then + name = name .. " " + end + name = name .. last_word + end + last_word = "" + else + last_word = last_word .. char + if char == "{" then + brace_level = brace_level + 1 + elseif char == "}" then + brace_level = brace_level - 1 + end + end + end + + if name ~= "" then + name = name .. " " + end + name = name .. last_word + table.insert(names, name) + + for i, name in ipairs(names) do + names[i] = bibtex.parse_single_name(name) + end + return names +end + +function bibtex.parse_single_name(str) + local literal = string.match(str, "^{(.*)}$") + if literal then + return { + literal = literal, + } + end + + local name_parts = util.split(str, ",%s*") + if #name_parts > 1 then + return bibtex.parse_revesed_name(name_parts) + else + return bibtex.parse_non_revesed_name(str) + end +end + +function bibtex.parse_revesed_name(name_parts) + local name = {} + local von, last, jr, first + if #name_parts == 2 then + first = name_parts[2] + elseif #name_parts >= 3 then + jr = name_parts[2] + first = name_parts[3] + end + if first and first ~= "" then + name.given = first + end + if jr and jr ~= "" then + name.suffix = jr + end + + last = name_parts[1] + local words = util.split(last) + local index = #words - 1 + while index > 0 and string.match(words[index], "^%L") do + index = index - 1 + end + name.family = util.concat(util.slice(words, index + 1), " ") + if index >= 1 then + von = util.concat(util.slice(words, 1, index), " ") + name["non-dropping-particle"] = von + end + return name +end + +function bibtex.parse_non_revesed_name(str) + local name = {} + local words = util.split(str) + + local index = 1 + -- TODO: case determination for pseudo-characters (e.g., "\bb{BB}") + while index < #words and string.match(words[index], "^%L") do + index = index + 1 + end + if index > 1 then + name.given = util.concat(util.slice(words, 1, index - 1), " ") + end + + local particle_start_index = index + index = #words - 1 + while index >= particle_start_index and string.match(words[index], "^%L") do + index = index - 1 + end + if index >= particle_start_index then + local particles = util.slice(words, particle_start_index, index) + -- TODO: distiguish dropping and non-dropping particles + name["non-dropping-particle"] = util.concat(particles, " ") + end + name.family = util.concat(util.slice(words, index + 1), " ") + + return name +end + +function bibtex.parse_date(str) + local date_range = util.split(str, "/") + if #date_range == 1 then + date_range = util.split(str, util.unicode["en dash"]) + end + + local literal = { literal = str } + + if #date_range > 2 then + return literal + end + + local date = {} + date["date-parts"] = {} + for _, date_part in ipairs(date_range) do + local date_ = bibtex.parse_single_date(date_part) + if not date_ then + return literal + end + table.insert(date["date-parts"], date_) + end + return date +end + +function bibtex.parse_single_date(str) + local date = {} + for _, date_part in ipairs(util.split(str, "%-")) do + if not string.match(date_part, "^%d+$") then + return nil + end + table.insert(date, tonumber(date_part)) + end + return date +end + + +-- -- TODO: check if the original title is in sentence case +-- function bibtex.convert_sentence_case(str) +-- local res = "" +-- local to_lower = false +-- local brace_level = 0 +-- for _, code_point in utf8.codes(str) do +-- local char = utf8.char(code_point) +-- if to_lower and brace_level == 0 then +-- char = string.lower(char) +-- end +-- if string.match(char, "%S") then +-- to_lower = true +-- end +-- if char == "{" then +-- brace_level = brace_level + 1 +-- char = "" +-- elseif char == "}" then +-- brace_level = brace_level - 1 +-- char = "" +-- elseif char == ":" then +-- to_lower = false +-- end +-- res = res .. char +-- end +-- return res +-- end + + + +function bibtex.process_special_fields(item, bib_fields) + -- Default entry type `document` + if item.type == "document" then + if item.URL then + item.type = "webpage" + else + item.type = "article" + end + end + + -- event-title: for compatibility with CSL v1.0.1 and earlier versions + if item["event-title"] then + item.event = item["event-title"] + end + + -- issued date + if bib_fields.year and not item.issued then + item.issued = bibtex.parse_date(bib_fields.year) + end + local month = bib_fields.month + if month and string.match(month, "^%d+$") then + if item.issued and item.issued["date-parts"] and + item.issued["date-parts"][1] and + item.issued["date-parts"][1][2] == nil then + item.issued["date-parts"][1][2] = tonumber(month) + end + end + + -- language: convert `babel` language to ISO 639-1 language code + if not item.language and bib_fields.language then + item.language = bib_fields.language + end + if item.language then + local language_code = bibtex_data.language_code_map[item.language] + if language_code then + item.language = language_code + end + end + -- if not item.language then + -- if util.has_cjk_char(item.title) then + -- item.language = "zh" + -- end + -- end + + -- number + if item.number then + if item.type == "article-journal" or item.type == "article-magazine" or item.type == "article-newspaper" or item.type == "periodical" then + if not item.issue then + item.issue = item.number + item.number = nil + end + elseif item["collection-title"] and not item["collection-number"] then + item["collection-number"] = item.number + item.number = nil + end + end + + -- PMID + if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then + item.PMID = bib_fields.eprint + end + +end + + +return bibtex diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-cli.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-cli.lua index 97a51d724c8..a199c8e68cb 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-cli.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-cli.lua @@ -10,6 +10,7 @@ local cli = {} require("lualibs") local citeproc = require("citeproc") +local bibtex -- = require("citeproc-bibtex") -- load on demand local util = require("citeproc-util") local core = require("citeproc-latex-core") @@ -67,13 +68,17 @@ end local function convert_bib(path, output_path) local contents = util.read_file(path) - local bib = citeproc.parse_bib(contents) + bibtex = bibtex or require("citeproc-bibtex") + local data = bibtex.parse(contents) if not output_path then output_path = string.gsub(path, "%.bib$", ".json") end local file = io.open(output_path, "w") - file:write(utilities.json.tojson(bib)) - file:write('\n') + if not file then + util.error(string.format('Cannot write "%s".', output_path)) + return + end + file:write(utilities.json.tojson(data) .. "\n") file:close() end @@ -87,7 +92,7 @@ local function read_aux_file(aux_file) local file = io.open(aux_file, "r") if not file then - error(string.format('Failed to open "%s"', aux_file)) + error(string.format('Cannot read "%s"', aux_file)) return end for line in file:lines() do diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua index 2e9f4c4a61b..d59c3bb4ea1 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua @@ -621,8 +621,6 @@ function CiteProc:build_ambiguous_ir(cite_item, output_format) if context.reference then ir = self.style.citation:build_ir(self, state, context) else - -- The warning has been given in the retrieving procedure. - -- util.warning(string.format('Failed to find the entry "%s" in database.', cite_item.id)) ir = Rendered:new({Formatted:new({PlainText:new(cite_item.id)}, {["font-weight"] = "bold"})}, self) end @@ -1804,7 +1802,7 @@ function CiteProc:_retrieve_item(id) local res = {} local item = self.sys.retrieveItem(id) if not item then - util.warning(string.format('Failed to find entry "%s"', id)) + util.warning(string.format('Database entry "%s" not found', id)) return nil end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-core.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-core.lua index 0be2381797d..8472818bac2 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-core.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-core.lua @@ -7,6 +7,7 @@ local core = {} local citeproc = require("citeproc") +local bibtex -- = require("citeproc-bibtex") -- load on demand local util = citeproc.util require("lualibs") @@ -15,44 +16,24 @@ core.locale_file_format = "csl-locales-%s.xml" core.uncited_ids = {} core.uncite_all_items = false -function core.error(message) - if luatexbase then - luatexbase.module_error("csl", message) - else - util.error(message) - end -end - -function core.warning(message) - if luatexbase then - luatexbase.module_warning("csl", message) - else - util.warning(message) - end -end -function core.info(message) - if luatexbase then - luatexbase.module_info("csl", message) +function core.read_file(file_name, ftype, file_info) + if file_info then + file_info = util.capitalize(file_info) else - util.info(message) + file_info = "File" end -end - - -function core.read_file(file_name, ftype, file_info) - file_info = file_info or "file" local path = kpse.find_file(file_name, ftype) if not path then if ftype and not util.endswith(file_name, ftype) then file_name = file_name .. ftype end - core.error(string.format('Cannot find %s "%s"', file_info, file_name)) + util.error(string.format('%s "%s" not found', file_info, file_name)) return nil end local file = io.open(path, "r") if not file then - core.error(string.format('Cannot open %s "%s"', file_info, path)) + util.error(string.format('Cannot open %s "%s"', file_info, path)) return nil end local contents = file:read("*a") @@ -85,7 +66,7 @@ local function read_data_file(data_file) extension = ".bib" contents = core.read_file(data_file, "bib", "database file") else - core.error(string.format('Cannot find database file "%s"', data_file .. ".json")) + util.error(string.format('Cannot find database file "%s"', data_file .. ".json")) end end end @@ -95,7 +76,8 @@ local function read_data_file(data_file) if extension == ".json" then csl_items = utilities.json.tolua(contents) elseif extension == ".bib" then - csl_items = citeproc.parse_bib(contents) + bibtex = bibtex or require("citeproc-bibtex") + csl_items = bibtex.parse(contents) end return file_name, csl_items @@ -111,7 +93,7 @@ local function read_data_files(data_files) for _, item in ipairs(csl_items) do local id = item.id if bib[id] then - core.warning(string.format('Duplicate entry key "%s" in "%s".', id, file_name)) + util.warning(string.format('Duplicate entry key "%s" in "%s".', id, file_name)) else bib[id] = item end @@ -132,9 +114,6 @@ function core.make_citeproc_sys(data_files) end, retrieveItem = function (id) local res = core.bib[id] - -- if not res then - -- core.warning(string.format('Failed to find entry "%s".', id)) - -- end return res end } @@ -146,9 +125,9 @@ function core.init(style_name, data_files, lang) if style_name == "" or #data_files == 0 then return nil end - local style = core.read_file(style_name .. ".csl", nil, "style file") + local style = core.read_file(style_name .. ".csl", nil, "style") if not style then - core.error(string.format('Failed to load style "%s.csl"', style_name)) + util.error(string.format('Failed to load style "%s.csl"', style_name)) return nil end @@ -244,10 +223,12 @@ function core.update_uncited_items(engine, citations) for _, citation in ipairs(citations) do if citation.citationID == "@nocite" then for _, cite_item in ipairs(citation.citationItems) do - table.insert(core.uncited_ids, cite_item.id) if cite_item.id == "*" then - for id, _ in pairs(core.bib) do - table.insert(core.uncited_ids, id) + if not core.uncite_all_items then + for id, _ in pairs(core.bib) do + table.insert(core.uncited_ids, id) + end + core.uncite_all_items = true end else table.insert(core.uncited_ids, cite_item.id) diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua index 19348635b00..cce8f2a1912 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex.lua @@ -22,17 +22,6 @@ csl.citations_pre = {} csl.preview_mode = false -- Whether to use citeproc:preview_citation -function csl.error(str) - luatexbase.module_error("csl", str) -end -function csl.warning(str) - luatexbase.module_warning("csl", str) -end -function csl.info(str) - luatexbase.module_info("csl", str) -end - - function csl.init(style_name, bib_files, lang) bib_files = util.split(util.strip(bib_files), "%s*,%s*") @@ -68,10 +57,24 @@ end function csl.register_citation_info(citation_info) local citation = core.make_citation(citation_info) - for _, cite_item in ipairs(citation.citationItems) do - if not csl.id_map[cite_item.id] then - table.insert(csl.id_list, cite_item.id) - csl.id_map[cite_item.id] = true + if citation.citationID == "@nocite" then + for _, cite_item in ipairs(citation.citationItems) do + if cite_item.id == "*" then + -- \nocite all items + core.uncite_all_items = true + + elseif not csl.uncited_id_map[cite_item.id] then + table.insert(csl.uncited_id_list, cite_item.id) + csl.uncited_id_map[cite_item.id] = true + end + end + + else + for _, cite_item in ipairs(citation.citationItems) do + if not csl.id_map[cite_item.id] then + table.insert(csl.id_list, cite_item.id) + csl.id_map[cite_item.id] = true + end end end end @@ -137,7 +140,7 @@ end function csl.bibliography() if not csl.engine then - csl.error("CSL engine is not initialized.") + util.error("CSL engine is not initialized.") return end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-names.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-names.lua index 2f02367eead..749f571bd24 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-names.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-names.lua @@ -82,7 +82,7 @@ end function Names:build_ir(engine, state, context) -- names_inheritance: names and name attributes inherited from cs:style - -- and cs:citaiton or cs:bibliography + -- and cs:citation or cs:bibliography -- name_override: names, name, et-al, label elements inherited in substitute element local names_inheritance = Names:new() names_inheritance.delimiter = context.name_inheritance.names_delimiter diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-util.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-util.lua index 38de3b57511..71221e6bec9 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-util.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-util.lua @@ -72,7 +72,14 @@ end function util.error(message) if luatexbase then - luatexbase.module_error("citeproc", message) + -- The luatexbase.module_error() prints the traceback, which causes panic + -- luatexbase.module_error("citeproc", message) + + texio.write_nl("term", "\n") + tex.error("Module citeproc Error: " .. message) + + -- tex.print(string.format("\\PackageError{citation-style-language}{%s}{}", message)) + else error(message, 2) end @@ -82,9 +89,13 @@ util.warning_enabled = true function util.warning(message) if luatexbase then + texio.write_nl("term", "\n") luatexbase.module_warning("citeproc", message) + + -- tex.print(string.format("\\PackageWarning{citation-style-language}{%s}{}", message)) + elseif util.warning_enabled then - io.stderr:write(message, "\n") + io.stderr:write("Warning: " .. message, "\n") end end @@ -158,7 +169,7 @@ function util.split_multiple(str, seps, include_sep) end if #seps > 1 then - table.sort(splits, function(a, b) return a[1] < b[1] end) + table.sort(splits, function (a, b) return a[1] < b[1] end) end local res = {} @@ -972,7 +983,10 @@ function util.read_file(path) print(debug.traceback()) end local file = io.open(path, "r") - if not file then return nil end + if not file then + -- util.error(string.format('Cannot read file "%s".', path)) + return nil + end local content = file:read("*a") file:close() return content diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc.lua index b266abbdc5a..67b73961529 100755 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc.lua @@ -7,13 +7,11 @@ local citeproc = {} local engine = require("citeproc-engine") -local bib = require("citeproc-bib") local util = require("citeproc-util") -citeproc.__VERSION__ = "0.2.0" +citeproc.__VERSION__ = "0.2.1" citeproc.new = engine.CiteProc.new -citeproc.parse_bib = bib.parse citeproc.util = util return citeproc diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty index 87165c4be28..bc4acd29e23 100644 --- a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language.sty @@ -9,7 +9,7 @@ \RequirePackage{expl3} \RequirePackage{xparse} -\ProvidesExplPackage {citation-style-language} {2022-08-18} {v0.2.0} +\ProvidesExplPackage {citation-style-language} {2022-09-18} {v0.2.1} {Citation Style Language for LaTeX} \RequirePackage { l3keys2e } @@ -293,8 +293,8 @@ % #1: citation info "{<citationID>}{{id=ITEM-1},{id=ITEM-2}}{<noteIndex>}" { \if@filesw - \iow_now:Nn \@auxout - { \citation { #1 } } + \iow_now:Nx \@auxout + { \token_to_str:N \citation { #1 } } \fi } @@ -398,7 +398,7 @@ { \bibcite {#1} {#2} % \if@filesw - % \iow_now:Nn \@auxout { \bibcite {#1} {#2} } + % \iow_now:Nx \@auxout { \token_to_str:N \bibcite {#1} {#2} } % \fi } @@ -418,17 +418,15 @@ { \msg_warning:nnn { citation-style-language } { bibliography / empty } } } { - \tl_if_empty:NTF \l__csl_bibliography_tl - { - \file_if_exist_input:nF { \jobname .bbl } - { - \msg_warning:nnx { citation-style-language } { file / non-exist} { \jobname .bbl } - } - } - { \exp_args:NV \__csl_print_bibliography:n \l__csl_bibliography_tl } + \tl_if_empty:NTF \g__csl_bibliography_tl + { \msg_warning:nnn { citation-style-language } { bibliography / empty } } + { \exp_args:NV \__csl_print_bibliography:n \g__csl_bibliography_tl } } } +\msg_new:nnn { citation-style-language } { bibliography / empty } + { The~ bibliography~ is~ empty. } + \cs_new:Npn \__csl_print_bibliography:n #1 { \begin { thebibliography } @@ -436,12 +434,6 @@ \end { thebibliography } } -\msg_new:nnn { citation-style-language } { bibliography / empty } - { The~ bibliography~ is~ empty. } - -\msg_new:nnn { citation-style-language } { file / non-exist } - { No~ file~ #1. } - \tl_new:N \l__csl_style_tl \clist_new:N \l__csl_bib_resources_clist @@ -483,7 +475,7 @@ \bool_new:N \l__csl_engine_initialized_bool -\prop_set_from_keyval:Nn \l__csl_babel_locale_mapping_prop +\prop_set_from_keyval:Nn \l__csl_language_code_map_prop { acadian = fr-CA, american = en-US, @@ -600,10 +592,27 @@ welsh = cy-GB, } -\tl_new:N \l__csl_bibliography_tl -\tl_new:N \l__csl_bibliography_setup_tl +\tl_new:N \g__csl_bibliography_tl +\tl_new:N \g__csl_bibliography_setup_tl + + +\AtBeginDocument { \__csl_at_begin_document_hook: } + + +\cs_new:Npn \__csl_at_begin_document_hook: + { + \__csl_write_aux_info: + \sys_if_engine_luatex:TF + { + \__csl_initialize_lua_module: + } + { + \__csl_load_bbl: + } + } + -\AtBeginDocument +\cs_new:Npn \__csl_write_aux_info: { \tl_if_empty:NTF \l__csl_style_tl { \tl_set_eq:NN \l__csl_style_tl \g__csl_aux_bibstyle_tl } @@ -615,44 +624,35 @@ { \clist_use:Nn \l__csl_bib_resources_clist { , } } } \__csl_write_aux_csl_options: - \sys_if_engine_luatex:T - { - \lua_now:e - { - csl.init( - "\l__csl_style_tl", - "\l__csl_bib_resources_clist", - "\l__csl_locale_tl" - ) - } - \str_if_eq:eeT { \lua_now:n { tex.print(csl.initialized) } } { true } - { \bool_set_true:N \l__csl_engine_initialized_bool } - \__csl_get_style_class: - \@ifpackageloaded { hyperref } - { \lua_now:n { csl.enable_linking() } } - { } - } - % Load .bbl at the beginning of document to save one pass of latex. - % In this procedure, the \cslcite command is processed and the contents - % of `thebibliography` is stored into \l__csl_bibliography_tl. - \group_begin: - \RenewDocumentCommand \cslsetup { m } - { \tl_set:Nn \l__csl_bibliography_setup_tl {#1} } - \RenewDocumentEnvironment { thebibliography } { m +b } - { \tl_set:Nn \l__csl_bibliography_tl { {#1} #2 } } - { } - \file_if_exist_input:n { \jobname .bbl } - \group_end: } \cs_new:Npn \__csl_write_aux_bibstyle:n #1 { \if@filesw - \iow_now:Nn \@auxout { \bibstyle {#1} } + \iow_now:Nx \@auxout { \token_to_str:N \bibstyle {#1} } \fi } +\cs_new:Npn \__csl_initialize_lua_module: + { + \lua_now:e + { + csl.init( + "\l__csl_style_tl", + "\l__csl_bib_resources_clist", + "\l__csl_locale_tl" + ) + } + \str_if_eq:eeT { \lua_now:n { tex.print(csl.initialized) } } { true } + { \bool_set_true:N \l__csl_engine_initialized_bool } + \__csl_get_style_class: + \@ifpackageloaded { hyperref } + { \lua_now:n { csl.enable_linking() } } + { } + } + + \str_new:N \l__csl_style_class_str % In-text (including numeric or author-date) or note style \bool_new:N \l__csl_note_style_bool @@ -677,7 +677,7 @@ { \tl_if_exist:NT \bbl@main@language { - \prop_get:NVN \l__csl_babel_locale_mapping_prop \bbl@main@language + \prop_get:NVN \l__csl_language_code_map_prop \bbl@main@language \l__csl_locale_tl } } @@ -696,7 +696,7 @@ \if@filesw \iow_now:Nx \@auxout { - \exp_not:N \csloptions + \token_to_str:N \csloptions { \clist_use:Nn \l__csl_options_clist { , } } } \fi @@ -704,6 +704,31 @@ } +% Load .bbl at the beginning of document to save one pass of latex. +% In this procedure, the \cslcite command is processed and the contents +% of `thebibliography` is stored into \g__csl_bibliography_tl. +\cs_new:Npn \__csl_load_bbl: + { + \group_begin: + \RenewDocumentCommand \cslsetup { m } + { \tl_set:Nn \g__csl_bibliography_setup_tl {##1} } + \RenewDocumentEnvironment { thebibliography } { m +b } + { \tl_gset:Nn \g__csl_bibliography_tl { {##1} ##2 } } + { } + % The \@input@ prints "No file ....bbl" in the .log file from which + % the latexmk decides to run $bibtex or not. + \@input@ { \jobname .bbl } + % \file_if_exist_input:nF { \jobname .bbl } + % { + % \msg_warning:nnx { citation-style-language } { file / non-exist} { \jobname .bbl } + % } + \group_end: + } + +% \msg_new:nnn { citation-style-language } { file / non-exist } +% { No~ file~ #1. } + + \DeclareDocumentCommand \bibliographystyle { m } { \__csl_if_preamble:F @@ -734,7 +759,7 @@ \cs_new:Npn \__csl_write_aux_bibdata:n #1 { \if@filesw - \iow_now:Nn \@auxout { \bibdata {#1} } + \iow_now:Nx \@auxout { \token_to_str:N \bibdata {#1} } \fi } |