diff options
40 files changed, 4260 insertions, 2167 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 68afabb179f..e0042de33e2 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,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v0.4.1] - 2023-04-12 + +### Added + +- Add support for `crossref` feature in BibTeX database. +- Add `\printbibheading` command. +- Add options `heading`, `label`, and `title` in `\printbibliography` ([#31](https://github.com/zepinglee/citeproc-lua/issues/31)). +- Add `prenote` and `postnote` options in `\printbibliography`. + +### Fixed + +- Remove UTF-8 BOM from loaded files (fix [#34](https://github.com/zepinglee/citeproc-lua/issues/34)). + ## [v0.4.0] - 2023-04-02 ### Added @@ -101,7 +114,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.4.0...HEAD +[Unreleased]: https://github.com/zepinglee/citeproc-lua/compare/v0.4.1...HEAD +[v0.4.1]: https://github.com/zepinglee/citeproc-lua/compare/v0.4.0...0.4.1 [v0.4.0]: https://github.com/zepinglee/citeproc-lua/compare/v0.3.0...0.4.0 [v0.3.0]: https://github.com/zepinglee/citeproc-lua/compare/v0.2.2...0.3.0 [v0.2.2]: https://github.com/zepinglee/citeproc-lua/compare/v0.2.1...0.2.2 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 cf2f8ebf219..0378ba3dd98 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 628e30f781a..dd275e18aa5 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 @@ -49,7 +49,7 @@ }% } -\date{2023-04-02 v0.4.0} +\date{2023-04-12 v0.4.1} \maketitle diff --git a/Master/texmf-dist/doc/man/man1/citeproc-lua.1 b/Master/texmf-dist/doc/man/man1/citeproc-lua.1 index c8fe3c3d68e..ab588bea42c 100644 --- a/Master/texmf-dist/doc/man/man1/citeproc-lua.1 +++ b/Master/texmf-dist/doc/man/man1/citeproc-lua.1 @@ -1,4 +1,4 @@ -.TH citeproc-lua 1 "0.1.1" +.TH citeproc-lua 1 "0.4.1" .SH NAME citeproc-lua \- make CSL citations and bibliography for LaTeX .SH SYNOPSIS 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 9e906d391d8..feaca70a62f 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-bibtex-data.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-data.lua index d2b374e9aae..525f4d2fb8c 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-data.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-data.lua @@ -5,3262 +5,4292 @@ return { types = { abstract = { csl = nil, + source = "biblatex-cv.dbx", }, ancienttext = { csl = "classic", + source = "sbl.dbx", }, archival = { csl = "collection", + notes = "New in CSL v1.0.2.", + source = "jurabib.bst", }, archive = { csl = "collection", + source = "gbt7714-numerical.bst", }, article = { csl = "article-journal", + notes = "May also be `article-magazine` or `article-newspaper` depending upon the field `entrysubtype`.", + source = "bibtex", }, ["article-journal"] = { csl = "article-journal", + source = "csl", }, ["article-magazine"] = { csl = "article-magazine", + source = "csl", }, ["article-newspaper"] = { csl = "article-newspaper", + source = "csl", }, artifactdataset = { csl = "dataset", + source = "ACM-Reference-Format.bst", }, artifactsoftware = { csl = "software", + source = "ACM-Reference-Format.bst", }, artwork = { csl = "graphic", + source = "biblatex", }, atlas = { csl = nil, + source = "ametsoc2014.bst", }, audio = { csl = "song", + notes = "CSL's `song` can be used for any audio recording (not only music).", + source = "biblatex", }, bachelor = { csl = "thesis", + source = "dlfltxbbibtex.bst", }, bibnote = { csl = nil, + notes = "Not supported.", + source = "biblatex", }, bill = { csl = "bill", + source = "csl", }, book = { csl = "book", + source = "bibtex", }, bookinarticle = { csl = nil, + source = "bookinother.dbx", }, bookinbook = { csl = "chapter", + source = "biblatex", }, bookincollection = { csl = nil, + source = "bookinother.dbx", }, bookininarticle = { csl = nil, + source = "bookinother.dbx", }, bookininbook = { csl = nil, + source = "bookinother.dbx", }, bookinincollection = { csl = nil, + source = "bookinother.dbx", }, bookininproceedings = { csl = nil, + source = "bookinother.dbx", }, bookininreference = { csl = nil, + source = "bookinother.dbx", }, bookinjournal = { csl = nil, + source = "bookinother.dbx", }, bookinmathesis = { csl = nil, + source = "bookinother.dbx", }, bookinphdthesis = { csl = nil, + source = "bookinother.dbx", }, bookinproceedings = { csl = nil, + source = "bookinother.dbx", }, bookinreference = { csl = nil, + source = "bookinother.dbx", }, bookinthesis = { csl = nil, + source = "bookinother.dbx", }, booklet = { csl = "pamphlet", + source = "bibtex", }, broadcast = { csl = "broadcast", + source = "csl", }, brochure = { csl = "pamphlet", + source = "thesnumb.bst", }, catalog = { csl = nil, + source = "arthistory-bonn.dbx", }, cconference = { csl = "paper-conference", + source = "seuthesis.bst", }, chapter = { csl = "chapter", + source = "csl", }, classic = { csl = "classic", + source = "csl", }, classictext = { csl = "classic", + source = "sbl.dbx", }, codefragment = { csl = "software", + source = "software.dbx", }, collection = { csl = "book", + source = "biblatex", }, comment = { csl = nil, + notes = "Special entry type for Scribe compatibility", + source = "bibtex", }, commentary = { csl = "book", + notes = "Not supported.", + source = "biblatex", }, commented = { csl = nil, + source = "jurabib.bst", }, committee = { csl = nil, + source = "biblatex-cv.dbx", }, conference = { + alias = "inproceedings", csl = "paper-conference", + source = "bibtex", }, conferencepaper = { csl = "paper-conference", + source = "sbl.dbx", }, constitution = { csl = "legislation", + source = "apa.dbx", }, ctan = { csl = "software", + source = "tugboat.bst", }, customa = { csl = nil, + source = "biblatex", }, customb = { csl = nil, + source = "biblatex", }, customc = { csl = nil, + source = "biblatex", }, customd = { csl = nil, + source = "biblatex", }, custome = { csl = nil, + source = "biblatex", }, customf = { csl = nil, + source = "biblatex", }, data = { csl = nil, + source = "apa6.dbx", }, database = { csl = "dataset", + source = "gbt7714-numerical.bst", }, dataset = { csl = "dataset", + source = "biblatex", }, degree = { csl = nil, + source = "biblatex-cv.dbx", }, dictionary = { csl = "book", + source = "vancouver.bst", }, docthesis = { csl = "thesis", + source = "gost2003.bst", }, document = { csl = "document", + source = "csl", }, electronic = { + alias = "online", csl = "webpage", + source = "biblatex", }, entry = { csl = "entry", + source = "csl", }, ["entry-dictionary"] = { csl = "entry-dictionary", + source = "csl", }, ["entry-encyclopedia"] = { csl = "entry-encyclopedia", + source = "csl", }, eulegislation = { csl = "legislation", + source = "bath.bst", }, event = { csl = "event", + source = "csl", }, exhibcatalog = { csl = nil, + source = "arthistory-bonn.dbx", }, figure = { csl = "figure", + source = "csl", }, footnote = { csl = nil, + source = "apsrev4-2.bst", }, funding = { csl = nil, + source = "biblatex-cv.dbx", }, game = { csl = "software", + source = "ACM-Reference-Format.bst", }, gitcommit = { csl = nil, + source = "gitlog.dbx", }, govpub = { csl = "regulation", + source = "thesnumb.bst", }, graphic = { csl = "graphic", + source = "csl", }, habthesis = { csl = "thesis", + source = "bestpapers-export.bst", }, heading = { csl = nil, + source = "bookdb.bst", }, hearing = { csl = "hearing", + source = "csl", }, hidden = { csl = nil, + source = "abntex2-alf.bst", }, image = { csl = "graphic", + source = "biblatex", }, inarticle = { csl = nil, + source = "bookinother.dbx", }, inaudio = { csl = nil, + source = "oxalph.dbx", }, inbook = { csl = "chapter", + source = "bibtex", }, incatalog = { csl = nil, + source = "arthistory-bonn.dbx", }, incollection = { csl = "chapter", + source = "bibtex", }, incommentary = { csl = nil, + source = "sbl.dbx", }, inexhibcatalog = { csl = nil, + source = "arthistory-bonn.dbx", }, ininarticle = { csl = nil, + source = "bookinother.dbx", }, ininbook = { csl = nil, + source = "bookinother.dbx", }, inincollection = { csl = nil, + source = "bookinother.dbx", }, ininproceedings = { csl = nil, + source = "bookinother.dbx", }, ininreference = { csl = nil, + source = "bookinother.dbx", }, inlexicon = { csl = nil, + source = "sbl.dbx", }, inloosecollection = { csl = "chapter", + source = "resphilosophica.bst", }, inmathesis = { csl = nil, + source = "bookinother.dbx", }, inmovie = { csl = nil, + source = "oxalph.dbx", }, inmusic = { csl = nil, + source = "oxalph.dbx", }, inphdthesis = { csl = nil, + source = "bookinother.dbx", }, inpress = { csl = "article", + notes = "Use for preprints, working papers, and similar works posted on a platform where some level of persistence or stewardship is expected (e.g. arXiv or other preprint repositories, working paper series).", + source = "bjnano.bst", }, inproceedings = { csl = "paper-conference", + source = "bibtex", }, inreference = { csl = "entry", + notes = "May also be `entry`, `entry-dictionary` or `entry-encyclopedia`.", + source = "biblatex", }, inserialcollection = { csl = nil, + source = "asmejour.bst", }, internet = { csl = "webpage", + source = "IEEEtran.bst", }, interview = { csl = "interview", + source = "csl", }, inthesis = { csl = nil, + source = "bookinother.dbx", }, invideo = { csl = nil, + source = "oxalph.dbx", }, journalpart = { csl = nil, + source = "abntex2-alf.bst", }, journals = { csl = "periodical", + source = "bestpapers-export.bst", }, jurisdiction = { csl = "legal_case", + notes = '"Court decisions, court recordings, and similar things."', + source = "biblatex", }, jurthesis = { csl = "thesis", + source = "jurabib.bst", }, legadminmaterial = { csl = "regulation", + source = "apa.dbx", }, legal = { csl = "treaty", + notes = '"Legal documents such as treaties."', + source = "biblatex", }, legal_case = { csl = "legal_case", + source = "csl", }, legislation = { csl = "legislation", + notes = '"Laws, bills, legislative proposals, and similar things." May also be `bill`', + source = "biblatex", }, legmaterial = { csl = "legislation", + source = "apa.dbx", }, letter = { csl = "personal_communication", + source = "biblatex", }, letters = { csl = "personal_communication", + source = "apa6.dbx", }, lexicon = { csl = "book", + source = "jurabib.bst", }, majorthesis = { csl = "thesis", + source = "achicago.bst", }, manual = { csl = "report", + notes = "CSL's `report` is also used for manuals and similar technical documentation (e.g. a software, instrument, or test manual).", + source = "bibtex", }, manuscript = { csl = "manuscript", + source = "manuscripts-shared.dbx", }, map = { csl = "map", + source = "vancouver.bst", }, mastersthesis = { + alias = "thesis", csl = "thesis", + source = "bibtex", }, masterthesis = { csl = "thesis", + source = "asaetr.bst", }, minorthesis = { csl = "thesis", + source = "achicago.bst", }, misc = { csl = "document", + notes = "New in CSL v1.0.2.", + source = "bibtex", }, mlasource = { csl = nil, + source = "mla.dbx", }, monograph = { csl = "book", + source = "gbt7714-numerical.bst", }, monography = { csl = "book", + source = "abntex2-alf.bst", }, motion_picture = { csl = "motion_picture", + source = "csl", }, movie = { csl = "motion_picture", + source = "biblatex", }, music = { csl = "song", + source = "biblatex", }, musical_score = { csl = "musical_score", + source = "csl", }, mvbook = { csl = "book", + source = "biblatex", }, mvcollection = { csl = "book", + source = "biblatex", }, mvcommentary = { csl = nil, + source = "sbl.dbx", }, mvlexicon = { csl = nil, + source = "sbl.dbx", }, mvproceedings = { csl = "book", + source = "biblatex", }, mvreference = { csl = "book", + source = "biblatex", }, nameonly = { csl = nil, + source = "apa.dbx", }, news = { csl = "article-newspaper", + source = "seuthesix.bst", }, newsarticle = { csl = "article-newspaper", + source = "apa6.dbx", }, newspaper = { csl = "article-newspaper", + source = "gbt7714-numerical.bst", }, online = { csl = "webpage", + source = "biblatex", }, other = { csl = nil, + source = "bjnano.bst", }, pamphlet = { csl = "pamphlet", + source = "csl", }, ["paper-conference"] = { csl = "paper-conference", + source = "csl", }, patent = { csl = "patent", + source = "biblatex", }, performance = { csl = "performance", + notes = "New in CSL v1.0.2.", + source = "biblatex", }, periodical = { csl = "periodical", + notes = "New in CSL v1.0.2.", + source = "biblatex", }, personal_communication = { csl = "personal_communication", + source = "csl", }, phdthesis = { + alias = "thesis", csl = "thesis", + source = "bibtex", }, post = { csl = "post", + source = "csl", }, ["post-weblog"] = { csl = "post-weblog", + source = "csl", }, preamble = { csl = nil, + notes = "Special entry type for inserting commands or text in the bbl", + source = "bibtex", }, preprint = { csl = "article", + notes = "Use for preprints, working papers, and similar works posted on a platform where some level of persistence or stewardship is expected (e.g. arXiv or other preprint repositories, working paper series).", + source = "gbt7714-numerical.bst", }, presentation = { csl = "speech", + notes = "A speech or other presentation (e.g. a paper, talk, poster, or symposium at a conference).", + source = "apsrev4-2.bst", }, proceedings = { csl = "book", + source = "bibtex", }, program = { csl = "software", + source = "ChemCommun.bst", }, reference = { csl = "book", + source = "biblatex", }, regulation = { csl = "regulation", + source = "csl", }, report = { csl = "report", + source = "biblatex", }, repository = { csl = nil, + source = "quantum.bst", }, review = { csl = "review", + notes = '"A more specific variant of the `@article` type"', + source = "biblatex", }, ["review-book"] = { csl = "review-book", + source = "csl", }, school = { csl = nil, + source = "biblatex-cv.dbx", }, seminarpaper = { csl = nil, + source = "sbl.dbx", }, set = { csl = nil, + notes = "Not supported.", + source = "biblatex", }, setup = { csl = nil, + source = "bestpapers-export.bst", }, software = { csl = "software", + notes = "New in CSL v1.0.2.", + source = "biblatex", }, softwaremodule = { csl = "software", + source = "software.dbx", }, softwareversion = { csl = nil, + source = "software.dbx", }, song = { csl = "song", + source = "csl", }, speech = { csl = "speech", + source = "csl", }, standard = { csl = "standard", + notes = "New in CSL v1.0.2.", + source = "biblatex", }, string = { csl = nil, + notes = "Special entry type for defining abbreviations", + source = "bibtex", }, student = { csl = nil, + source = "biblatex-cv.dbx", }, suppbook = { csl = "chapter", + notes = 'lossy mapping; "Supplemental material in a `@book`. This type is closely related to the @inbook entry type. While `@inbook` is primarily intended for a part of a book with its own title (e. g., a single essay in a collection of essays by the same author), this type is provided for elements such as prefaces, introductions, forewords, afterwords, etc. which often have a generic title only. Style guides may require such items to be formatted differently from other `@inbook` items."', + source = "biblatex", }, suppcollection = { csl = "chapter", + notes = "lossy mapping; see `suppbook`", + source = "biblatex", }, suppperiodical = { csl = "article", + notes = "see `article`", + source = "biblatex", }, talk = { csl = "speech", + source = "archaeologie.dbx", }, teaching = { csl = nil, + source = "biblatex-cv.dbx", }, techreport = { + alias = "report", csl = "report", + source = "bibtex", }, techstandard = { csl = "standard", + notes = "New in CSL v1.0.2.", + source = "udesoftec.bst", }, thesis = { csl = "thesis", + source = "biblatex", }, treaty = { csl = "treaty", + source = "csl", }, uklegislation = { csl = "legislation", + source = "bath.bst", }, unpublished = { csl = "manuscript", + notes = "For unpublished works not made widely available or only hosted on personal websites, use manuscript", + source = "bibtex", }, video = { csl = "motion_picture", + source = "biblatex", }, webpage = { csl = "webpage", + source = "IEEEtran.bst", }, website = { csl = "webpage", + source = "quantum.bst", }, www = { + alias = "online", csl = "webpage", + source = "biblatex", }, xdata = { csl = nil, + notes = 'special item type: "`@xdata` entries hold data which may be inherited by other entries using the xdata field. Entries of this type only serve as data containers; they may not be cited or added to the bibliography."', + source = "biblatex", }, }, fields = { abstract = { csl = "abstract", + source = "biblatex", type = "literal", }, abstractloc = { csl = nil, + source = "apa6.dbx", type = "literal", }, abstracturl = { csl = nil, + source = "apa6.dbx", type = "verbatim", }, accessed = { csl = "accessed", + source = "csl", }, account = { csl = nil, + source = "address-html.bst", }, acronym = { csl = nil, + source = "export.bst", type = "literal", }, actor = { csl = "performer", + source = "fiwi.dbx", type = "name", }, add = { csl = nil, + source = "figbib.bst", }, add1 = { csl = nil, + source = "figbib1.bst", }, addendum = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, address = { + alias = "location", csl = "publisher-place", + source = "bibtex", type = "literal", }, adsurl = { csl = nil, + source = "mnras.bst", }, advisor = { csl = nil, + source = "ACM-Reference-Format.bst", type = "name", }, afterword = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "name", }, alternatetitle = { csl = nil, + source = "fiwi.dbx", type = "literal", }, alternatetitlescript = { csl = nil, + source = "fiwi.dbx", type = "literal", }, amendment = { csl = nil, + source = "apa.dbx", type = "literal", }, amount = { csl = nil, + source = "biblatex-cv.dbx", type = "integer", }, annotate = { csl = "note", + source = "apacite.bst", }, annotation = { csl = "note", + notes = "Descriptive text or notes about an item (e.g. in an annotated bibliography)", + source = "biblatex", type = "literal", }, annotator = { csl = nil, + source = "biblatex", type = "name", }, annote = { + alias = "annotation", csl = "note", + source = "biblatex", type = "literal", }, annotelanguage = { csl = nil, + source = "bababbr3-fl.bst", }, anonstring = { csl = nil, + source = "aefkw.dbx", type = "name", }, appentry = { csl = nil, + source = "apa.dbx", type = "literal", }, applicant = { csl = nil, + source = "seuthesix.bst", }, arachne = { csl = nil, + source = "archaeologie.dbx", type = "verbatim", }, archive = { csl = "archive", + source = "apsrev4-2.bst", }, ["archive-place"] = { csl = "archive-place", + source = "csl", }, archive_collection = { csl = "archive_collection", + source = "csl", }, archive_location = { csl = "archive_location", + source = "csl", }, archiveprefix = { + alias = "eprinttype", csl = "archive", + source = "biblatex", type = "literal", }, archname = { csl = "archive", + source = "jurabib.bst", }, arthist = { csl = nil, + source = "arthistory-bonn.dbx", type = "integer", }, arthistdate = { csl = nil, + source = "arthistory-bonn.dbx", type = "date", }, article = { csl = nil, + notes = "Should be prepended to the section field (e.g., article I section 3)", + source = "apa.dbx", type = "literal", }, articleno = { csl = nil, + source = "ACM-Reference-Format.bst", type = "literal", }, arxiv = { csl = nil, + source = "aomalpha.bst", }, assignee = { csl = nil, + source = "vancouver.bst", }, author = { csl = "author", + source = "bibtex", type = "name", }, authoraddon = { csl = nil, + source = "oxalph.dbx", type = "name", }, authorcountry = { csl = nil, + source = "gost2003.bst", type = "literal", }, authorfa = { csl = nil, + source = "asa-fa.bst", }, authority = { csl = "authority", + source = "csl", }, authortype = { csl = nil, + source = "biblatex", type = "key", }, ["available-date"] = { csl = "available-date", + source = "csl", }, bibsource = { csl = nil, + source = "export.bst", }, biburl = { csl = nil, + source = "export.bst", }, binding = { csl = nil, + source = "bookdb.bst", }, birthday = { csl = nil, + source = "adrbirthday.bst", }, birthyear = { csl = nil, + source = "address-html.bst", }, blogsubtitle = { csl = nil, + source = "windycity.dbx", type = "literal", }, blogtitle = { csl = "title", + source = "windycity.dbx", type = "literal", }, blogtitleaddon = { csl = nil, + source = "windycity.dbx", type = "literal", }, book = { csl = nil, + source = "biblatex-gost.dbx", type = "range", }, bookaddress = { csl = "publisher-place", + source = "apsrev4-2.bst", }, bookafterword = { csl = nil, + source = "biblatex-gost.dbx", type = "name", }, bookannotator = { csl = nil, + source = "biblatex-gost.dbx", type = "name", }, bookauthor = { csl = "container-author", + source = "biblatex", type = "name", }, bookauthortype = { csl = nil, + source = "windycity.dbx", type = "literal", }, bookbooksubtitle = { csl = nil, + source = "windycity.dbx", type = "literal", }, bookbooktitle = { csl = nil, + source = "windycity.dbx", type = "literal", }, bookbooktitleaddon = { csl = nil, + source = "windycity.dbx", type = "literal", }, bookbooktitlekey = { csl = nil, + source = "windycity.dbx", type = "key", }, bookbookvolume = { csl = nil, + source = "windycity.dbx", type = "literal", }, bookcommentator = { csl = nil, + source = "biblatex-gost.dbx", type = "name", }, bookcredits = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, bookeditor = { csl = "editor", + source = "bookinother.dbx", type = "name", }, bookforeword = { csl = nil, + source = "biblatex-gost.dbx", type = "name", }, bookineditor = { csl = nil, + source = "bookinother.dbx", type = "name", }, bookintroduction = { csl = nil, + source = "biblatex-gost.dbx", type = "name", }, booklanguage = { csl = nil, + source = "gost2003.bst", }, bookoriglanguage = { csl = nil, + source = "biblatex-gost.dbx", type = "key", }, bookpages = { csl = nil, + source = "ACM-Reference-Format.bst", }, bookpagination = { csl = nil, + source = "biblatex", type = "key", }, books = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, booksubtitle = { csl = nil, + source = "biblatex", type = "literal", }, booktitle = { csl = "container-title", + source = "bibtex", type = "literal", }, booktitleaddon = { csl = nil, + source = "biblatex", type = "literal", }, booktitlekey = { csl = nil, + source = "windycity.dbx", type = "key", }, booktitlenote = { csl = nil, + source = "aefkw.dbx", type = "literal", }, booktranslator = { csl = "translator", + source = "biblatex-gost.dbx", type = "name", }, bookvolume = { csl = nil, + source = "windycity.dbx", type = "literal", }, bookyear = { csl = nil, + source = "windycity.dbx", type = "literal", }, ["call-number"] = { csl = "call-number", + source = "csl", }, caption = { csl = nil, + source = "figbib.bst", }, caption1 = { csl = nil, + source = "figbib1.bst", }, cartographer = { csl = nil, + source = "vancouver.bst", }, casenumber = { csl = nil, + source = "bath.bst", }, catalog = { csl = nil, + source = "oxalph.dbx", type = "literal", }, category = { csl = nil, + source = "bookdb.bst", }, cellular = { csl = nil, + source = "address-html.bst", }, chair = { csl = "chair", + source = "apacite.bst", }, chapter = { csl = "chapter-number", + source = "bibtex", type = "literal", }, ["chapter-number"] = { csl = "chapter-number", + source = "csl", }, citation = { csl = nil, + source = "apa.dbx", type = "literal", }, citedate = { csl = nil, + source = "seuthesis.bst", }, city = { csl = nil, + source = "ACM-Reference-Format.bst", }, classes = { csl = nil, + source = "biblatex-cv.dbx", type = "entrykey", }, claves = { csl = nil, + source = "claves.dbx", type = "literal", }, claves_definition = { csl = nil, + source = "claves.dbx", type = "literal", }, code = { csl = nil, + source = "quantum.bst", }, coden = { csl = nil, + source = "is-abbrv.bst", }, collaboration = { csl = nil, + source = "apsrev4-2.bst", type = "literal", }, collator = { csl = nil, + source = "bookdb.bst", }, collection = { csl = nil, + source = "bath.dbx", type = "literal", }, ["collection-editor"] = { csl = "collection-editor", + source = "csl", }, ["collection-number"] = { csl = "collection-number", + source = "csl", }, ["collection-title"] = { csl = "collection-title", + source = "csl", }, columns = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, commentator = { csl = nil, + source = "biblatex", type = "name", }, commit = { csl = nil, + source = "quantum.bst", }, commithash = { csl = nil, + source = "gitlog.dbx", type = "literal", }, committee = { csl = nil, + source = "biblatex-cv.dbx", type = "name", }, compiler = { csl = "compiler", + source = "gost2003.bst", }, composer = { csl = "composer", + source = "csl", }, concentration = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, condition = { csl = nil, + source = "bookdb.bst", }, ["conference-location"] = { csl = nil, + source = "abntex2-alf.bst", }, ["conference-number"] = { csl = nil, + source = "abntex2-alf.bst", }, ["conference-year"] = { csl = nil, + source = "abntex2-alf.bst", }, ["container-author"] = { csl = "container-author", + source = "csl", }, ["container-title"] = { csl = "container-title", + source = "csl", }, ["container-title-short"] = { csl = "container-title-short", + source = "csl", }, contents = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, contributor = { csl = "contributor", + source = "csl", }, contributora = { csl = nil, + source = "mla.dbx", type = "literal", }, contributorb = { csl = nil, + source = "mla.dbx", type = "literal", }, copublisher = { csl = nil, + source = "gzt.dbx", type = "literal", }, copy = { csl = nil, + source = "bookdb.bst", }, country = { csl = "jurisdiction", + source = "adrbirthday.bst", }, credits = { csl = nil, + source = "gost2003.bst", type = "literal", }, crossref = { csl = nil, + notes = "Inherits data from a parent entry.", + source = "biblatex", type = "entrykey", }, curator = { csl = "curator", + source = "csl", }, currency = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, custom = { csl = "custom", + source = "csl", }, dataset = { csl = nil, + source = "apalike-ejor.bst", }, date = { csl = "issued", + source = "biblatex", type = "date", }, ["date+an"] = { csl = nil, + source = "aefkw.dbx", type = "literal", }, datea = { csl = nil, + source = "mla.dbx", type = "literal", }, dateaddon = { csl = nil, + source = "iso-alphabetic.dbx", type = "literal", }, dateb = { csl = nil, + source = "mla.dbx", type = "literal", }, datetype = { csl = nil, + source = "oxalph.dbx", type = "literal", }, dating = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, day = { csl = nil, + source = "apacite.bst", }, dayfiled = { csl = nil, + source = "IEEEtran.bst", }, decision = { + alias = "usera", csl = nil, + source = "biblatex-juradiss.dbx", type = "literal", }, decisionname = { + alias = "userf", csl = nil, + source = "biblatex-juradiss.dbx", type = "literal", }, definition = { csl = nil, + source = "glsplain.bst", }, degree = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, degreelist = { csl = nil, + source = "biblatex-cv.dbx", type = "entrykey", }, department = { csl = nil, + source = "ametsoc2014.bst", type = "literal", }, description = { csl = nil, + source = "ChemCommun.bst", }, designator = { csl = nil, + source = "thesnumb.bst", }, dimensions = { csl = "dimensions", + source = "abntex2-alf.bst", }, director = { csl = "director", + source = "apa6.dbx", type = "name", }, dissyear = { csl = nil, + source = "jurabib.bst", }, distinctURL = { csl = nil, + source = "acmdatamodel.dbx", type = "literal", }, division = { csl = "division", + source = "csl", }, doi = { csl = "DOI", + source = "biblatex", type = "verbatim", }, dticnumber = { csl = nil, + source = "thesnumb.bst", }, dummy = { csl = nil, + source = "expcites.bst", }, duration = { csl = nil, + source = "fiwi.dbx", type = "literal", }, durationtype = { csl = nil, + source = "fiwi.dbx", type = "literal", }, edition = { csl = "edition", + source = "bibtex", type = "literal", }, editioncredits = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, editor = { csl = "editor", + source = "bibtex", type = "name", }, editora = { csl = nil, + source = "biblatex", type = "name", }, editoraaddon = { csl = nil, + source = "windycity.dbx", type = "literal", }, editoraddon = { csl = nil, + source = "oxalph.dbx", type = "name", }, editoratype = { csl = nil, + source = "biblatex", type = "key", }, editorb = { csl = nil, + source = "biblatex", type = "name", }, editorbtype = { csl = nil, + source = "biblatex", type = "key", }, editorc = { csl = nil, + source = "biblatex", type = "name", }, editorctype = { csl = nil, + source = "biblatex", type = "key", }, ["editorial-director"] = { csl = "editorial-director", + source = "csl", }, editortype = { csl = nil, + source = "biblatex", type = "key", }, eid = { csl = nil, + source = "biblatex", type = "literal", }, email = { csl = nil, + source = "adrbirthday.bst", }, endbookyear = { csl = nil, + source = "windycity.dbx", type = "literal", }, endnumber = { csl = nil, + source = "seuthesis.bst", }, endvolume = { csl = nil, + source = "seuthesis.bst", }, endyear = { csl = nil, + source = "seuthesis.bst", }, englishabstract = { csl = nil, + source = "gzt.dbx", type = "literal", }, englishtitle = { csl = nil, + source = "apacite.bst", }, entryset = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "entrykey", }, entrysubtype = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, epilog = { csl = nil, + source = "iopart-num.bst", }, eprint = { csl = nil, + notes = 'Mapped to `PMID` if `eprinttype` is "PubMed".', + source = "biblatex", type = "verbatim", }, eprintclass = { csl = nil, + source = "biblatex", type = "literal", }, eprintdate = { csl = nil, + source = "sbl.dbx", type = "date", }, eprintday = { csl = nil, + source = "sbl.dbx", type = "datepart", }, eprintmonth = { csl = nil, + source = "sbl.dbx", type = "datepart", }, eprints = { csl = nil, + source = "databib.bst", }, eprinttype = { csl = "archive", + source = "biblatex", type = "literal", }, eprintyear = { csl = nil, + source = "sbl.dbx", type = "datepart", }, erratumeid = { csl = nil, + source = "ChemCommun.bst", }, erratumgermanpages = { csl = nil, + source = "ChemCommun.bst", }, erratumnumpages = { csl = nil, + source = "ChemCommun.bst", }, erratumpages = { csl = nil, + source = "ChemCommun.bst", }, erratumvolume = { csl = nil, + source = "ChemCommun.bst", }, erratumyear = { csl = nil, + source = "ChemCommun.bst", }, event = { csl = "event-title", + source = "csl", }, ["event-date"] = { csl = "event-date", + source = "csl", }, ["event-place"] = { csl = "event-place", + source = "csl", }, ["event-title"] = { csl = "event-title", + source = "csl", }, eventdate = { csl = "event-date", + source = "biblatex", type = "date", }, eventdatelanguage = { csl = nil, + source = "archaeologie.dbx", type = "verbatim", }, eventnumber = { csl = nil, + source = "aefkw.dbx", type = "integer", }, eventsubtitle = { csl = nil, + source = "arthistory-bonn.dbx", type = "literal", }, eventtitle = { csl = "event-title", + notes = "Supercedes `event` in CSL v1.0.2.", + source = "biblatex", type = "literal", }, eventtitleaddon = { csl = nil, + source = "biblatex", type = "literal", }, eventtype = { csl = nil, + source = "aefkw.dbx", type = "literal", }, eventyear = { csl = nil, + source = "bath.bst", }, execdirector = { csl = "director", + source = "apa.dbx", type = "name", }, execproducer = { csl = "executive-producer", + source = "apa.dbx", type = "name", }, execute = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "code", }, ["executive-producer"] = { csl = "executive-producer", + source = "csl", }, exhibfirstdate = { csl = "event-date", + source = "arthistory-bonn.dbx", type = "date", }, exhibfirstlocation = { csl = "event-place", + source = "arthistory-bonn.dbx", type = "literal", }, exhibfirstmuseum = { csl = nil, + source = "arthistory-bonn.dbx", type = "literal", }, exhibseconddate = { csl = nil, + source = "arthistory-bonn.dbx", type = "date", }, exhibsecondlocation = { csl = nil, + source = "arthistory-bonn.dbx", type = "literal", }, exhibsecondmuseum = { csl = nil, + source = "arthistory-bonn.dbx", type = "literal", }, exhibthirddate = { csl = nil, + source = "arthistory-bonn.dbx", type = "date", }, exhibthirdlocation = { csl = nil, + source = "arthistory-bonn.dbx", type = "literal", }, exhibthirdmuseum = { csl = nil, + source = "arthistory-bonn.dbx", type = "literal", }, faddress = { csl = nil, + source = "achicago.bst", }, fakeset = { csl = nil, + source = "biblatex.bst", }, fax = { csl = nil, + source = "adrbirthday.bst", }, festschrift = { csl = nil, + source = "aefkw.dbx", type = "name", }, festschriftaddon = { csl = nil, + source = "aefkw.dbx", type = "literal", }, file = { csl = nil, + source = "biblatex", type = "verbatim", }, firstkey = { csl = nil, + source = "apacite.bst", }, fjournal = { csl = nil, + source = "ijmart.bst", }, flanguage = { csl = nil, + source = "achicago.bst", }, font = { csl = nil, + source = "nederlands.bst", }, foreword = { csl = nil, + source = "biblatex", type = "name", }, founder = { csl = nil, + source = "jurabib.bst", }, fpublisher = { csl = nil, + source = "achicago.bst", }, frenchabstract = { csl = nil, + source = "gzt.dbx", type = "literal", }, ftitle = { csl = nil, + source = "achicago.bst", }, fulleventdate = { csl = nil, + source = "aefkw.dbx", type = "date", }, funder = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, furtherresp = { csl = nil, + source = "abntex2-alf.bst", }, fyear = { csl = nil, + source = "achicago.bst", }, gender = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, genre = { csl = "genre", + source = "csl", }, germanpages = { csl = nil, + source = "ChemCommun.bst", }, gpa = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, group = { csl = nil, + source = "glsplain.bst", }, guest = { csl = "guest", + source = "csl", }, hal_id = { csl = nil, + source = "software.dbx", type = "verbatim", }, hal_version = { csl = "version", + source = "software.dbx", type = "verbatim", }, handle = { csl = nil, + source = "windycity.dbx", type = "literal", }, heading = { csl = nil, + source = "glsplain.bst", type = "literal", }, hereafter = { csl = nil, + source = "opcit.bst", }, holder = { csl = nil, + source = "biblatex", type = "name", }, honors = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, host = { csl = "host", + source = "csl", }, howcited = { csl = nil, + source = "jox.bst", }, howpublished = { csl = nil, + notes = "Check if a URL is contained.", + source = "bibtex", type = "literal", }, hyphenation = { + alias = "langid", csl = "language", + source = "biblatex", type = "literal", }, ids = { csl = nil, + source = "biblatex", type = "entrykey", }, illustrated = { csl = nil, + source = "abntex2-alf.bst", }, illustrations = { csl = nil, + source = "bookdb.bst", }, illustrator = { csl = "illustrator", + source = "achicago.bst", }, impactfactor = { csl = nil, + source = "publist.dbx", type = "literal", }, inafterword = { csl = nil, + source = "archaeologie.dbx", type = "name", }, inannotator = { csl = nil, + source = "archaeologie.dbx", type = "name", }, incommentator = { csl = nil, + source = "archaeologie.dbx", type = "name", }, indexsorttitle = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, indextitle = { csl = nil, + source = "biblatex", type = "literal", }, ineditor = { csl = nil, + source = "archaeologie.dbx", type = "name", }, inforeword = { csl = nil, + source = "archaeologie.dbx", type = "name", }, inintroduction = { csl = nil, + source = "archaeologie.dbx", type = "name", }, institution = { csl = "publisher", + source = "bibtex", type = "literal", }, interviewee = { csl = nil, + source = "gzt.dbx", type = "name", }, interviewer = { csl = "interviewer", + source = "csl", }, intranslator = { csl = nil, + source = "archaeologie.dbx", type = "name", }, introducedin = { csl = nil, + source = "software.dbx", type = "literal", }, introduction = { csl = nil, + source = "biblatex", type = "name", }, intype = { csl = nil, + source = "IEEEtran.bst", }, inventor = { csl = "author", + source = "vancouver.bst", }, ipc = { csl = nil, + source = "gost2003.bst", type = "literal", }, isan = { csl = nil, + source = "biblatex", type = "literal", }, isbn = { csl = "ISBN", + source = "biblatex", type = "literal", }, ismn = { csl = nil, + source = "biblatex", type = "literal", }, ["iso-abbreviation"] = { csl = nil, + source = "abntex2-alf.bst", }, ["iso-author-punctuation"] = { csl = nil, + source = "abntex2-alf.bst", }, ["iso-date-place"] = { csl = nil, + source = "abntex2-alf.bst", }, isrn = { csl = nil, + source = "biblatex", type = "literal", }, issn = { csl = "ISSN", + source = "biblatex", type = "literal", }, issue = { csl = "issue", + source = "biblatex", type = "literal", }, issued = { csl = "issued", + source = "csl", }, issues = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, issuesubtitle = { csl = nil, + source = "biblatex", type = "literal", }, issuetitle = { - csl = nil, + csl = "volume-title", + source = "biblatex", type = "literal", }, issuetitleaddon = { csl = nil, + source = "biblatex", type = "literal", }, iswc = { csl = nil, + source = "biblatex", type = "literal", }, jfmnumber = { csl = nil, + source = "aomalpha.bst", }, jointauthor = { csl = nil, + source = "oxalph.dbx", type = "name", }, jointauthortype = { csl = nil, + source = "oxalph.dbx", type = "literal", }, journal = { + alias = "journaltitle", csl = "container-title", + source = "bibtex", type = "literal", }, journalabbreviation = { csl = "container-title-short", + source = "csl", }, journalsubtitle = { csl = nil, + notes = "It should be concatenated to the `container-title`.", + source = "biblatex", type = "literal", }, journaltie = { csl = nil, + source = "tugboat.bst", }, journaltitle = { csl = "container-title", + source = "biblatex", type = "literal", }, journaltitleaddon = { csl = nil, + source = "biblatex", type = "literal", }, journalyear = { + alias = "usere", csl = nil, + source = "biblatex-juradiss.dbx", type = "literal", }, jstor = { csl = nil, + source = "archaeologie.dbx", type = "verbatim", }, juraauthor = { csl = nil, + source = "jox.bst", }, juratitle = { csl = nil, + source = "jox.bst", }, jurisdiction = { csl = "jurisdiction", + source = "csl", }, key = { + alias = "sortkey", csl = nil, + notes = "Not supported.", + source = "bibtex", type = "literal", }, keyword = { csl = "keyword", + source = "csl", }, keywords = { csl = nil, + source = "biblatex", type = "keyword", }, label = { csl = nil, + source = "biblatex", type = "literal", }, lang = { csl = nil, + source = "hustthesis.bst", }, langid = { csl = "language", + notes = "The language id of the bibliography entry. The identifier must be a language name known to the babel/polyglossia packages. It should be converted to ISO 639-1 language code in CSL.", + source = "biblatex", type = "literal", }, langidopts = { csl = nil, + source = "biblatex", type = "literal", }, language = { - csl = nil, + csl = "language", + notes = "The `language` field in `biblatex` has no special internal meaning thus it is used only when langid is missing.", + source = "biblatex", type = "key", }, lastaccessed = { csl = "accessed", + source = "ACM-Reference-Format.bst", type = "literal", }, lastchecked = { csl = "accessed", + source = "apacite.bst", }, layer = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, lccn = { csl = nil, + source = "is-abbrv.bst", }, library = { csl = nil, + source = "biblatex", type = "literal", }, librarylocation = { csl = "archive-place", + source = "fiwi.dbx", type = "literal", }, license = { csl = "license", + source = "software.dbx", type = "literal", }, lista = { csl = nil, + source = "biblatex", type = "literal", }, listb = { csl = nil, + source = "biblatex", type = "literal", }, listc = { csl = nil, + source = "biblatex", type = "literal", }, listd = { csl = nil, + source = "biblatex", type = "literal", }, liste = { csl = nil, + source = "biblatex", type = "literal", }, listf = { csl = nil, + source = "biblatex", type = "literal", }, littype = { csl = nil, + source = "seuthesix.bst", }, location = { csl = "publisher-place", + source = "biblatex", type = "literal", }, locationa = { csl = nil, + source = "mla.dbx", type = "literal", }, locationb = { csl = nil, + source = "mla.dbx", type = "literal", }, madadurltest = { csl = nil, + source = "alpha-persian.bst", }, main = { csl = nil, + source = "figbib.bst", }, main1 = { csl = nil, + source = "figbib1.bst", }, mainauthor = { csl = nil, + source = "bookinother.dbx", type = "name", }, maineditor = { csl = nil, + source = "morenames.dbx", type = "name", }, mainsubtitle = { csl = nil, + source = "biblatex", type = "literal", }, maintainer = { csl = nil, + source = "cnltx.dbx", type = "name", }, maintitle = { csl = nil, + source = "biblatex", type = "literal", }, maintitleaddon = { csl = nil, + source = "biblatex", type = "literal", }, maintitlenote = { csl = nil, + source = "aefkw.dbx", type = "literal", }, maintranslator = { csl = nil, + source = "sbl.dbx", type = "name", }, major = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, majorcode = { csl = nil, + source = "gost2003.bst", }, marginnote = { csl = nil, + source = "abntex2-alf.bst", }, mark = { csl = nil, + source = "gbt7714-numerical.bst", }, ["max.best.papers"] = { csl = nil, + source = "bestpapers-export.bst", }, mcitetail = { csl = nil, + source = "apsrmpM.bst", }, media = { csl = "medium", + source = "gost2003.bst", type = "key", }, medium = { csl = "medium", + source = "gbt7714-numerical.bst", }, meeting = { csl = nil, + source = "amsra.bst", }, minor = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, misctitle = { csl = nil, + source = "aasjournal.bst", }, miscyear = { csl = nil, + source = "seuthesis.bst", }, mobile = { csl = nil, + source = "adrbirthday.bst", }, modifydate = { csl = nil, + source = "seuthesis.bst", }, month = { csl = nil, + notes = "Used only when `date` is empty.", + source = "bibtex", type = "literal", }, monthfiled = { csl = nil, + source = "IEEEtran.bst", }, mrnumber = { csl = nil, + source = "amsplain.bst", }, multieventdate = { csl = nil, + source = "aefkw.dbx", type = "literal", }, multivenue = { csl = nil, + source = "aefkw.dbx", type = "literal", }, name = { csl = nil, + source = "adrbirthday.bst", type = "name", }, namea = { csl = nil, + source = "biblatex", type = "name", }, nameaddon = { csl = nil, + source = "biblatex", type = "literal", }, nameatype = { csl = nil, + source = "biblatex", type = "key", }, nameb = { csl = nil, + source = "biblatex", type = "name", }, namebtype = { csl = nil, + source = "biblatex", type = "key", }, namec = { csl = nil, + source = "biblatex", type = "name", }, namectype = { csl = nil, + source = "biblatex", type = "key", }, narrator = { csl = "narrator", + source = "apa.dbx", type = "name", }, nationality = { csl = nil, + source = "IEEEtran.bst", }, nbirthday = { csl = nil, + source = "adrbirthday.bst", }, neutralcite = { csl = nil, + source = "oxalph.dbx", type = "literal", }, newpage = { csl = nil, + source = "tugboat.bst", }, newsdate = { csl = nil, + source = "aefkw.dbx", type = "date", }, newspaper = { csl = "container-title", + source = "seuthesix.bst", type = "literal", }, nickname = { csl = nil, + source = "address-html.bst", }, nihms = { csl = nil, + source = "apacite.bst", }, noed = { csl = nil, + source = "jox.bst", }, nolink = { csl = nil, + source = "quantum.bst", }, normal = { csl = nil, + source = "bookdb.bst", }, normalauthor = { csl = nil, + source = "seuthesis.bst", }, normaleditor = { csl = nil, + source = "seuthesis.bst", }, note = { csl = "note", + source = "bibtex", type = "literal", }, nowarning = { csl = nil, + source = "tugboat.bst", }, number = { csl = "number", + notes = "It is mapped to `issue` in `@ariticle` but to `number` in `@patent` or `@report`.", + source = "bibtex", type = "literal", }, ["number-of-pages"] = { csl = "number-of-pages", + source = "csl", }, ["number-of-volumes"] = { csl = "number-of-volumes", + source = "csl", }, numbera = { csl = nil, + source = "mla.dbx", type = "literal", }, numberb = { csl = nil, + source = "mla.dbx", type = "literal", }, numcites = { csl = nil, + source = "biblatex-cv.dbx", type = "integer", }, numlectures = { csl = nil, + source = "biblatex-cv.dbx", type = "integer", }, numpages = { csl = "number-of-pages", + source = "ACM-Reference-Format.bst", type = "literal", }, numstudents = { csl = nil, + source = "biblatex-cv.dbx", type = "integer", }, oaddress = { csl = "original-publisher-place", + source = "achicago.bst", }, officialpages = { + alias = "userd", csl = nil, + source = "biblatex-juradiss.dbx", type = "literal", }, officialvolume = { + alias = "userc", csl = nil, + source = "biblatex-juradiss.dbx", type = "literal", }, openaccess = { csl = nil, + source = "publist.dbx", type = "literal", }, options = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "option", }, opublisher = { csl = "original-publisher", + source = "achicago.bst", }, ["org-short"] = { csl = nil, + source = "abntex2-alf.bst", }, organization = { - csl = "publisher", + csl = nil, + notes = "The `organizer` that sponsors a conference or a `publisher` that publishes a `@manual` or `@online`.", + source = "bibtex", type = "literal", }, organizer = { csl = "organizer", + source = "csl", }, origdate = { csl = "original-date", + source = "biblatex", type = "date", }, ["origdate+an"] = { csl = nil, + source = "aefkw.dbx", type = "literal", }, origdatetype = { csl = nil, + source = "oxalph.dbx", type = "literal", }, origin = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, ["original-author"] = { csl = "original-author", + source = "csl", }, ["original-date"] = { csl = "original-date", + source = "csl", }, ["original-publisher"] = { csl = "original-publisher", + source = "csl", }, ["original-publisher-place"] = { csl = "original-publisher-place", + source = "csl", }, ["original-title"] = { csl = "original-title", + source = "csl", }, originaladdress = { csl = "original-publisher-place", + source = "apacite.bst", }, originalbooktitle = { csl = nil, + source = "apacite.bst", }, originaledition = { csl = nil, + source = "apacite.bst", }, originaleditor = { csl = nil, + source = "apacite.bst", }, originaljournal = { csl = nil, + source = "apacite.bst", }, originalnumber = { csl = nil, + source = "apacite.bst", }, originalpages = { csl = nil, + source = "apacite.bst", }, originalpublisher = { csl = "original-publisher", + source = "apacite.bst", }, originalvolume = { csl = nil, + source = "apacite.bst", }, originalyear = { csl = "original-date", + source = "apacite.bst", }, origlanguage = { csl = nil, + source = "biblatex", type = "key", }, origlocation = { csl = "original-publisher-place", + source = "biblatex", type = "literal", }, origpublisher = { csl = "original-publisher", + source = "biblatex", type = "literal", }, origrealdate = { csl = nil, + source = "aefkw.dbx", type = "date", }, origtitle = { csl = "original-title", + source = "biblatex", type = "literal", }, owner = { csl = nil, + source = "manuscripts-shared.dbx", type = "name", }, oyear = { csl = nil, + source = "achicago.bst", }, page = { csl = "page", + source = "csl", }, pagename = { csl = nil, + source = "abntex2-alf.bst", }, pages = { csl = "page", + source = "bibtex", type = "range", }, pagetotal = { csl = "number-of-pages", + source = "biblatex", type = "literal", }, pagination = { csl = nil, + source = "biblatex", type = "key", }, paper = { csl = nil, + source = "IEEEtran.bst", }, pardate = { csl = nil, + source = "oxalph.dbx", type = "date", }, parpages = { csl = nil, + source = "oxalph.dbx", type = "range", }, parreporter = { csl = nil, + source = "oxalph.dbx", type = "literal", }, parseries = { csl = nil, + source = "oxalph.dbx", type = "literal", }, part = { csl = "part", + source = "biblatex", type = "literal", }, ["part-title"] = { csl = "part-title", + source = "csl", }, parts = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, parttitle = { csl = nil, + source = "fiwi.dbx", type = "literal", }, parvolume = { csl = nil, + source = "oxalph.dbx", type = "integer", }, patentid = { csl = nil, + source = "seuthesis.bst", }, pdf = { + alias = "file", csl = nil, + source = "biblatex", type = "verbatim", }, peerreview = { csl = nil, + source = "publist.dbx", type = "literal", }, performer = { csl = "performer", + source = "csl", }, phone = { csl = nil, + source = "adrbirthday.bst", }, pid = { csl = nil, + source = "seuthesix.bst", }, pii = { csl = nil, + source = "amsra.bst", }, pmc = { csl = nil, + source = "hep-bibliography.dbx", type = "literal", }, pmcid = { csl = "PMCID", + source = "apacite.bst", type = "literal", }, pmid = { csl = "PMID", + source = "hep-bibliography.dbx", type = "literal", }, prebibitem = { csl = nil, + source = "tugboat.bst", }, preface = { csl = nil, + source = "bookdb.bst", type = "name", }, preprint = { csl = nil, + source = "amsra.bst", }, presentationtype = { csl = nil, + source = "biblatex-cv.dbx", type = "literal", }, presenter = { csl = nil, + source = "biblatex-cv.dbx", type = "name", }, presort = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, price = { csl = nil, + source = "is-abbrv.bst", }, primaryclass = { + alias = "eprintclass", csl = nil, + source = "biblatex", type = "literal", }, printing = { csl = nil, + source = "dk-abbrv.bst", }, ["printing-number"] = { csl = "printing-number", + source = "csl", }, prioritycountry = { csl = nil, + source = "gost2003.bst", type = "literal", }, prioritydate = { csl = nil, + source = "gost2003.bst", type = "date", }, prioritynumber = { csl = nil, + source = "gost2003.bst", type = "literal", }, producer = { csl = "producer", + source = "apa6.dbx", type = "name", }, production = { csl = nil, + source = "fiwi.dbx", type = "literal", }, protocollessurl = { csl = nil, + source = "hep-bibliography.dbx", type = "uri", }, pseudonym = { csl = nil, + source = "jox.bst", }, publication = { csl = nil, + source = "gost2003.bst", type = "literal", }, publicationdate = { csl = nil, + source = "gost2003.bst", type = "date", }, publicprice = { csl = nil, + source = "gzt.dbx", type = "literal", }, publisher = { csl = "publisher", + source = "bibtex", type = "literal", }, ["publisher-place"] = { csl = "publisher-place", + source = "csl", }, publishera = { csl = nil, + source = "mla.dbx", type = "literal", }, publisherb = { csl = nil, + source = "mla.dbx", type = "literal", }, pubmed = { csl = "PMID", + source = "urlbst", }, pubstate = { csl = "status", + notes = "The publication state of the work, e. g., ‘in press’.", + source = "biblatex", type = "key", }, rawauthor = { csl = nil, + source = "oxalph.dbx", type = "literal", }, realauthor = { csl = nil, + source = "realauthor.dbx", type = "name", }, realdate = { csl = nil, + source = "aefkw.dbx", type = "date", }, realeditor = { csl = nil, + source = "realauthor.dbx", type = "name", }, recipient = { csl = "recipient", + source = "csl", }, references = { csl = "references", + source = "csl", }, related = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "entrykey", }, relatedoptions = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "option", }, relatedstring = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, relatedtype = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, reportnumber = { csl = nil, + source = "hep-bibliography.dbx", type = "literal", }, repository = { csl = nil, + source = "software.dbx", type = "uri", }, ["reprinted-from"] = { csl = nil, + source = "abntex2-alf.bst", }, ["reprinted-text"] = { csl = nil, + source = "abntex2-alf.bst", }, reprinttitle = { csl = nil, + source = "biblatex", type = "literal", }, requestdate = { csl = nil, + source = "gost2003.bst", }, requestnumber = { csl = nil, + source = "gost2003.bst", type = "literal", }, responsible = { csl = nil, + source = "rusnat.bst", }, revdauthor = { csl = nil, + source = "sbl.dbx", type = "name", }, revdeditor = { csl = nil, + source = "sbl.dbx", type = "name", }, revdshorttitle = { csl = nil, + source = "sbl.dbx", type = "literal", }, revdsubtitle = { csl = nil, + source = "sbl.dbx", type = "literal", }, revdtitle = { csl = nil, + source = "sbl.dbx", type = "literal", }, revdtitleaddon = { csl = nil, + source = "sbl.dbx", type = "literal", }, review = { csl = nil, + source = "amsra.bst", }, ["reviewed-author"] = { csl = "reviewed-author", + source = "csl", }, ["reviewed-genre"] = { csl = "reviewed-genre", + source = "csl", }, ["reviewed-title"] = { csl = "reviewed-title", + source = "csl", }, reviewer = { csl = nil, + source = "gzt.dbx", type = "name", }, reviewerinstitution = { csl = nil, + source = "gzt.dbx", type = "literal", }, revision = { csl = nil, + source = "IEEEtran.bst", }, role = { csl = nil, + source = "biblatex-cv.dbx", type = "key", }, scale = { csl = "scale", + source = "csl", }, school = { + alias = "institution", csl = "publisher", + source = "bibtex", type = "literal", }, science = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, score = { csl = nil, + source = "bestpapers-export.bst", }, scribe = { csl = nil, + source = "oxalph.dbx", type = "name", }, script = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, ["script-writer"] = { csl = "script-writer", + source = "csl", }, scriptwriter = { csl = nil, + source = "fiwi.dbx", type = "name", }, section = { csl = "section", + source = "abntex2-alf.bst", type = "literal", }, semesters = { csl = nil, + source = "biblatex-cv.dbx", type = "entrykey", }, series = { csl = "collection-title", + source = "bibtex", type = "literal", }, ["series-creator"] = { csl = "series-creator", + source = "csl", }, seriesaddon = { csl = nil, + source = "windycity.dbx", type = "literal", }, seriesedition = { csl = nil, + source = "achicago.bst", }, serieseditor = { csl = nil, + source = "oxalph.dbx", type = "name", }, seriesseries = { csl = nil, + source = "sbl.dbx", type = "literal", }, setlabel = { csl = nil, + source = "windycity.dbx", type = "literal", }, shelfmark = { csl = nil, + source = "bath.dbx", type = "literal", }, short = { csl = nil, + source = "glsplain.bst", }, shortarchive = { csl = nil, + source = "jurabib.bst", }, shortauthor = { csl = nil, + source = "biblatex", type = "name", }, shortblog = { csl = nil, + source = "windycity.dbx", type = "literal", }, shortbookauthor = { csl = nil, + source = "windycity.dbx", type = "name", }, shortbooktitle = { csl = nil, + source = "sbl.dbx", type = "literal", }, shortcollection = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, shorteditor = { csl = nil, + source = "biblatex", type = "name", }, shortform = { csl = nil, + source = "aefkw.dbx", type = "literal", }, shorthand = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, shorthandintro = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, shortissuetitle = { csl = nil, + source = "sbl.dbx", type = "literal", }, shortjournal = { csl = "container-title-short", + source = "biblatex", type = "literal", }, shortlabeltitle = { csl = nil, + source = "oxalph.dbx", type = "literal", }, shortlibrary = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, shortmaintitle = { csl = nil, + source = "sbl.dbx", type = "literal", }, shortorganization = { csl = nil, + source = "windycity.dbx", type = "literal", }, shortserie = { csl = nil, + source = "lncs.dbx", type = "literal", }, shortseries = { csl = nil, + source = "biblatex", type = "literal", }, shortsubarchive = { csl = nil, + source = "jurabib.bst", }, shortsubseries = { csl = nil, + source = "aefkw.dbx", type = "literal", }, shortsubsubseries = { csl = nil, + source = "subseries.dbx", type = "literal", }, shorttitle = { csl = "title-short", + source = "biblatex", type = "literal", }, shorttranslator = { csl = nil, + source = "windycity.dbx", type = "name", }, shorturl = { csl = nil, + source = "quantum.bst", }, sig1 = { csl = nil, + source = "jurabib.bst", }, sig2 = { csl = nil, + source = "jurabib.bst", }, sig3 = { csl = nil, + source = "jurabib.bst", }, sig4 = { csl = nil, + source = "jurabib.bst", }, sign = { + alias = "userb", csl = nil, + source = "biblatex-juradiss.dbx", type = "literal", }, size = { csl = nil, + source = "bookdb.bst", }, slaccitation = { csl = nil, + source = "apsrev4-2.bst", }, smfprice = { csl = nil, + source = "gzt.dbx", type = "literal", }, ["sort-short"] = { csl = nil, + source = "glsplain.bst", }, ["sort-word"] = { csl = nil, + source = "glsplain.bst", }, sortas = { csl = nil, + source = "adrbirthday.bst", }, sortkey = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, sortname = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "name", }, sortshelfmark = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, sortshorthand = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, sorttitle = { csl = nil, + notes = "Not supported.", + source = "biblatex", type = "literal", }, sortvolume = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, sortyear = { csl = nil, + source = "biblatex", type = "integer", }, + source = { + csl = "source", + source = "figbib.bst", + type = "literal", + }, source1 = { csl = nil, + source = "figbib1.bst", }, specdata = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, speciality = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, specialitycode = { csl = nil, + source = "gost2003.bst", type = "literal", }, ssedition = { csl = nil, + source = "jox.bst", }, standard = { csl = nil, + source = "udesoftec.bst", }, startnumber = { csl = nil, + source = "seuthesis.bst", }, startvolume = { csl = nil, + source = "seuthesis.bst", }, startyear = { csl = nil, + source = "seuthesis.bst", }, state = { csl = nil, + source = "address-html.bst", }, status = { csl = "status", + source = "amsra.bst", type = "key", }, stdcode = { csl = "number", + source = "seuthesix.bst", }, stitle = { csl = nil, + source = "jox.bst", }, street = { csl = nil, + source = "adrbirthday.bst", }, subarchive = { csl = nil, + source = "jurabib.bst", }, submitted = { csl = "submitted", + source = "csl", }, subnumber = { csl = nil, + source = "aefkw.dbx", type = "integer", }, subseries = { csl = nil, + source = "aefkw.dbx", type = "literal", }, subsubnumber = { csl = nil, + source = "subseries.dbx", type = "literal", }, subsubseries = { csl = nil, + source = "subseries.dbx", type = "literal", }, subtitle = { csl = nil, + source = "biblatex", type = "literal", }, summarytitle = { csl = nil, + source = "aefkw.dbx", type = "literal", }, supervisor = { csl = nil, + source = "iso-alphabetic.dbx", type = "name", }, supplement = { csl = "supplement", + source = "csl", }, supplemental = { csl = nil, + source = "mla.dbx", type = "literal", }, supplementala = { csl = nil, + source = "mla.dbx", type = "literal", }, supplementalb = { csl = nil, + source = "mla.dbx", type = "literal", }, support = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, swhid = { csl = nil, + source = "software.dbx", type = "verbatim", }, swhidcore = { csl = nil, + source = "software.dbx", type = "verbatim", }, symposium = { csl = nil, + source = "apacite.bst", }, systemreq = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, text = { csl = nil, + source = "apacite.bst", }, thesisdate = { csl = nil, + source = "arthistory-bonn.dbx", type = "date", }, thesistype = { csl = nil, + source = "arthistory-bonn.dbx", type = "verbatim", }, thumbnail = { csl = nil, + source = "gzt.dbx", type = "verbatim", }, timestamp = { csl = nil, + source = "export.bst", }, title = { csl = "title", + source = "bibtex", type = "literal", }, ["title-short"] = { csl = "title-short", + source = "csl", }, titlea = { csl = nil, + source = "mla.dbx", type = "literal", }, titleaddon = { csl = nil, + source = "biblatex", type = "literal", }, titleb = { csl = nil, + source = "mla.dbx", type = "literal", }, titleisdescription = { csl = nil, + source = "apa6.dbx", type = "literal", }, titlekey = { csl = nil, + source = "windycity.dbx", type = "key", }, titlenote = { csl = nil, + source = "aomalpha.bst", type = "literal", }, titletype = { csl = nil, + source = "mla.dbx", type = "literal", }, totalpages = { csl = nil, + source = "aomalpha.bst", }, transissue = { csl = nil, + source = "iopart-num.bst", }, transjournal = { csl = nil, + source = "iopart-num.bst", }, translation = { csl = nil, + source = "apsrev4-2.bst", }, translator = { csl = "translator", + source = "biblatex", type = "name", }, translatora = { csl = nil, + source = "windycity.dbx", type = "name", }, translatoratype = { csl = nil, + source = "windycity.dbx", type = "key", }, translatorb = { csl = nil, + source = "windycity.dbx", type = "name", }, translatorbtype = { csl = nil, + source = "windycity.dbx", type = "key", }, translatortype = { csl = nil, + source = "windycity.dbx", type = "key", }, transnumber = { csl = nil, + source = "iopart-num.bst", }, transpages = { csl = nil, + source = "iopart-num.bst", }, transsection = { csl = nil, + source = "iopart-num.bst", }, transvolume = { csl = nil, + source = "iopart-num.bst", }, transyear = { csl = nil, + source = "iopart-num.bst", }, type = { csl = "genre", + source = "bibtex", type = "key", }, typeaddon = { csl = nil, + source = "windycity.dbx", type = "literal", }, typeoflit = { csl = nil, + source = "seuthesis.bst", }, umfnumber = { csl = nil, + source = "thesnumb.bst", }, update = { csl = nil, + source = "biblatex-gost.dbx", type = "date", }, updated = { csl = nil, + source = "vancouver.bst", }, url = { csl = "URL", + source = "biblatex", type = "uri", }, urlaccessdate = { csl = "accessed", + source = "abntex2-alf.bst", }, urldate = { csl = "accessed", + source = "biblatex", type = "date", }, urldescription = { csl = nil, + source = "apa6.dbx", type = "literal", }, urlnewline = { csl = nil, + source = "tugboat.bst", }, urls = { csl = nil, + source = "acmdatamodel.dbx", type = "uri", }, urltype = { csl = nil, + source = "asmeconf.bst", }, urlyear = { csl = "accessed", + source = "bath.bst", }, urn = { csl = nil, + source = "export.bst", type = "verbatim", }, usera = { csl = nil, + source = "biblatex", type = "literal", }, userb = { csl = nil, + source = "biblatex", type = "literal", }, userc = { csl = nil, + source = "biblatex", type = "literal", }, userd = { csl = nil, + source = "biblatex", type = "literal", }, usere = { csl = nil, + source = "biblatex", type = "literal", }, userf = { csl = nil, + source = "biblatex", type = "literal", }, usualtitle = { csl = nil, + source = "manuscripts-shared.dbx", type = "literal", }, value = { csl = nil, + source = "bookdb.bst", }, venue = { csl = "event-place", + source = "biblatex", type = "literal", }, verba = { csl = nil, + source = "biblatex", type = "verbatim", }, verbb = { csl = nil, + source = "biblatex", type = "verbatim", }, verbc = { csl = nil, + source = "biblatex", type = "verbatim", }, version = { csl = "version", + source = "biblatex", type = "literal", }, versiona = { csl = nil, + source = "mla.dbx", type = "literal", }, versionb = { csl = nil, + source = "mla.dbx", type = "literal", }, versiontype = { csl = nil, + source = "asmeconf.bst", }, volformat = { csl = nil, + source = "jox.bst", }, volsorder = { csl = nil, + source = "biblatex-gost.dbx", type = "literal", }, volume = { csl = "volume", + source = "bibtex", type = "integer", }, ["volume-title"] = { csl = "volume-title", + source = "csl", }, ["volume-title-short"] = { csl = "volume-title-short", + source = "csl", }, volumes = { csl = "number-of-volumes", + source = "biblatex", type = "integer", }, volumetitle = { csl = "volume-title", + source = "iopart-num.bst", }, with = { csl = nil, + source = "apa.dbx", type = "name", }, withauthor = { csl = nil, + source = "sbl.dbx", type = "name", }, withauthortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withbookauthor = { csl = nil, + source = "sbl.dbx", type = "name", }, withbookauthortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withbookeditor = { csl = nil, + source = "sbl.dbx", type = "name", }, withbookeditortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withbooktranslator = { csl = nil, + source = "sbl.dbx", type = "name", }, withbooktranslatortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, witheditor = { csl = nil, + source = "sbl.dbx", type = "name", }, witheditortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withmainauthor = { csl = nil, + source = "sbl.dbx", type = "name", }, withmainauthortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withmaineditor = { csl = nil, + source = "sbl.dbx", type = "name", }, withmaineditortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withmaintranslator = { csl = nil, + source = "sbl.dbx", type = "name", }, withmaintranslatortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, withtranslator = { csl = nil, + source = "sbl.dbx", type = "name", }, withtranslatortype = { csl = nil, + source = "sbl.dbx", type = "literal", }, word = { csl = nil, + source = "vancouver.bst", }, writer = { csl = nil, + source = "apa6.dbx", type = "name", }, xdata = { csl = nil, + notes = "inherits fields from other items.", + source = "biblatex", type = "entrykey", }, xid = { csl = nil, + source = "amsra.bst", }, xref = { csl = nil, + notes = "Establishes a parent-child relationship in biblatex, but without inheriting data => no need to parse this.", + source = "biblatex", type = "entrykey", }, year = { - csl = nil, + csl = "issued", + notes = "Used only when `date` is empty.", + source = "bibtex", type = "date", }, ["year-presented"] = { csl = nil, + source = "abntex2-alf.bst", }, yearcomp = { csl = nil, + source = "achicago.bst", }, yearfiled = { csl = nil, + source = "IEEEtran.bst", }, zblnumber = { csl = nil, + source = "aomalpha.bst", }, zenon = { csl = nil, + source = "archaeologie.dbx", type = "verbatim", }, zip = { csl = nil, + source = "adrbirthday.bst", }, }, macros = { - jan = { - value = "1", - }, - feb = { - value = "2", + acmcs = { + source = "bibtex", + value = "ACM Computing Surveys", }, - mar = { - value = "3", + acta = { + source = "bibtex", + value = "Acta Informatica", }, apr = { - value = "4", - }, - may = { - value = "5", - }, - jun = { - value = "6", - }, - jul = { - value = "7", + source = "bibtex", + value = "April", }, aug = { - value = "8", - }, - sep = { - value = "9", + source = "bibtex", + value = "August", }, - oct = { - value = "10", - }, - nov = { - value = "11", + cacm = { + source = "bibtex", + value = "Communications of the ACM", }, dec = { - value = "12", - }, - acmcs = { - value = "ACM Computing Surveys", + source = "bibtex", + value = "December", }, - acta = { - value = "Acta Informatica", - }, - cacm = { - value = "Communications of the ACM", + feb = { + source = "bibtex", + value = "February", }, ibmjrd = { + source = "bibtex", value = "IBM Journal of Research and Development", }, ibmsj = { + source = "bibtex", value = "IBM Systems Journal", }, ieeese = { + source = "bibtex", value = "IEEE Transactions on Software Engineering", }, ieeetc = { + source = "bibtex", value = "IEEE Transactions on Computers", }, ieeetcad = { + source = "bibtex", value = "IEEE Transactions on Computer-Aided Design of Integrated Circuits", }, ipl = { + source = "bibtex", value = "Information Processing Letters", }, jacm = { + source = "bibtex", value = "Journal of the ACM", }, + jan = { + source = "bibtex", + value = "January", + }, jcss = { + source = "bibtex", value = "Journal of Computer and System Sciences", }, + jul = { + source = "bibtex", + value = "July", + }, + jun = { + source = "bibtex", + value = "June", + }, + mar = { + source = "bibtex", + value = "March", + }, + may = { + source = "bibtex", + value = "May", + }, + nov = { + source = "bibtex", + value = "November", + }, + oct = { + source = "bibtex", + value = "October", + }, scp = { + source = "bibtex", value = "Science of Computer Programming", }, + sep = { + source = "bibtex", + value = "September", + }, sicomp = { + source = "bibtex", value = "SIAM Journal on Computing", }, + tcs = { + source = "bibtex", + value = "Theoretical Computer Science", + }, tocs = { + source = "bibtex", value = "ACM Transactions on Computer Systems", }, tods = { + source = "bibtex", value = "ACM Transactions on Database Systems", }, tog = { + source = "bibtex", value = "ACM Transactions on Graphics", }, toms = { + source = "bibtex", value = "ACM Transactions on Mathematical Software", }, toois = { + source = "bibtex", value = "ACM Transactions on Office Information Systems", }, toplas = { + source = "bibtex", value = "ACM Transactions on Programming Languages and Systems", }, - tcs = { - value = "Theoretical Computer Science", - }, }, language_code_map = { + UKenglish = "en-GB", + USenglish = "en-US", acadian = "fr-CA", afrikaans = "af-ZA", albanian = "sq-AL", @@ -3358,11 +4388,75 @@ return { 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", }, + months = { + apr = "4", + april = "4", + aug = "8", + august = "8", + dec = "12", + december = "12", + feb = "2", + february = "2", + jan = "1", + january = "1", + jul = "7", + july = "7", + jun = "6", + june = "6", + mar = "3", + march = "3", + may = "5", + nov = "11", + november = "11", + oct = "10", + october = "10", + sep = "9", + september = "9", + }, + primary_fields = { + annotation = "note", + ["archive-place"] = "archive-place", + author = "author", + bookauthor = "container-author", + chapter = "chapter-number", + date = "issued", + director = "director", + editor = "editor", + eprinttype = "archive", + eventdate = "event-date", + eventtitle = "event-title", + ["executive-producer"] = "executive-producer", + journaltitle = "container-title", + jurisdiction = "jurisdiction", + langid = "language", + location = "publisher-place", + medium = "medium", + number = "number", + origdate = "original-date", + origlocation = "original-publisher-place", + origpublisher = "original-publisher", + origtitle = "original-title", + pages = "page", + pagetotal = "number-of-pages", + performer = "performer", + pmid = "PMID", + publisher = "publisher", + pubstate = "status", + series = "collection-title", + shortjournal = "container-title-short", + shorttitle = "title-short", + title = "title", + translator = "translator", + type = "genre", + urldate = "accessed", + venue = "event-place", + version = "version", + ["volume-title"] = "volume-title", + volumes = "number-of-volumes", + }, } diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-parser.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-parser.lua index 3932e7fe3fc..00d66169f67 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-parser.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex-parser.lua @@ -13,11 +13,22 @@ -- @module bibtex_parser local bibtex_parser = {} +local unicode +local bibtex_data +local util +if kpse then + unicode = require("citeproc-unicode") + bibtex_data = require("citeproc-bibtex-data") + util = require("citeproc-util") +else + unicode = require("citeproc.unicode") + bibtex_data = require("citeproc.bibtex-data") + util = require("citeproc.util") +end + local lpeg = require("lpeg") -local unicode = require("unicode") -local bibtex_data = require("citeproc-bibtex-data") local latex_parser = nil -- load as needed -local util = require("citeproc-util") + local P = lpeg.P local R = lpeg.R @@ -151,17 +162,24 @@ function BibtexParser:new() end +---@alias BibtexEntry { key: string, type: string, fields: table<string, string> } ---@alias BibtexData table ---@alias Exception table ---comment ----@return BibtexData?, Exception[]? +---@param bib_str string +---@param strings table +---@return BibtexData? +---@return Exception[]? function BibtexParser:parse(bib_str, strings) if strings then strings = setmetatable({}, {__index = strings}) else strings = setmetatable({}, {__index = self.strings}) end + if type(bib_str) ~= "string" then + util.error("Invalid string.") + end local bib_objects = self.grammar:match(bib_str) if not bib_objects then local error = { @@ -172,7 +190,10 @@ function BibtexParser:parse(bib_str, strings) end local res = { + ---@type BibtexEntry[] entries = {}, + ---@type table<string, BibtexEntry> + entries_by_id = {}, strings = {}, preamble = nil, } @@ -181,7 +202,8 @@ function BibtexParser:parse(bib_str, strings) for _, object in ipairs(bib_objects) do if object.category == "entry" then local entry = self:_make_entry(object, strings) - table.insert(res.entries, object) + table.insert(res.entries, entry) + res.entries_by_id[entry.key] = entry elseif object.category == "string" then local string_value = concat_strings(object.contents, strings) @@ -215,7 +237,11 @@ function BibtexParser:_make_entry(object, strings) value = concat_strings(value, strings) if self.options.convert_to_unicode then - latex_parser = latex_parser or require("citeproc-latex-parser") + if kpse then + latex_parser = latex_parser or require("citeproc-latex-parser") + else + latex_parser = latex_parser or require("citeproc.latex-parser") + end value = latex_parser.latex_to_unicode(value) end @@ -312,14 +338,6 @@ function bibtex_parser.split_name_parts(str) return name end -local function is_upper_letter(char) - return unicode.utf8.upper(char) == char and unicode.utf8.lower(char) ~= char -end - -local function is_lower_letter(char) - return unicode.utf8.lower(char) == char and unicode.utf8.upper(char) ~= char -end - local function is_lower_word(word) -- Word is a list of tokens for _, token in ipairs(word) do @@ -335,17 +353,17 @@ local function is_lower_word(word) token_content = string.gsub(token, "}%s*$", "") for i = 1, #token_content do local char = string.sub(token_content, i, i) - if is_lower_letter(char) then + if unicode.islower(char) then return true - elseif is_upper_letter(char) then + elseif unicode.isupper(char) then return false end end end else - if is_lower_letter(token) then + if unicode.islower(token) then return true - elseif is_upper_letter(token) then + elseif unicode.isupper(token) then return false end end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex2csl.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex2csl.lua index 06c6de15765..83fada68caa 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex2csl.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-bibtex2csl.lua @@ -6,13 +6,28 @@ local bibtex2csl = {} -local bibtex_parser = require("citeproc-bibtex-parser") -local bibtex_data = require("citeproc-bibtex-data") -local latex_parser = nil -- load as needed -local util = require("citeproc-util") +local uni_utf8 +local bibtex_parser +local bibtex_data +local latex_parser +local unicode +local util +if kpse then + uni_utf8 = require("unicode").utf8 + bibtex_parser = require("citeproc-bibtex-parser") + bibtex_data = require("citeproc-bibtex-data") + unicode = require("citeproc-unicode") + util = require("citeproc-util") +else + uni_utf8 = require("lua-utf8") + bibtex_parser = require("citeproc.bibtex-parser") + bibtex_data = require("citeproc.bibtex-data") + unicode = require("citeproc.unicode") + util = require("citeproc.util") +end ----@alias CslItem table +---@alias CslItem table<string, nil | string | number | table> ---@alias CslData CslItem[] @@ -48,24 +63,48 @@ end ---@return CslData function bibtex2csl.convert_to_csl_data(bib, keep_unknown_commands, case_protection, sentence_case_title, check_sentence_case) local csl_data = {} + + -- BibTeX looks for crossref in a case-insensitive manner. + local entries_by_id = {} + for _, entry in ipairs(bib.entries) do + entries_by_id[unicode.casefold(entry.key)] = entry + end + for _, entry in ipairs(bib.entries) do + ---@type CslItem local 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 + -- crossref + if entry.fields.crossref then + bibtex2csl.process_cross_ref(entry, entries_by_id) end - --TODO: language + bibtex2csl.pre_process_special_fields(item, entry) + + -- First convert primary fields + for field, csl_field in pairs(bibtex_data.primary_fields) do + local value = entry.fields[field] + if value then + local _, csl_value = bibtex2csl.convert_field( + field, value, keep_unknown_commands, case_protection, sentence_case_title, item.language, check_sentence_case) + if csl_field and csl_value and not item[csl_field] then + item[csl_field] = csl_value + end + end + end - -- TODO: preprosse - -- Merge title, maintitle, substitle, titleaddon + -- Convert the fields in a fixed order + local field_list = {} + for field, _ in pairs(entry.fields) do + table.insert(field_list, field) + end + table.sort(field_list) - for field, value in pairs(entry.fields) do + for _, field in ipairs(field_list) do + local value = entry.fields[field] local csl_field, csl_value = bibtex2csl.convert_field( field, value, keep_unknown_commands, case_protection, sentence_case_title, item.language, check_sentence_case) if csl_field and csl_value and not item[csl_field] then @@ -73,7 +112,7 @@ function bibtex2csl.convert_to_csl_data(bib, keep_unknown_commands, case_protect end end - bibtex2csl.process_special_fields(item, entry.fields) + bibtex2csl.post_process_special_fields(item, entry, entry.type) table.insert(csl_data, item) end @@ -81,6 +120,98 @@ function bibtex2csl.convert_to_csl_data(bib, keep_unknown_commands, case_protect end +---@param entry BibtexEntry +---@param entries_by_id table<string, BibtexEntry> +function bibtex2csl.process_cross_ref(entry, entries_by_id) + local ref_entry = entries_by_id[unicode.casefold(entry.fields.crossref)] + if ref_entry then + for field, value in pairs(ref_entry.fields) do + if not entry.fields[field] then + entry.fields[field] = value + end + end + else + util.error(string.format('Crossref "%s" not found.', entry.fields.crossref)) + end +end + + +---@param item CslItem +---@param entry BibtexEntry +function bibtex2csl.pre_process_special_fields(item, entry) + -- CSL types + local type_data = bibtex_data.types[entry.type] + if type_data and type_data.csl then + item.type = type_data.csl + elseif entry.fields.url then + item.type = "webpage" + end + + -- BibTeX's `edition` is expected to be an ordinal. + if entry.fields.edition then + item.edition = util.convert_ordinal_to_arabic(entry.fields.edition) + end + + -- language: convert `babel` language to ISO 639-1 language code + local lang = entry.fields.langid or entry.fields.language + if lang then + item.language = bibtex_data.language_code_map[unicode.casefold(lang)] + end + -- if not item.language then + -- if util.has_cjk_char(item.title) then + -- item.language = "zh" + -- end + -- end + + -- Merge title, maintitle, subtitle, titleaddon + bibtex2csl.process_titles(entry) + +end + + +---@param entry BibtexEntry +function bibtex2csl.process_titles(entry) + local fields = entry.fields + if fields.subtitle then + if not fields.shorttitle then + fields.shorttitle = fields.title + end + if fields.title then + fields.title = util.join_title(fields.title, fields.subtitle) + else + fields.title = fields.subtitle + end + end + if fields.booksubtitle then + if not fields.shorttitle then + fields["container-title-short"] = fields.booktitle + end + if fields.booktitle then + fields.booktitle = util.join_title(fields.booktitle, fields.booksubtitle) + else + fields.booktitle = fields.booksubtitle + end + end + if fields.journalsubtitle then + if fields.journaltitle then + fields.journaltitle = util.join_title(fields.journaltitle, fields.journalsubtitle) + elseif fields.journal then + fields.journal = util.join_title(fields.journal, fields.journal) + end + end + if fields.issuesubtitle then + if not fields.shorttitle then + fields["volume-title-short"] = fields.issuetitle + end + if fields.issuetitle then + fields.issuetitle = util.join_title(fields.issuetitle, fields.issuesubtitle) + else + fields.issuetitle = fields.issuesubtitle + end + end +end + + ---Convert BibTeX field to CSL field ---@param bib_field string ---@param value string @@ -101,7 +232,11 @@ function bibtex2csl.convert_field(bib_field, value, keep_unknown_commands, case_ return nil, nil end - latex_parser = latex_parser or require("citeproc-latex-parser") + if kpse then + latex_parser = latex_parser or require("citeproc-latex-parser") + else + latex_parser = latex_parser or require("citeproc.latex-parser") + end local field_type = field_data.type local csl_value @@ -115,7 +250,12 @@ function bibtex2csl.convert_field(bib_field, value, keep_unknown_commands, case_ csl_value[i] = bibtex2csl.convert_to_csl_name(name_dict) end - elseif bib_field == "title" or bib_field == "booktitle" then + elseif field_type == "date" then + csl_value = latex_parser.latex_to_pseudo_html(value, false, false) + csl_value = bibtex2csl._parse_edtf_date(csl_value) + + elseif bib_field == "title" or bib_field == "shorttitle" + or bib_field == "booktitle" or bib_field == "container-title-short" then -- util.debug(value) -- 1. unicode 2. sentence case 3. html tag if sentence_case_title and (not language or util.startswith(language, "en")) then @@ -129,9 +269,7 @@ function bibtex2csl.convert_field(bib_field, value, keep_unknown_commands, case_ else -- 1. unicode 2. html tag csl_value = latex_parser.latex_to_pseudo_html(value, keep_unknown_commands, case_protection) - if field_type == "date" then - csl_value = bibtex2csl._parse_edtf_date(csl_value) - elseif csl_field == "volume" or csl_field == "page" then + if csl_field == "volume" or csl_field == "page" then csl_value = string.gsub(csl_value, util.unicode["en dash"], "-") end end @@ -166,56 +304,47 @@ function bibtex2csl.convert_to_csl_name(bibtex_name) end -function bibtex2csl.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 - +---@param item CslItem +---@param entry BibtexEntry +function bibtex2csl.post_process_special_fields(item, entry) + local bib_type = entry.type + local bib_fields = entry.fields -- 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 = bibtex2csl._parse_edtf_date(bib_fields.year) + -- Jounal abbreviations + if item.type == "article-journal" or item.type == "article-magazine" + or item.type == "article-newspaper" then + util.check_journal_abbreviations(item) end - local month = bib_fields.month - if month and string.match(month, "^%d+$") then - if item.issued and item.issued["date-parts"] and + + -- month + -- local month = bib_fields.month + local month_text = bib_fields.month + if month_text then + month_text = latex_parser.latex_to_pseudo_html(month_text, false, false) + local month, day = uni_utf8.match(month_text, "^(%a+)%.?,?%s+(%d+)%a*$") + if not month then + day, month = uni_utf8.match(month_text, "^(%d+)%a*%s+(%a+)%.?$") + end + if not month then + month = string.match(month_text, "^(%a+)%.?$") + end + if month then + month = bibtex_data.months[unicode.casefold(month)] + end + if month and 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) + if day then + item.issued["date-parts"][1][3] = tonumber(day) + end 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 - - -- Jounal abbreviations - if item.type == "article-journal" or item.type == "article-magazine" - or item.type == "article-newspaper" then - util.check_journal_abbreviations(item) - end - -- number if item.number then if item.type == "article-journal" or item.type == "article-magazine" or @@ -230,8 +359,22 @@ function bibtex2csl.process_special_fields(item, bib_fields) end end + -- organization: the `organizer` that sponsors a conference or a `publisher` that publishes a `@manual` or `@online`. + if bib_fields.organization then + if item.publisher or bib_type == "inproceedings" or bib_type == "proceedings" then + if not item.organizer then + item.organizer = { + literal = bib_fields.organization + } + end + elseif not item.publisher then + item.publisher = bib_fields.organization + end + end + -- PMID - if bib_fields.eprint and string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then + if bib_fields.eprint and type(bib_fields.eprinttype) == "string" and + string.lower(bib_fields.eprinttype) == "pubmed" and not item.PMID then item.PMID = bib_fields.eprint end 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 709e676ec38..e9309e313ac 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-cli.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-cli.lua @@ -8,6 +8,8 @@ local cli = {} +local lpeg = require("lpeg") + require("lualibs") local citeproc = require("citeproc") local bibtex2csl -- = require("citeproc-bibtex-parser") -- load on demand @@ -74,52 +76,76 @@ local function convert_bib(path, output_path) if not output_path then output_path = string.gsub(path, "%.bib$", ".json") end - local file = io.open(output_path, "w") - if not file then - util.error(string.format('Cannot write "%s".', output_path)) - return + util.write_file(utilities.json.tojson(csl_data) .. "\n", output_path) +end + + +local balanced = lpeg.P{ "{" * lpeg.V(1)^0 * "}" + (1 - lpeg.S"{}") } + + +---@param text string +---@return string? +local function get_command_argument(text, command) + if string.match(text, command) then + local grammar = (lpeg.P(command) * lpeg.S(" \t\r\n")^0 * lpeg.C(balanced) + 1)^0 + local argument = grammar:match(text) + if not argument then + return nil + end + argument = string.sub(argument, 2, -2) + return argument end - file:write(utilities.json.tojson(csl_data) .. "\n") - file:close() + return nil end +---comment +---@param aux_file any +---@return string +---@return string[] +---@return Citation[] +---@return table<string, string> +---@return string[] local function read_aux_file(aux_file) local bib_style = nil local bib_files = {} local citations = {} local csl_options = {} + local bibliographies = {} local file = io.open(aux_file, "r") if not file then error(string.format('Cannot read "%s"', aux_file)) - return end for line in file:lines() do - local match -- TODO: Use lpeg-based method and detect multiple lines - match = string.match(line, "^\\csl@aux@style%s*(%b{})") - if match then - bib_style = string.sub(match, 2, -2) + local style = get_command_argument(line, "\\csl@aux@style") + if style then + bib_style = style else - match = string.match(line, "^\\csl@aux@data%s*(%b{})") - if match then - for _, bib in ipairs(util.split(string.sub(match, 2, -2), "%s*,%s*")) do - table.insert(bib_files, bib) + local data = get_command_argument(line, "\\csl@aux@data") + if data then + for _, bib_file in ipairs(latex_parser.parse_seq(data)) do + table.insert(bib_files, bib_file) end else - match = string.match(line, "^\\csl@aux@cite%s*(%b{})") - if match then - local citation = core.make_citation(string.sub(match, 2, -2)) + local cite = get_command_argument(line, "\\csl@aux@cite") + if cite then + local citation = core.make_citation(cite) table.insert(citations, citation) else - match = string.match(line, "^\\csl@aux@options%s*(%b{})") - if match then - local options = latex_parser.parse_prop(string.sub(match, 2, -2)) + local options = get_command_argument(line, "\\csl@aux@options") + if options then + options = latex_parser.parse_prop(options) for key, value in pairs(options) do csl_options[key] = value end + else + local bib = get_command_argument(line, "\\csl@aux@bibliography") + if bib then + table.insert(bibliographies, bib) + end end end end @@ -127,20 +153,24 @@ local function read_aux_file(aux_file) end file:close() - return bib_style, bib_files, citations, csl_options + return bib_style, bib_files, citations, csl_options, bibliographies end +---@param aux_file string local function process_aux_file(aux_file) if not util.endswith(aux_file, ".aux") then aux_file = aux_file .. ".aux" end - local style_name, bib_files, citations, csl_options = read_aux_file(aux_file) + local style_name, bib_files, citations, csl_options, bibliographies = read_aux_file(aux_file) local lang = csl_options.locale local engine = core.init(style_name, bib_files, lang) + if not engine then + error("citeproc-lua: fails in initialize engine") + end if csl_options.linking then engine:enable_linking() end @@ -156,7 +186,7 @@ local function process_aux_file(aux_file) -- util.debug(citation_strings) - local output_string = "" + local output_string = string.format("\\cslsetup{class = %s}\n\n", style_class) for _, citation in ipairs(citations) do local citation_id = citation.citationID @@ -172,15 +202,13 @@ local function process_aux_file(aux_file) core.set_categories(engine, categories_str) end - local filter_str = csl_options["bib-filter"] - - local result = core.make_bibliography(engine, filter_str) - output_string = output_string .. result + for _, bib_filter_str in ipairs(bibliographies) do + local result = core.make_bibliography(engine, bib_filter_str) + output_string = output_string .. "\n\n\n" .. result + end local output_path = string.gsub(aux_file, "%.aux$", ".bbl") - local bbl_file = io.open(output_path, "w") - bbl_file:write(output_string) - bbl_file:close() + util.write_file(output_string, output_path) end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-context.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-context.lua index 24bb2b7d7a5..973c39a7284 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-context.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-context.lua @@ -6,9 +6,19 @@ local context = {} -local LocalizedQuotes = require("citeproc-output").LocalizedQuotes - -local util = require("citeproc-util") +local unicode +local LocalizedQuotes +local util + +if kpse then + unicode = require("citeproc-unicode") + LocalizedQuotes = require("citeproc-output").LocalizedQuotes + util = require("citeproc-util") +else + unicode = require("citeproc.unicode") + LocalizedQuotes = require("citeproc.output").LocalizedQuotes + util = require("citeproc.util") +end local Context = { @@ -179,7 +189,7 @@ function Context:split_ndp_family(name) if ndp and family then table.insert(ndp_parts, ndp) parts[i] = family - elseif i < #parts and util.is_lower(part) then + elseif i < #parts and unicode.islower(part) then table.insert(ndp_parts, part) end end @@ -190,7 +200,7 @@ function Context:split_ndp_family(name) end break end - if not util.is_lower(part) then + if not unicode.islower(part) then for j = i, #parts do table.insert(family_parts, parts[j]) end @@ -212,7 +222,7 @@ function Context:split_given_dp(name) local parts = util.split(name.given) for i = #parts, 1, -1 do local part = parts[i] - if i == 1 or not util.is_lower(part) then + if i == 1 or not unicode.islower(part) then for j = 1, i do table.insert(given_parts, parts[j]) end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-element.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-element.lua index 4d3226dc707..956095e622c 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-element.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-element.lua @@ -6,12 +6,25 @@ local element = {} -local SeqIr = require("citeproc-ir-node").SeqIr +local context +local ir_node +local output +local util -local InlineElement = require("citeproc-output").InlineElement -local Micro = require("citeproc-output").Micro +if kpse then + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + util = require("citeproc-util") +else + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + util = require("citeproc.util") +end + +local SeqIr = ir_node.SeqIr -local util = require("citeproc-util") +local InlineElement = output.InlineElement +local Micro = output.Micro ---@class Element 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 83cc2654ee5..ac50da02d85 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-engine.lua @@ -6,20 +6,45 @@ local engine = {} -local dom = require("luaxml-domobject") - -local nodes = require("citeproc-nodes") -local Element = require("citeproc-element").Element -local Style = require("citeproc-node-style").Style -local Locale = require("citeproc-node-locale").Locale -local Context = require("citeproc-context").Context -local IrState = require("citeproc-context").IrState -local InlineElement = require("citeproc-output").InlineElement --- local OutputFormat = require("citeproc-output").OutputFormat -local LatexWriter = require("citeproc-output").LatexWriter -local HtmlWriter = require("citeproc-output").HtmlWriter -local SortStringFormat = require("citeproc-output").SortStringFormat -local util = require("citeproc-util") +local dom +local context +local element +local nodes +local node_locale +local node_style +local output +local util + +if kpse then + dom = require("luaxml-domobject") + context = require("citeproc-context") + element = require("citeproc-element") + nodes = require("citeproc-nodes") + node_locale = require("citeproc-node-locale") + node_style = require("citeproc-node-style") + output = require("citeproc-output") + util = require("citeproc-util") +else + dom = require("citeproc.luaxml.domobject") + context = require("citeproc.context") + element = require("citeproc.element") + nodes = require("citeproc.nodes") + node_locale = require("citeproc.node-locale") + node_style = require("citeproc.node-style") + output = require("citeproc.output") + util = require("citeproc.util") +end + +local Element = element.Element +local Style = node_style.Style +local Locale = node_locale.Locale +local Context = context.Context +local IrState = context.IrState +local InlineElement = output.InlineElement +-- local OutputFormat = output.OutputFormat +local LatexWriter = output.LatexWriter +local HtmlWriter = output.HtmlWriter +local SortStringFormat = output.SortStringFormat ---@class CiteProc @@ -74,7 +99,7 @@ function CiteProc.new(sys, style, lang, force_lang) uncited_list = {}, previous_citation = nil, requires_sorting = false, - longest_label = "", + widest_label = "", maxoffset = 0, } @@ -602,7 +627,7 @@ function CiteProc:makeBibliography(bibsection) local res = {} - self.registry.longest_label = "" + self.registry.widest_label = "" self.registry.maxoffset = 0 local ids = self:get_sorted_refs() @@ -629,6 +654,7 @@ function CiteProc:makeBibliography(bibsection) linespacing = self.style.bibliography.line_spacing, entryspacing = self.style.bibliography.entry_spacing, maxoffset = self.registry.maxoffset, + widest_label = self.registry.widest_label, bibstart = bib_start, bibend = bib_end, entry_ids = util.clone(self.registry.reflist), diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-ir-node.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-ir-node.lua index 5770d8d0dc0..b9324a15bb8 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-ir-node.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-ir-node.lua @@ -6,7 +6,13 @@ local irnode = {} -local util = require("citeproc-util") +local util + +if kpse then + util = require("citeproc-util") +else + util = require("citeproc.util") +end ---@class IrNode 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 c8fcf475a34..1d734c43acc 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 @@ -8,6 +8,7 @@ local core = {} local citeproc = require("citeproc") local bibtex2csl -- = require("citeproc-bibtex-parser") -- load on demand +local unicode = require("citeproc-unicode") local util = citeproc.util require("lualibs") local latex_parser = require("citeproc-latex-parser") @@ -22,7 +23,7 @@ core.item_dict = {} function core.read_file(file_name, ftype, file_info) if file_info then - file_info = util.capitalize(file_info) + file_info = unicode.capitalize(file_info) else file_info = "File" end @@ -40,6 +41,7 @@ function core.read_file(file_name, ftype, file_info) return nil end local contents = file:read("*a") + contents = util.remove_bom(contents) file:close() return contents end @@ -139,6 +141,11 @@ function core.make_citeproc_sys(data_files) return citeproc_sys end +---comment +---@param style_name string +---@param data_files string[] +---@param lang string? +---@return CiteProc? function core.init(style_name, data_files, lang) if style_name == "" or #data_files == 0 then return nil @@ -288,23 +295,47 @@ function core.update_cited_and_uncited_ids(engine, citations) end + +---Convert to a filter object described in +--- <https://citeproc-js.readthedocs.io/en/latest/running.html#selective-output-with-makebibliography> +---@param filter_str string e.g., "type={book},notcategory={csl},notcategory={tex}" +---@return table function core.parser_filter(filter_str) - -- util.debug(filter_str) - local filter = latex_parser.parse_prop(filter_str) - for filter_type, conditions in pairs(filter) do - conditions = latex_parser.parse_seq(conditions) - filter[filter_type] = conditions - for i, condition in ipairs(conditions) do - conditions[i] = latex_parser.parse_prop(condition) + local conditions = {} + for i, condition in ipairs(latex_parser.parse_seq(filter_str)) do + local negative + local field, value = string.match(condition, "(%w+)%s*=%s*{([^}]+)}") + if field then + if string.match(field, "^not") then + negative = true + field = string.gsub(field, "^not", "") + end + if field == "category" then + field = "categories" + end + if field == "keyword" or field == "type" or field == "categories" then + table.insert(conditions, { + field = field, + value = value, + negative = negative, + }) + end end end - return filter + -- util.debug(conditions) + return {select = conditions} end -function core.make_bibliography(engine, filter_str) +---comment +---@param engine CiteProc +---@param option_str string +---@return unknown +function core.make_bibliography(engine, option_str) local filter - if filter_str then - filter = core.parser_filter(filter_str) + local options = {} + if option_str and option_str ~= "" then + options = latex_parser.parse_prop(option_str) + filter = core.parser_filter(option_str) end local result = engine:makeBibliography(filter) @@ -313,20 +344,23 @@ function core.make_bibliography(engine, filter_str) local res = "" - local bib_options = {} - bib_options["class"] = engine:get_style_class() - local bib_option_list = {"class"} + ---@type table<string, any> + local bib_options = { + index = options.index or "1" + } local bib_option_map = { + ["hanging-indent"] = "hangingindent", ["entry-spacing"] = "entryspacing", ["line-spacing"] = "linespacing", - ["hanging-indent"] = "hangingindent", + ["widest-label"] = "widest_label", } local bib_option_order = { - "class", + "index", "hanging-indent", "line-spacing", "entry-spacing", + "widest-label", } for option, param in pairs(bib_option_map) do @@ -335,20 +369,23 @@ function core.make_bibliography(engine, filter_str) end end - local bib_options_str = "\\cslsetup{\n" + local bib_option_list = {} for _, option in ipairs(bib_option_order) do local value = bib_options[option] - if value then - bib_options_str = bib_options_str .. string.format(" %s = %s,\n", option, tostring(value)) + if value and value ~= "" then + table.insert(bib_option_list, string.format("%s = %s", option, tostring(value))) end end - bib_options_str = bib_options_str .. "}\n" - res = res .. bib_options_str .. "\n" + local bib_options_str = table.concat(bib_option_list, ", ") -- util.debug(params.bibstart) - if params.bibstart then - res = res .. params.bibstart - end + -- if params.bibstart then + -- res = res .. params.bibstart + -- end + + local bibstart = string.format("\\begin{thebibliography}{%s}\n", bib_options_str) + res = res .. bibstart + for _, bib_item in ipairs(bib_items) do res = res .. "\n" .. bib_item diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-data.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-data.lua index d7b5355265b..283d3430d5d 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-data.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-data.lua @@ -44,6 +44,32 @@ return { inline_type = "Formatted", num_args = 0, }, + ["\\mkbibbold"] = { + formatting_key = "font-weight", + formatting_value = "bold", + inline_type = "Formatted", + num_args = 1, + }, + ["\\mkbibemph"] = { + formatting_key = "font-style", + formatting_value = "italic", + inline_type = "Formatted", + num_args = 1, + }, + ["\\mkbibitalic"] = { + formatting_key = "font-style", + formatting_value = "italic", + inline_type = "Formatted", + num_args = 1, + }, + ["\\mkbibquote"] = { + inline_type = "Quoted", + num_args = 1, + }, + ["\\noopsort"] = { + action = "gobble", + num_args = 1, + }, ["\\sl"] = { formatting_key = "font-style", formatting_value = "oblique", @@ -466,109 +492,124 @@ return { }, 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", + code_point = "0308", + composites = { + 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", + }, }, ["\\#"] = "0023", ["\\$"] = "0024", ["\\%"] = "0025", ["\\&"] = "0026", ["\\'"] = { - 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", - ["\\AE"] = "01FC", - ["\\ae"] = "01FD", - ["\\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", - ["Æ"] = "01FC", - ["æ"] = "01FD", + code_point = "0301", + composites = { + 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", + ["\\AE"] = "01FC", + ["\\ae"] = "01FD", + ["\\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", + ["Æ"] = "01FC", + ["æ"] = "01FD", + }, }, ["\\-"] = "00AD", ["\\."] = { - [""] = "02D9", - 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", + code_point = "0307", + composites = { + [""] = "02D9", + 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", + }, }, ["\\="] = { - 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", - ["Æ"] = "01E2", - ["æ"] = "01E3", + code_point = "0304", + composites = { + 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", + ["Æ"] = "01E2", + ["æ"] = "01E3", + }, }, ["\\AA"] = "00C5", ["\\AE"] = "00C6", ["\\DH"] = "00D0", ["\\DJ"] = "0110", ["\\H"] = { - O = "0150", - U = "0170", - o = "0151", - u = "0171", + code_point = "030B", + composites = { + O = "0150", + U = "0170", + o = "0151", + u = "0171", + }, }, ["\\Hwithstroke"] = "0126", ["\\IJ"] = "0132", @@ -579,113 +620,128 @@ return { ["\\SS"] = "1E9E", ["\\TH"] = "00DE", ["\\^"] = { - [""] = "005E", - 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", - j = "0135", - o = "00F4", - s = "015D", - u = "00FB", - w = "0175", - y = "0177", - z = "1E91", + code_point = "0302", + composites = { + [""] = "005E", + 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", + j = "0135", + o = "00F4", + s = "015D", + u = "00FB", + w = "0175", + y = "0177", + z = "1E91", + }, }, ["\\_"] = "005F", ["\\`"] = { - 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", + code_point = "0300", + composites = { + 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", + }, }, ["\\aa"] = "00E5", ["\\ae"] = "00E6", + ["\\b"] = { + code_point = "0332", + }, ["\\bgroup"] = "007B", ["\\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", + code_point = "0327", + composites = { + 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"] = { - A = "1EA0", - B = "1E04", - D = "1E0C", - E = "1EB8", - H = "1E24", - I = "1ECA", - K = "1E32", - L = "1E36", - M = "1E42", - N = "1E46", - O = "1ECC", - R = "1E5A", - S = "1E62", - T = "1E6C", - U = "1EE4", - V = "1E7E", - W = "1E88", - Y = "1EF4", - Z = "1E92", - a = "1EA1", - b = "1E05", - d = "1E0D", - e = "1EB9", - h = "1E25", - i = "1ECB", - k = "1E33", - l = "1E37", - m = "1E43", - n = "1E47", - o = "1ECD", - r = "1E5B", - s = "1E63", - t = "1E6D", - u = "1EE5", - v = "1E7F", - w = "1E89", - y = "1EF5", - z = "1E93", + code_point = "0323", + composites = { + A = "1EA0", + B = "1E04", + D = "1E0C", + E = "1EB8", + H = "1E24", + I = "1ECA", + K = "1E32", + L = "1E36", + M = "1E42", + N = "1E46", + O = "1ECC", + R = "1E5A", + S = "1E62", + T = "1E6C", + U = "1EE4", + V = "1E7E", + W = "1E88", + Y = "1EF4", + Z = "1E92", + a = "1EA1", + b = "1E05", + d = "1E0D", + e = "1EB9", + h = "1E25", + i = "1ECB", + k = "1E33", + l = "1E37", + m = "1E43", + n = "1E47", + o = "1ECD", + r = "1E5B", + s = "1E63", + t = "1E6D", + u = "1EE5", + v = "1E7F", + w = "1E89", + y = "1EF5", + z = "1E93", + }, }, ["\\dh"] = "00F0", ["\\dj"] = "0111", @@ -701,24 +757,29 @@ return { ["\\ij"] = "0133", ["\\j"] = "0237", ["\\k"] = { - [""] = "02DB", - A = "0104", - E = "0118", - I = "012E", - O = "01EA", - U = "0172", - ["\\i"] = "012F", - a = "0105", - e = "0119", - i = "012F", - o = "01EB", - u = "0173", + code_point = "0328", + composites = { + [""] = "02DB", + A = "0104", + E = "0118", + I = "012E", + O = "01EA", + U = "0172", + ["\\i"] = "012F", + a = "0105", + e = "0119", + i = "012F", + o = "01EB", + u = "0173", + }, }, ["\\l"] = "0142", ["\\lbrack"] = "005B", ["\\lq"] = "2018", ["\\mbox"] = { - ["-"] = "2011", + composites = { + ["-"] = "2011", + }, }, ["\\ng"] = "014B", ["\\nobreak"] = "FEFF", @@ -729,10 +790,13 @@ return { ["\\quotedblbase"] = "201E", ["\\quotesinglbase"] = "201A", ["\\r"] = { - A = "00C5", - U = "016E", - a = "00E5", - u = "016F", + code_point = "030A", + composites = { + A = "00C5", + U = "016E", + a = "00E5", + u = "016F", + }, }, ["\\rbrack"] = "005D", ["\\rq"] = "2019", @@ -762,10 +826,12 @@ return { ["\\textcircledP"] = "2117", ["\\textcolonmonetary"] = "20A1", ["\\textcommabelow"] = { - S = "0218", - T = "021A", - s = "0219", - t = "021B", + composites = { + S = "0218", + T = "021A", + s = "0219", + t = "021B", + }, }, ["\\textcompwordmark"] = "200C", ["\\textcopyright"] = "00A9", @@ -845,70 +911,79 @@ return { ["\\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", + code_point = "0306", + composites = { + 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", - j = "01F0", - k = "01E9", - l = "013E", - n = "0148", - o = "01D2", - r = "0159", - s = "0161", - t = "0165", - u = "01D4", - z = "017E", + code_point = "030C", + composites = { + 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", + j = "01F0", + k = "01E9", + l = "013E", + n = "0148", + o = "01D2", + r = "0159", + s = "0161", + t = "0165", + u = "01D4", + z = "017E", + }, }, ["\\{"] = "007B", ["\\}"] = "007D", ["\\~"] = { - [""] = "007E", - A = "00C3", - I = "0128", - N = "00D1", - O = "00D5", - U = "0168", - ["\\i"] = "0129", - a = "00E3", - i = "0129", - n = "00F1", - o = "00F5", - u = "0169", + code_point = "0303", + composites = { + [""] = "007E", + 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-latex-parser.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-parser.lua index 26068889989..3c7aac601c2 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-parser.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-latex-parser.lua @@ -6,10 +6,21 @@ local latex_parser = {} +local bibtex_parser +local latex_data +local markup +local util +if kpse then + latex_data = require("citeproc-latex-data") + markup = require("citeproc-output") + util = require("citeproc-util") +else + latex_data = require("citeproc.latex-data") + markup = require("citeproc.output") + util = require("citeproc.util") +end + local lpeg = require("lpeg") -local latex_data = require("citeproc-latex-data") -local markup = require("citeproc-output") -local util = require("citeproc-util") -- Convert LaTeX string to Unicode string @@ -35,6 +46,7 @@ end -- Convert LaTeX string to string with HTML-like tags function latex_parser.latex_to_pseudo_html(str, strict, case_protection) local ast = latex_parser.latex_grammar:match(str) + -- util.debug(ast) latex_parser.convert_ast_to_unicode(ast) local inlines = latex_parser.convert_tokens_to_inlines(ast, strict, case_protection) -- util.debug(inlines) @@ -196,13 +208,20 @@ local function _remove_braces_of_diacritic(tokens, i, orig_first_token) end end -local function _replace_diacritic_with_unicode(tokens, i, code_point) +---comment +---@param tokens any +---@param i any +---@param command_info string | table +local function _replace_diacritic_with_unicode(tokens, i, command_info) local unicode_char - if type(code_point) == "string" then - unicode_char = utf8.char(tonumber(code_point, 16)) + if type(command_info) == "string" then + unicode_char = utf8.char(tonumber(command_info, 16)) tokens[i] = unicode_char - elseif type(code_point) == "table" then + elseif type(command_info) == "table" then + if not command_info.composites then + error('Missing "composites"') + end -- The command takes an argument (\"{o}) local arg local j = i + 1 @@ -230,12 +249,19 @@ local function _replace_diacritic_with_unicode(tokens, i, code_point) end end end - if arg and code_point[arg] then - unicode_char = utf8.char(tonumber(code_point[arg], 16)) + if arg and command_info.composites[arg] then + unicode_char = utf8.char(tonumber(command_info.composites[arg], 16)) tokens[i] = unicode_char for k = j, i + 1, -1 do table.remove(tokens, k) end + elseif command_info.code_point then + -- Move the Diacritic after the next token + unicode_char = utf8.char(tonumber(command_info.code_point, 16)) + for k = i, j - 1 do + tokens[k] = tokens[k + 1] + end + tokens[j] = unicode_char end end end @@ -253,9 +279,9 @@ function latex_parser.convert_ast_to_unicode(tokens) elseif token.type == "control_sequence" then local cs = token - local code_point = latex_data.unicode_commands[cs.name] - if code_point then - _replace_diacritic_with_unicode(tokens, i, code_point) + local command_info = latex_data.unicode_commands[cs.name] + if command_info then + _replace_diacritic_with_unicode(tokens, i, command_info) end end end @@ -309,6 +335,14 @@ function latex_parser.convert_cs_to_inlines(tokens, i, strict, case_protection) -- NoCase table.insert(inlines, markup[inline_type]:new(arg_inlines)) end + + elseif command_info.action then + if command_info.action == "gobble" then + table.remove(tokens, i) + for j = 1, command_info.num_args do + table.remove(tokens, i) + end + end end else @@ -331,7 +365,7 @@ function latex_parser.convert_cs_to_inlines(tokens, i, strict, case_protection) return inlines, i end -function latex_parser.convert_group_to_inlines(token, strict, case_protection) +function latex_parser.convert_group_to_inlines(token, strict, case_protection, force_add_braces) if case_protection then local first_token = token.contents[1] if type(first_token) == "table" and first_token.type == "control_sequence" then @@ -340,6 +374,10 @@ function latex_parser.convert_group_to_inlines(token, strict, case_protection) end end local inlines = latex_parser.convert_tokens_to_inlines(token.contents, strict, false) + if #inlines == 0 then + -- Empty group like `{\\noopsort{1973b}}` + return inlines + end if case_protection then inlines = {markup.NoCase:new(inlines)} end @@ -351,7 +389,7 @@ function latex_parser.convert_group_to_inlines(token, strict, case_protection) break end end - if has_command then + if force_add_braces or has_command then table.insert(inlines, 1, markup.Code:new("{")) table.insert(inlines, markup.Code:new("}")) end @@ -360,7 +398,9 @@ function latex_parser.convert_group_to_inlines(token, strict, case_protection) end ----comment +---A group is surrounded with braces in these cases: +---1. Following a command; e.g, `\textbf{foo}` and `\textcolor{red}{flag}` +---2. Containing a command; e.g, {\bfseies foo} ---@param tokens table ---@param strict boolean? Convert unrecognized LaTeX command to Code element ---@param case_protection boolean? Protect case with BibTeX's rules @@ -369,6 +409,7 @@ function latex_parser.convert_tokens_to_inlines(tokens, strict, case_protection) local inlines = {} local i = 1 + local add_group_braces = false while i <= #tokens do local token = tokens[i] if type(token) == "string" then @@ -382,15 +423,17 @@ function latex_parser.convert_tokens_to_inlines(tokens, strict, case_protection) end end table.insert(inlines, markup.PlainText:new(token)) + add_group_braces = false elseif type(token) == "table" then if token.type == "control_sequence" then local cs_inlines cs_inlines, i = latex_parser.convert_cs_to_inlines(tokens, i, strict, case_protection) util.extend(inlines, cs_inlines) + add_group_braces = true elseif token.type == "group" then - util.extend(inlines, latex_parser.convert_group_to_inlines(token, strict, case_protection)) + util.extend(inlines, latex_parser.convert_group_to_inlines(token, strict, case_protection, add_group_braces)) elseif token.type == "math" then table.insert(inlines, markup.MathTeX:new(token.text)) diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-bibliography.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-bibliography.lua index 6db7e53e678..93797196a2f 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-bibliography.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-bibliography.lua @@ -6,18 +6,38 @@ local bibliography_module = {} -local dom = require("luaxml-domobject") +local context +local element +local ir_node +local output +local node_names +local util + +if kpse then + context = require("citeproc-context") + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + node_names = require("citeproc-node-names") + util = require("citeproc-util") +else + context = require("citeproc.context") + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + node_names = require("citeproc.node-names") + util = require("citeproc.util") +end -local Context = require("citeproc-context").Context -local IrState = require("citeproc-context").IrState -local Element = require("citeproc-element").Element -local IrNode = require("citeproc-ir-node").IrNode -local Rendered = require("citeproc-ir-node").Rendered -local SeqIr = require("citeproc-ir-node").SeqIr -local PlainText = require("citeproc-output").PlainText -local DisamStringFormat = require("citeproc-output").DisamStringFormat -local YearSuffix = require("citeproc-ir-node").YearSuffix -local util = require("citeproc-util") +local Context = context.Context +local IrState = context.IrState +local Element = element.Element +local IrNode = ir_node.IrNode +local Rendered = ir_node.Rendered +local SeqIr = ir_node.SeqIr +local PlainText = output.PlainText +local DisamStringFormat = output.DisamStringFormat +local YearSuffix = ir_node.YearSuffix ---@class Bibliography: Element @@ -71,7 +91,7 @@ function Bibliography:from_node(node, style) o:set_attribute(node, "subsequent-author-substitute") o:set_attribute(node, "subsequent-author-substitute-rule") - local name_inheritance = require("citeproc-node-names").Name:new() + local name_inheritance = node_names.Name:new() for key, value in pairs(style.name_inheritance) do if value ~= nil then name_inheritance[key] = value diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-choose.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-choose.lua index 4a9329c2972..5e6f5993ffd 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-choose.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-choose.lua @@ -6,9 +6,22 @@ local choose = {} -local Element = require("citeproc-element").Element -local SeqIr = require("citeproc-ir-node").SeqIr -local util = require("citeproc-util") +local element +local ir_node +local util + +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + util = require("citeproc.util") +end + +local Element = element.Element +local SeqIr = ir_node.SeqIr -- [Choose](https://docs.citationstyles.org/en/stable/specification.html#choose) local Choose = Element:derive("choose") diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-citation.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-citation.lua index aca01a7c930..7812c33a9bf 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-citation.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-citation.lua @@ -1,4 +1,3 @@ - -- -- Copyright (c) 2021-2023 Zeping Lee -- Released under the MIT license. @@ -7,23 +6,43 @@ local citation_module = {} -local dom = require("luaxml-domobject") - -local Context = require("citeproc-context").Context -local IrState = require("citeproc-context").IrState -local Element = require("citeproc-element").Element -local IrNode = require("citeproc-ir-node").IrNode -local Rendered = require("citeproc-ir-node").Rendered -local SeqIr = require("citeproc-ir-node").SeqIr -local YearSuffix = require("citeproc-ir-node").YearSuffix -local Micro = require("citeproc-output").Micro -local Formatted = require("citeproc-output").Formatted -local PlainText = require("citeproc-output").PlainText -local InlineElement = require("citeproc-output").InlineElement -local CiteInline = require("citeproc-output").CiteInline -local DisamStringFormat = require("citeproc-output").DisamStringFormat -local SortStringFormat = require("citeproc-output").SortStringFormat -local util = require("citeproc-util") +local context +local element +local ir_node +local output +local node_names +local util + +if kpse then + context = require("citeproc-context") + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + node_names = require("citeproc-node-names") + util = require("citeproc-util") +else + context = require("citeproc.context") + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + node_names = require("citeproc.node-names") + util = require("citeproc.util") +end + +local Context = context.Context +local IrState = context.IrState +local Element = element.Element +local IrNode = ir_node.IrNode +local Rendered = ir_node.Rendered +local SeqIr = ir_node.SeqIr +local YearSuffix = ir_node.YearSuffix +local Micro = output.Micro +local Formatted = output.Formatted +local PlainText = output.PlainText +local InlineElement = output.InlineElement +local CiteInline = output.CiteInline +local DisamStringFormat = output.DisamStringFormat +local SortStringFormat = output.SortStringFormat ---@class Citation: Element @@ -95,7 +114,7 @@ function Citation:from_node(node, style) -- Note Distance o:set_number_attribute(node, "near-note-distance") - local name_inheritance = require("citeproc-node-names").Name:new() + local name_inheritance = node_names.Name:new() for key, value in pairs(style.name_inheritance) do if value ~= nil then name_inheritance[key] = value diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-date.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-date.lua index 94d5365849c..1e0f11d25e3 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-date.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-date.lua @@ -6,12 +6,28 @@ local date_module = {} -local Element = require("citeproc-element").Element -local IrNode = require("citeproc-ir-node").IrNode -local Rendered = require("citeproc-ir-node").Rendered -local SeqIr = require("citeproc-ir-node").SeqIr -local PlainText = require("citeproc-output").PlainText -local util = require("citeproc-util") +local element +local ir_node +local output +local util + +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + util = require("citeproc.util") +end + +local Element = element.Element +local IrNode = ir_node.IrNode +local Rendered = ir_node.Rendered +local SeqIr = ir_node.SeqIr +local PlainText = output.PlainText -- [Date](https://docs.citationstyles.org/en/stable/specification.html#date) diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-group.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-group.lua index ecc638ee554..a89199128fa 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-group.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-group.lua @@ -6,9 +6,22 @@ local group = {} -local SeqIr = require("citeproc-ir-node").SeqIr -local Element = require("citeproc-element").Element -local util = require("citeproc-util") +local element +local ir_node +local util + +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + util = require("citeproc.util") +end + +local SeqIr = ir_node.SeqIr +local Element = element.Element local Group = Element:derive("group") diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-label.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-label.lua index 1861c990495..6f89bdb123c 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-label.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-label.lua @@ -6,11 +6,27 @@ local label = {} -local Element = require("citeproc-element").Element -local IrNode = require("citeproc-ir-node").IrNode -local Rendered = require("citeproc-ir-node").Rendered -local PlainText = require("citeproc-output").PlainText -local util = require("citeproc-util") +local element +local ir_node +local output +local util + +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + util = require("citeproc.util") +end + +local Element = element.Element +local IrNode = ir_node.IrNode +local Rendered = ir_node.Rendered +local PlainText = output.PlainText -- [Label](https://docs.citationstyles.org/en/stable/specification.html#label) diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-layout.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-layout.lua index 4996ddd9f21..e6e9310be6c 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-layout.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-layout.lua @@ -6,9 +6,22 @@ local layout = {} -local Element = require("citeproc-element").Element -local SeqIr = require("citeproc-ir-node").SeqIr -local util = require("citeproc-util") +local element +local ir_node +local util + +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + util = require("citeproc.util") +end + +local Element = element.Element +local SeqIr = ir_node.SeqIr ---@class Layout: Element diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-locale.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-locale.lua index 394785477f9..99c32a878fd 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-locale.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-locale.lua @@ -6,8 +6,18 @@ local locale = {} -local Element = require("citeproc-element").Element -local util = require("citeproc-util") +local element +local util + +if kpse then + element = require("citeproc-element") + util = require("citeproc-util") +else + element = require("citeproc.element") + util = require("citeproc.util") +end + +local Element = element.Element local Locale = Element:derive("locale") 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 385110c1e9f..9b7fae22639 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 @@ -6,19 +6,36 @@ local names_module = {} -local unicode = require("unicode") +local unicode +local element +local ir_node +local output +local util + +if kpse then + unicode = require("citeproc-unicode") + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + util = require("citeproc-util") +else + unicode = require("citeproc.unicode") + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + util = require("citeproc.util") +end -local IrNode = require("citeproc-ir-node").IrNode -local NameIr = require("citeproc-ir-node").NameIr -local PersonNameIr = require("citeproc-ir-node").PersonNameIr -local SeqIr = require("citeproc-ir-node").SeqIr -local Rendered = require("citeproc-ir-node").Rendered -local InlineElement = require("citeproc-output").InlineElement -local PlainText = require("citeproc-output").PlainText -local SortStringFormat = require("citeproc-output").SortStringFormat +local IrNode = ir_node.IrNode +local NameIr = ir_node.NameIr +local PersonNameIr = ir_node.PersonNameIr +local SeqIr = ir_node.SeqIr +local Rendered = ir_node.Rendered +local InlineElement = output.InlineElement +local PlainText = output.PlainText +local SortStringFormat = output.SortStringFormat -local Element = require("citeproc-element").Element -local util = require("citeproc-util") +local Element = element.Element local Names = Element:derive("names") @@ -869,7 +886,7 @@ function Name:initialize_name(given, with, initialize_with_hyphen) local is_abbreviation = false local first_letter = utf8.char(utf8.codepoint(name)) - if util.is_lower(first_letter) then + if unicode.islower(first_letter) then is_particle = true elseif #name == 1 then is_abbreviation = true @@ -890,14 +907,14 @@ function Name:initialize_name(given, with, initialize_with_hyphen) name_list[i] = name .. with else if self.initialize then - if util.is_upper(name) then + if unicode.isupper(name) then name = first_letter else -- Long abbreviation: "TSerendorjiin" -> "Ts." local abbreviation = "" for _, c in utf8.codes(name) do local char = utf8.char(c) - local lower = unicode.utf8.lower(char) + local lower = unicode.lower(char) if lower == char then break end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-number.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-number.lua index d96b3fe519e..24b970edde3 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-number.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-number.lua @@ -6,11 +6,22 @@ local number_module = {} -local Element = require("citeproc-element").Element +local element +local ir_node +local util -local Rendered = require("citeproc-ir-node").Rendered +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + util = require("citeproc.util") +end -local util = require("citeproc-util") +local Element = element.Element +local Rendered = ir_node.Rendered local Number = Element:derive("number") diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-sort.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-sort.lua index 1cd53c22ef4..04fe46c0457 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-sort.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-sort.lua @@ -6,13 +6,36 @@ local sort = {} -local unicode = require("unicode") +local uca_languages +local uca_ducet +local uca_collator + +local element +local output +local util +local node_date + +if kpse then + uca_languages = require("lua-uca-languages") + uca_ducet = require("lua-uca-ducet") + uca_collator = require("lua-uca-collator") + element = require("citeproc-element") + output = require("citeproc-output") + util = require("citeproc-util") + node_date = require("citeproc-node-date") +else + uca_languages = require("citeproc.lua-uca.languages") + uca_ducet = require("citeproc.lua-uca.ducet") + uca_collator = require("citeproc.lua-uca.collator") + element = require("citeproc.element") + output = require("citeproc.output") + util = require("citeproc.util") + node_date = require("citeproc.node-date") +end -local Element = require("citeproc-element").Element -local Date = require("citeproc-node-date").Date -local names = require("citeproc-node-names") -local InlineElement = require("citeproc-output").InlineElement -local util = require("citeproc-util") +local Element = element.Element +local Date = node_date.Date +local InlineElement = output.InlineElement -- [Sorting](https://docs.citationstyles.org/en/stable/specification.html#sorting) @@ -46,13 +69,8 @@ function Sort:sort(items, state, context) if not Sort.collator then local lang = context.engine.lang local language = string.sub(lang, 1, 2) - -- It's 6 seconds slower to run the whole test-suite if these package - -- loading statements are put in the header. - local uca_ducet = require("lua-uca.lua-uca-ducet") - local uca_collator = require("lua-uca.lua-uca-collator") Sort.collator = uca_collator.new(uca_ducet) if language ~= "en" then - local uca_languages = require("lua-uca.lua-uca-languages") if uca_languages[language] then Sort.collator = uca_languages[language](Sort.collator) else diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-style.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-style.lua index 6c8d184fda1..2fbff540675 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-style.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-style.lua @@ -6,15 +6,35 @@ local style_module = {} -local dom = require("luaxml-domobject") +local dom +local element +local ir_node +local output +local node_names +local util + +if kpse then + dom = require("luaxml-domobject") + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + node_names = require("citeproc-node-names") + util = require("citeproc-util") +else + dom = require("citeproc.luaxml.domobject") + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + node_names = require("citeproc.node-names") + util = require("citeproc.util") +end -local Element = require("citeproc-element").Element -local IrNode = require("citeproc-ir-node").IrNode -local Rendered = require("citeproc-ir-node").Rendered -local SeqIr = require("citeproc-ir-node").SeqIr -local PlainText = require("citeproc-output").PlainText -local DisamStringFormat = require("citeproc-output").DisamStringFormat -local util = require("citeproc-util") +local Element = element.Element +local IrNode = ir_node.IrNode +local Rendered = ir_node.Rendered +local SeqIr = ir_node.SeqIr +local PlainText = output.PlainText +local DisamStringFormat = output.DisamStringFormat local Style = Element:derive("style") @@ -67,7 +87,7 @@ function Style:from_node(node) -- Inheritable Name Options -- https://docs.citationstyles.org/en/stable/specification.html#inheritable-name-options - o.name_inheritance = require("citeproc-node-names").Name:new() + o.name_inheritance = node_names.Name:new() Element.make_name_inheritance(o.name_inheritance, node) if o.page_range_format == "chicago" then diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-text.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-text.lua index b5c9ea61a61..e74ab3e4d91 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-node-text.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-node-text.lua @@ -6,12 +6,28 @@ local text_module = {} -local Element = require("citeproc-element").Element -local Rendered = require("citeproc-ir-node").Rendered -local YearSuffix = require("citeproc-ir-node").YearSuffix -local PlainText = require("citeproc-output").PlainText -local Linked = require("citeproc-output").Linked -local util = require("citeproc-util") +local element +local ir_node +local output +local util + +if kpse then + element = require("citeproc-element") + ir_node = require("citeproc-ir-node") + output = require("citeproc-output") + util = require("citeproc-util") +else + element = require("citeproc.element") + ir_node = require("citeproc.ir-node") + output = require("citeproc.output") + util = require("citeproc.util") +end + +local Element = element.Element +local Rendered = ir_node.Rendered +local YearSuffix = ir_node.YearSuffix +local PlainText = output.PlainText +local Linked = output.Linked -- [Text](https://docs.citationstyles.org/en/stable/specification.html#text) diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-nodes.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-nodes.lua index b1466eee902..fa7ead38e68 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-nodes.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-nodes.lua @@ -4,20 +4,49 @@ -- Repository: https://github.com/zepinglee/citeproc-lua -- -local style = require("citeproc-node-style") -local citation = require("citeproc-node-citation") -local citation = require("citeproc-node-citation") -local bibliography = require("citeproc-node-bibliography") -local locale = require("citeproc-node-locale") -local layout = require("citeproc-node-layout") -local text = require("citeproc-node-text") -local date = require("citeproc-node-date") -local number = require("citeproc-node-number") -local names = require("citeproc-node-names") -local label = require("citeproc-node-label") -local group = require("citeproc-node-group") -local choose = require("citeproc-node-choose") -local sort = require("citeproc-node-sort") +local style +local citation +local bibliography +local locale +local layout +local text +local date +local number +local names +local label +local group +local choose +local sort + +if kpse then + style = require("citeproc-node-style") + citation = require("citeproc-node-citation") + bibliography = require("citeproc-node-bibliography") + locale = require("citeproc-node-locale") + layout = require("citeproc-node-layout") + text = require("citeproc-node-text") + date = require("citeproc-node-date") + number = require("citeproc-node-number") + names = require("citeproc-node-names") + label = require("citeproc-node-label") + group = require("citeproc-node-group") + choose = require("citeproc-node-choose") + sort = require("citeproc-node-sort") +else + style = require("citeproc.node-style") + citation = require("citeproc.node-citation") + bibliography = require("citeproc.node-bibliography") + locale = require("citeproc.node-locale") + layout = require("citeproc.node-layout") + text = require("citeproc.node-text") + date = require("citeproc.node-date") + number = require("citeproc.node-number") + names = require("citeproc.node-names") + label = require("citeproc.node-label") + group = require("citeproc.node-group") + choose = require("citeproc.node-choose") + sort = require("citeproc.node-sort") +end local nodes = { ["style"] = style.Style, diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-output.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-output.lua index b162328e666..aa1a733c3ef 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-output.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-output.lua @@ -6,11 +6,22 @@ local output_module = {} -local unicode = require("unicode") -local citeproc_unicode = require("citeproc-unicode") -local dom = require("luaxml-domobject") +local uni_utf8 +local unicode +local dom +local util -local util = require("citeproc-util") +if kpse then + uni_utf8 = require("unicode").utf8 + unicode = require("citeproc-unicode") + dom = require("luaxml-domobject") + util = require("citeproc-util") +else + uni_utf8 = require("lua-utf8") + unicode = require("citeproc.unicode") + dom = require("citeproc.luaxml.domobject") + util = require("citeproc.util") +end local LocalizedQuotes = { @@ -609,7 +620,7 @@ end function InlineElement:capitalize_first_term() -- util.debug(self) if self._type == "PlainText" then - self.value = util.capitalize(self.value) + self.value = unicode.capitalize(self.value) elseif self._type ~= "Code" and self._type ~= "MathML" and self._type ~= "MathTeX" then if self.inlines[1] then self.inlines[1]:capitalize_first_term() @@ -728,9 +739,9 @@ end ---@param str string ---@return boolean local function is_str_sentence_case(str) - local words = citeproc_unicode.words(str) + local words = unicode.words(str) for _, word in ipairs(words) do - if util.is_lower(word) and not util.stop_words[word] then + if unicode.islower(word) and not util.stop_words[word] then -- util.debug(word) return true end @@ -851,12 +862,12 @@ function OutputFormat:apply_text_case_inner(inlines, text_case, seen_one, is_upp end local function transform_lowercase(str) - return string.gsub(str, utf8.charpattern, unicode.utf8.lower) + return unicode.lower(str) end local function transform_uppercase(str) -- TODO: locale specific uppercase: textcase_LocaleUnicode.txt - return string.gsub(str, utf8.charpattern, unicode.utf8.upper) + return unicode.upper(str) end ---comment @@ -866,9 +877,11 @@ end ---@return string local function transform_first_word(str, is_first, transform) if is_first then - local segments = citeproc_unicode.split_word_bounds(str) + local segments = unicode.split_word_bounds(str) for i, segment in ipairs(segments) do - if citeproc_unicode.isalnum(segment) then + -- bugreports_ThesisUniversityAppearsTwice.txt: "Ph.D" + if uni_utf8.match(segment, "%a") then + -- util.debug(segment) segments[i] = transform(segment) break end @@ -894,7 +907,7 @@ local SegmentType = { ---@param transform function ---@return string local function transform_each_word(str, seen_one, is_last_inline, transform) - local segments = citeproc_unicode.split_word_bounds(str) + local segments = unicode.split_word_bounds(str) -- util.debug(segments) local segment_type_list = {} @@ -903,11 +916,11 @@ local function transform_each_word(str, seen_one, is_last_inline, transform) segment_type_list[i] = SegmentType.Other -- Do not use isalnum(): "can't" - if unicode.grapheme.match(segment, "%w") then + if uni_utf8.match(segment, "%w") then segment_type_list[i] = SegmentType.Word last_word_idx = i - elseif unicode.grapheme.match(segment, "%p") then + elseif uni_utf8.match(segment, "%p") then segment_type_list[i] = SegmentType.Puctuation if segment == "!" or segment == "?" then segment_type_list[i] = SegmentType.EndingPunctuation @@ -934,7 +947,7 @@ local function transform_each_word(str, seen_one, is_last_inline, transform) -- util.debug(segment) -- util.debug(after_colon) -- See "07-x" in `textcase_LastChar.txt` - if not (segments[i-1] == "-" and unicode.grapheme.len(segment) == 1) then + if not (segments[i-1] == "-" and unicode.len(segment) == 1) then segments[i] = transform(segment, is_first_word, after_colon, is_last_word, ignore_stop_word) end @@ -958,8 +971,8 @@ end ---@param word string ---@return string local function transform_capitalize_word_if_lower(word) - if citeproc_unicode.islower(word) then - local res = string.gsub(word, utf8.charpattern, unicode.utf8.upper, 1) + if unicode.islower(word) then + local res = unicode.capitalize(word) return res else return word @@ -973,18 +986,19 @@ local function title_case_word(word, is_first, after_end_punct, is_last, ignore_ -- util.debug(word) -- util.debug(ignore_stop_word) if (is_first or is_last or after_end_punct or ignore_stop_word or not util.stop_words[word]) - and string.match(word, "%a") and citeproc_unicode.islower(word) then - return citeproc_unicode.capitalize(word) + and string.match(word, "%a") and unicode.islower(word) then + return unicode.capitalize(word) else return word end end local function transform_lowercase_if_capitalize(word, is_first, after_end_punct, is_last, is_stop_word) + -- util.debug(word) if not (is_first or after_end_punct) then local is_capitalize_word = false - local lower_first = string.gsub(word, utf8.charpattern, unicode.utf8.lower, 1) - if util.is_lower(lower_first) then + local lower_first = string.gsub(word, utf8.charpattern, unicode.lower, 1) + if unicode.islower(lower_first) then return lower_first else return word @@ -1560,7 +1574,7 @@ local LatexWriter = Markup:new() LatexWriter.markups = { ["bibstart"] = function (engine) - return string.format("\\begin{thebibliography}{%s}\n", engine.registry.longest_label) + return string.format("\\begin{thebibliography}{%s}\n", engine.registry.widest_label) end, ["bibend"] = "\\end{thebibliography}", ["@font-style/normal"] = "{\\normalshape %s}", @@ -1633,7 +1647,7 @@ function LatexWriter:write_display(inline, context) local len = utf8.len(str) if len > context.engine.registry.maxoffset then context.engine.registry.maxoffset = len - context.engine.registry.longest_label = str + context.engine.registry.widest_label = str end end @@ -1741,10 +1755,11 @@ function HtmlWriter:write_display(inline, context) if inline.div == "left-margin" then local plainter_text_writer = output_module.PlainTextWriter:new() local str = plainter_text_writer:write_inline(inline, context) + --TODO: width of CJK characters local len = utf8.len(str) if len > context.engine.registry.maxoffset then context.engine.registry.maxoffset = len - context.engine.registry.longest_label = str + context.engine.registry.widest_label = str end end diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc-unicode.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc-unicode.lua index 530206ae3fb..2aa12b29bf3 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-unicode.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-unicode.lua @@ -6,14 +6,36 @@ local unicode = {} -local sln = require("unicode") -local uni_case = require("lua-uni-case") -local uni_words = nil -if kpse.find_file("lua-uni-words", "lua") then - uni_words = require("lua-uni-words") +local uni_utf8 +local uni_algos_words +local uni_algos_case +local util + +if kpse then + -- Load `slnunicode` if in LuaTeX + uni_utf8 = require("unicode").utf8 + if kpse.find_file("lua-uni-words", "lua") then + uni_algos_words = require("lua-uni-words") + end + uni_algos_case = require("lua-uni-case") + util = require("citeproc-util") +else + uni_utf8 = require("lua-utf8") + if not utf8 then + -- Lua < 5.3 + utf8 = uni_utf8 + end + uni_algos_words = require("citeproc.lua-uni-algos.words") + uni_algos_case = require("citeproc.lua-uni-algos.case") + util = require("citeproc.util") end -local util = require("citeproc-util") + +---@param str any +---@return integer +function unicode.len(str) + return uni_utf8.len(str) +end ---Return a copy of the string with its first character capitalized and the rest lowercased. @@ -26,7 +48,7 @@ function unicode.capitalize(str, locale) end -- TODO: locale and unicode titlecase Lt str = unicode.lower(str, locale) - str = sln.grapheme.gsub(str, ".", sln.grapheme.upper, 1) + str = uni_utf8.gsub(str, ".", uni_utf8.upper, 1) return str end @@ -43,7 +65,7 @@ function unicode.casefold(str, locale) if locale and string.match(locale, "^tr") then enable_special = true end - return uni_case.casefold(str, true, enable_special) + return uni_algos_case.casefold(str, true, enable_special) end @@ -54,7 +76,7 @@ function unicode.isalnum(str) if type(str) ~= "string" then error(string.format("bad argument #1 to 'isalnum' (string expected, got %s)", type(str))) end - return sln.grapheme.match(str, "^%w+$") ~= nil + return uni_utf8.match(str, "^%w+$") ~= nil end @@ -65,7 +87,7 @@ function unicode.isalpha(str) if type(str) ~= "string" then error(string.format("bad argument #1 to 'isalpha' (string expected, got %s)", type(str))) end - return sln.grapheme.match(str, "^%a+$") ~= nil + return uni_utf8.match(str, "^%a+$") ~= nil end @@ -99,7 +121,7 @@ function unicode.islower(str) error(string.format("bad argument #1 to 'islower' (string expected, got %s)", type(str))) end --TODO: No titlecased letters - return sln.grapheme.find(str, "%l") and not sln.grapheme.find(str, "%u") + return uni_utf8.find(str, "%l") and not uni_utf8.find(str, "%u") end @@ -114,6 +136,16 @@ function unicode.isnumeric(str) end +---@param str string +---@return boolean +function unicode.ispunct(str) + if type(str) ~= "string" then + error(string.format("bad argument #1 to 'isnumeric' (string expected, got %s)", type(str))) + end + return uni_utf8.match(str, "^%p+$") ~= nil +end + + -- ---Return True if the string is a titlecased string and there is at least one character, for example uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise. -- ---@param str string -- ---@return boolean @@ -134,7 +166,7 @@ function unicode.isupper(str) error(string.format("bad argument #1 to 'isupper' (string expected, got %s)", type(str))) end --TODO: No titlecased letters - return sln.grapheme.find(str, "%u") and not sln.grapheme.find(str, "%l") + return uni_utf8.find(str, "%u") and not uni_utf8.find(str, "%l") end @@ -147,7 +179,7 @@ function unicode.lower(str, locale) error(string.format("bad argument #1 to 'lower' (string expected, got %s)", type(str))) end -- TODO: locale - return sln.grapheme.lower(str) + return uni_utf8.lower(str) end @@ -172,7 +204,7 @@ function unicode.upper(str, locale) error(string.format("bad argument #1 to 'upper' (string expected, got %s)", type(str))) end -- TODO: locale - return sln.grapheme.lower(str) + return uni_utf8.upper(str) end @@ -189,8 +221,8 @@ local CharState = { ---@return string[] function unicode.words(str) local words = {} - if uni_words then - for _, _, segment in uni_words.word_boundaries(str) do + if uni_algos_words then + for _, _, segment in uni_algos_words.word_boundaries(str) do if unicode.isalnum(segment) then table.insert(words, segment) end @@ -200,9 +232,9 @@ function unicode.words(str) -- A naive implementation local state = CharState.Other local last_idx = 1 - for idx, char in sln.grapheme.gmatch(str, "()(.)") do + for idx, char in uni_utf8.gmatch(str, "()(.)") do local new_state = CharState.Other - if sln.grapheme.match(char, "%w") or char == "'" or char == "’" or char == "`" then + if uni_utf8.match(char, "%w") or char == "'" or char == "’" or char == "`" then new_state = CharState.Word else new_state = CharState.Other @@ -231,39 +263,56 @@ end ---@param str string ---@return string[] function unicode.split_word_bounds(str) + -- util.debug(str) local segments = {} - if uni_words then - for _, _, segment in uni_words.word_boundaries(str) do + if uni_algos_words then + for _, _, segment in uni_algos_words.word_boundaries(str) do table.insert(segments, segment) end + -- textcase_NoSpaceBeforeApostrophe.txt: "Marcus Shafi`" -> ["Marcus" "Shafi`"] + for i = #segments, 1, -1 do + local segment = segments[i] + if segment == "`" then + if i < #segments and not uni_utf8.match(segments[i+1], "^%s") then + segments[i] = segment .. segments[i+1] + table.remove(segments, i+1) + end + if i > 1 and not uni_utf8.match(segments[i-1], "%s") then + segments[i-1] = segments[i-1] .. segments[i] + table.remove(segments, i) + end + end + end + -- util.debug(segments) else -- A naive implementation local state = CharState.Other - local last_idx = 1 - for idx, char in sln.grapheme.gmatch(str, "()(.)") do + local segment = "" + for idx, code_point in utf8.codes(str) do + local char = utf8.char(code_point) local new_state = CharState.Other - if sln.grapheme.match(char, "%w") or char == "'" or char == "’" or char == "`" then + if uni_utf8.match(char, "%w") or char == "'" or char == "’" or char == "`" then new_state = CharState.Word - elseif sln.grapheme.match(char, "%p") then + elseif uni_utf8.match(char, "%p") then new_state = CharState.Punctuation - elseif sln.grapheme.match(char, "%s") then + elseif uni_utf8.match(char, "%s") then new_state = CharState.Space else new_state = CharState.Other end if new_state ~= state then - if idx > 1 then - local segment = string.sub(str, last_idx, idx - 1) + if segment ~= "" then table.insert(segments, segment) + segment = "" end state = new_state - last_idx = idx end + segment = segment .. char end - local segment = string.sub(str, last_idx, #str) table.insert(segments, segment) + -- util.debug(segments) end return segments 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 92fc1d49d72..8cd00159f69 100644 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc-util.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc-util.lua @@ -6,8 +6,14 @@ local util = {} --- load `slnunicode` from LuaTeX -local unicode = require("unicode") +local uni_utf8 +if kpse then + uni_utf8 = require("unicode").utf8 +else + uni_utf8 = require("lua-utf8") +end + + local inspect -- only load it when debugging local journal_data = nil -- load as needed @@ -80,6 +86,25 @@ function util.to_list(str) return util.split(str) end + +--- Concat with CJK or western colon +---@param main_title string +---@param substitle string +function util.join_title(main_title, substitle) + local code_point = utf8.codepoint(main_title, utf8.len(main_title)) + if util.is_cjk_char(code_point) then + return main_title .. ":" .. substitle + else + code_point = utf8.codepoint(substitle, 1) + if util.is_cjk_char(code_point) then + return main_title .. ":" .. substitle + else + return main_title .. ": " .. substitle + end + end +end + + function util.to_ordinal (n) -- assert(type(n) == "number") local last_digit = n % 10 @@ -151,6 +176,11 @@ function util.debug(obj) end -- Similar to re.split() in Python +---comment +---@param str string +---@param sep string? +---@param maxsplit integer? +---@return string[] function util.split(str, sep, maxsplit) if type(str) ~= "string" then util.error("Invalid string.") @@ -318,10 +348,6 @@ function util.endswith(str, suffix) return string.sub(str, -#suffix) == suffix end -function util.is_punct(str) - return string.match(str, "^%p$") -end - function util.is_numeric (str) if str == nil or str == "" then return false @@ -551,51 +577,6 @@ util.word_boundaries = { } --- Text-case - ---- Return True if all cased characters in the string are lowercase and there ---- is at least one cased character, False otherwise. ----@param str string ----@return boolean -function util.is_lower(str) - if not str then - print(debug.traceback()) - end - return unicode.utf8.lower(str) == str and unicode.utf8.upper(str) ~= str -end - ---- Return True if all cased characters in the string are uppercase and there ---- is at least one cased character, False otherwise. ----@param str string ----@return boolean -function util.is_upper(str) - return unicode.utf8.upper(str) == str and unicode.utf8.lower(str) ~= str -end - -function util.capitalize(str) - -- if not str then - -- print(debug.traceback()) - -- end - local res = string.gsub(str, utf8.charpattern, unicode.utf8.upper, 1) - return res -end - -function util.sentence (str) - if util.is_upper(str) then - return util.capitalize(str) - else - local output = {} - for i, word in ipairs(util.split(str)) do - if i == 1 and util.is_lower(word) then - table.insert(output, util.capitalize(word)) - else - table.insert(output, word) - end - end - return table.concat(output, " ") - end -end - -- TODO: process multiple words util.stop_words = { ["a"] = true, @@ -717,23 +698,6 @@ util.stop_words = { ["yet"] = true, } -function util.title (str) - local output = {} - local previous = ":" - for i, word in ipairs(util.split(str)) do - local lower = unicode.utf8.lower(word) - if previous ~= ":" and util.stop_words[string.match(lower, "%w+")] then - table.insert(output, lower) - elseif util.is_lower(word) or util.is_upper(word) then - table.insert(output, util.capitalize(word)) - else - table.insert(output, word) - end - end - local res = table.concat(output, " ") - return res -end - function util.all (t) for _, item in ipairs(t) do if not item then @@ -862,6 +826,57 @@ function util.has_cjk_char(s) return false end + +---@param ordinal string +---@return string +function util.convert_ordinal_to_arabic(ordinal) + -- "1st", "2nd" + local numeral, suffix = string.match(ordinal, "^(%d+)(%a+)$") + if numeral then + return numeral + end + local arabic = util.ordinal_to_arabic_map[string.lower(ordinal)] + if arabic then + return arabic + else + return ordinal + end +end + +util.ordinal_to_arabic_map = { + first = "1", + second = "2", + third = "3", + fourth = "4", + fifth = "5", + sixth = "6", + seventh = "7", + eighth = "8", + ninth = "9", + tenth = "10", + eleventh = "11", + twelfth = "12", + thirteenth = "13", + fourteenth = "14", + fifteenth = "15", + sixteenth = "16", + seventeenth = "17", + eighteenth = "18", + nineteenth = "19", + twentieth = "20", + ["twenty-first"] = "21", + ["twenty-second"] = "22", + ["twenty-third"] = "23", + ["twenty-fourth"] = "24", + ["twenty-fifth"] = "25", + ["twenty-sixth"] = "26", + ["twenty-seventh"] = "27", + ["twenty-eighth"] = "28", + ["twenty-ninth"] = "29", + thirtieth = "30", +} + + function util.convert_roman (number) -- assert(type(number) == "number") local output = {} @@ -1013,21 +1028,46 @@ util.superscripts = { -- File IO +function util.remove_bom(text) + if type(text) == "string" then + return string.gsub(text, "^\xEF\xBB\xBF", "") + else + return text + end +end + + +---@param path string +---@return string? function util.read_file(path) - -- if not path then - -- print(debug.traceback()) - -- end + if type(path) ~= "string" then + error("Invalid path.") + end local file = io.open(path, "r") if not file then - -- util.error(string.format('Cannot read file "%s".', path)) + util.error(string.format('Cannot open file "%s".', path)) return nil end local content = file:read("*a") + content = util.remove_bom(content) file:close() return content end +---@param text string +---@param path string +function util.write_file(text, path) + local file = io.open(path, "w") + if not file then + util.error(string.format('Cannot write to file "%s".', path)) + return + end + file:write(text) + file:close() +end + + function util.parse_iso_date(str) local date local date_parts = util.split(str, "/") @@ -1062,9 +1102,13 @@ end function util.check_journal_abbreviations(item) if item["container-title"] and not item["container-title-short"] then if not journal_data then - journal_data = require("citeproc-journal-data") + if kpse then + journal_data = require("citeproc-journal-data") + else + journal_data = require("citeproc.journal-data") + end end - local key = unicode.utf8.upper(string.gsub(item["container-title"], "%.", "")) + local key = uni_utf8.upper(string.gsub(item["container-title"], "%.", "")) local full = journal_data.unabbrevs[key] if full then item["container-title-short"] = item["container-title"] diff --git a/Master/texmf-dist/scripts/citation-style-language/citeproc.lua b/Master/texmf-dist/scripts/citation-style-language/citeproc.lua index 9f93901382f..aa5870d7a00 100755 --- a/Master/texmf-dist/scripts/citation-style-language/citeproc.lua +++ b/Master/texmf-dist/scripts/citation-style-language/citeproc.lua @@ -6,10 +6,17 @@ local citeproc = {} -local engine = require("citeproc-engine") -local util = require("citeproc-util") +local engine +local util +if kpse then + engine = require("citeproc-engine") + util = require("citeproc-util") +else + engine = require("citeproc.engine") + util = require("citeproc.util") +end -citeproc.__VERSION__ = "0.4.0" +citeproc.__VERSION__ = "0.4.1" citeproc.new = engine.CiteProc.new citeproc.util = util diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-bib.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-bib.sty new file mode 100644 index 00000000000..ee8f33d5046 --- /dev/null +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-bib.sty @@ -0,0 +1,714 @@ +% +% Copyright (c) 2021-2023 Zeping Lee +% Released under the MIT License. +% Repository: https://github.com/zepinglee/citeproc-lua +% + +% ## Bibliography commands + +% The options like `notcategory` can be used multiple times and thus we save +% them into a seq instead of a prop. +\seq_new:N \l__csl_bib_filter_seq +\int_new:N \g__bib_list_index_int +\tl_new:N \g__bib_list_index_tl +\tl_new:N \l__csl_bibliography_tl +\seq_new:N \l__csl_bibliography_seq + +\NewDocumentCommand \printbibliography { O { } } + { + \int_gincr:N \g__bib_list_index_int + \tl_gset:Nx \g__bib_list_index_tl { \int_use:N \g__bib_list_index_int } + \__csl_set_categories: + % Bibliography filter + \group_begin: + \seq_clear:N \l__csl_bib_filter_seq + \seq_put_right:Nx \l__csl_bib_filter_seq + { index = \g__bib_list_index_tl } + \keys_set:nn { csl / bibliography } {#1} + \__csl_serialize_seq:NN \l__csl_bib_filter_seq \l__csl_bib_filter_tl + % Collect the bibliography to token list + \sys_if_engine_luatex:TF + { + \bool_if:NT \l__csl_engine_initialized_bool + { + \__csl_collect_bibliography:n + { + \lua_now:e + { csl.bibliography("\l__csl_bib_filter_tl") } + } + } + } + { + % Write to aux file + \exp_args:NV \__csl_write_aux_bibliography:n \l__csl_bib_filter_tl + } + % Print the bibliography + \prop_get:NVNTF \g__csl_bibliographies_prop \g__bib_list_index_tl + \l__csl_bibliography_tl + { + \bool_if:NT \l__csl_regression_test_bool + { + \seq_set_split:NnV \l__csl_bibliography_seq { \par } \l__csl_bibliography_tl + \seq_show:N \l__csl_bibliography_seq + } + \tl_use:N \l__csl_bibliography_tl + } + { \msg_warning:nn { citation-style-language } { bibliography / empty } } + \group_end: + } + +\msg_new:nnn { citation-style-language } { bibliography / empty } + { The~ bibliography~ is~ empty. } + +\DeclareDocumentCommand \bibliography { m } + { + \__csl_write_aux_bibdata:n {#1} + \printbibliography + } + + +\tl_new:N \l__csl_bib_env_tl +\tl_new:N \l__csl_bib_head_name_tl +\tl_new:N \l__csl_bib_head_title_tl +\tl_new:N \l__csl_bib_head_label_tl +\tl_new:N \l__csl_bib_pre_note_tl +\tl_new:N \l__csl_bib_post_note_tl +\tl_new:N \l__csl_bib_filter_tl + +\tl_set:Nn \l__csl_bib_env_tl { bibliography } +\tl_set:Nn \l__csl_bib_head_name_tl { bibliography } + +\keys_define:nn { csl / bibliography } + { + % env .tl_set:N = \l__csl_bib_env_name_tl , + heading .tl_set:N = \l__csl_bib_head_name_tl , + title .tl_set:N = \l__csl_bib_head_title_tl , + label .tl_set:N = \l__csl_bib_head_label_tl , + % block + prenote .tl_set:N = \l__csl_bib_pre_note_tl , + postnote .tl_set:N = \l__csl_bib_post_note_tl , + % section + % segment + type .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { type = {#1} } } , + nottype .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { nottype = {#1} } } , + % subtype .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { subtype = {#1} } } , + % notsubtype .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { notsubtype = {#1} } } , + keyword .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { keyword = {#1} } } , + notkeyword .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { notkeyword = {#1} } } , + category .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { category = {#1} } } , + notcategory .code:n = { \seq_put_right:Nn \l__csl_bib_filter_seq { notcategory = {#1} } } , + % filter .tl_set:N = \l__csl_bibliography_nottype_tl , + } + + +% Used for debugging and testing +\clist_new:N \g__csl_bib_items_clist + + +\cs_new:Npn \__csl_write_aux_bibliography:n #1 + { + \if@filesw + \iow_now:Nn \@auxout { \csl@aux@bibliography {#1} } + \fi + } + +\cs_new:Npn \csl@aux@bibliography #1 { } + + +\tl_new:N \l__csl_bib_index_tl +\bool_new:N \l__csl_hanging_indent_bool +\tl_new:N \l__csl_line_spacing_tl +\tl_new:N \l__csl_entry_spacing_tl +\tl_new:N \l__csl_bib_wides_label_tl + +\keys_define:nn { csl / bib-options } + { + index .tl_set:N = \l__csl_bib_index_tl , + hanging-indent .bool_set:N = \l__csl_hanging_indent_bool , + line-spacing .tl_set:N = \l__csl_line_spacing_tl , + entry-spacing .tl_set:N = \l__csl_entry_spacing_tl , + widest-label .tl_set:N = \l__csl_bib_wides_label_tl , + } + +\keys_set:nn { csl / bib-options } + { + index = 1 , + hanging-indent = false , + line-spacing = 1 , + entry-spacing = 1 , + widest-label = { } , + } + +\RenewDocumentEnvironment { thebibliography } { m } + { + \exp_args:NVV \__csl_make_bib_heading:nn + \l__csl_bib_head_name_tl \l__csl_bib_head_title_tl + \exp_args:NV \__csl_print_bib_note:n \l__csl_bib_pre_note_tl + \group_begin: + \tl_set:Nn \l__csl_bib_index_tl { 1 } + \keys_set:nn { csl / bib-options } {#1} + \dim_zero:N \parindent + \tl_if_eq:NnF \l__csl_line_spacing_tl { 1 } + { \linespread { \l__csl_line_spacing_tl } \selectfont } + \l__csl_bib_font_tl + \list { } + { + \__csl_set_bib_label_spacing:n { \l__csl_bib_wides_label_tl } + \__csl_set_bib_item_sep: + } + \sloppy + \__csl_set_bib_page_break: + \frenchspacing + \__csl_bib_url_setup: + \clist_gclear:N \g__csl_bib_items_clist + } + { + \tl_set:Nn \@noitemerr + { \msg_warning:nn { citation-style-language } { bibliography / empty } } + \endlist + \group_end: + \exp_args:NV \__csl_print_bib_note:n \l__csl_bib_post_note_tl + } + + + +% ### Bibliography spacing + +\dim_new:N \l__csl_bib_hang_dim + +\cs_new:Npn \__csl_set_bib_label_spacing:n #1 + { + \bool_if:NTF \l__csl_hanging_indent_bool + { + \dim_set:Nn \l__csl_bib_hang_dim { \l__csl_bib_hang_tl } + \dim_set_eq:NN \leftmargin \l__csl_bib_hang_dim + \dim_set:Nn \itemindent { - \leftmargin } + } + { + \settowidth \labelwidth { \@biblabel {#1} } + \dim_set_eq:NN \leftmargin \labelwidth + \dim_add:Nn \leftmargin { \labelsep } + } + } + +% In standard LaTeX classes (10pt), the vertical sep of bibliographic item is +% \itemsep (4\p@ \@plus2\p@ \@minus\p@) + \parsep (4\p@ \@plus2\p@ \@minus\p@) +% = 8pt plus 4pt minus 2pt +\cs_new:Npn \__csl_set_bib_item_sep: + { + \skip_zero:N \parsep + \tl_if_empty:NTF \l__csl_bib_item_sep_tl + { + \skip_set:Nn \itemsep + { + 8 pt plus 4 pt minus 2 pt * \dim_ratio:nn { 1 em } { 8 pt } + * \l__csl_entry_spacing_tl + } + } + { \skip_set:Nn \itemsep { \l__csl_bib_item_sep_tl } } + } + + +% ### Bibliography label + +% CSL outputs the whole label thus the brackets are removed from \@biblabel +% \def\@biblabel#1{[#1]} +\cs_set:Npn \@biblabel #1 {#1} + +% For numeric or label-style bibliography: \bibitem[{[17]}]{entrykey} +% \@lbibitem is redefined in `babel` and `hyperref` and we need to override it +% in the patching code. Thus we define \__csl_lbibitem: here and reassign it to +% \@lbibitem in compatability code +\cs_new:Npn \__csl_lbibitem: + { + \bool_if:NTF \l__csl_back_ref_bool + { \__csl_lbibitem_back_ref:nnn } + { \__csl_lbibitem_plain:nn } + } + +\cs_set_eq:NN \@lbibitem \__csl_lbibitem: + +\cs_new:Npn \__csl_lbibitem_plain:nn [#1]#2 + { + \clist_gput_right:Nn \g__csl_bib_items_clist {#2} + \item [ \@biblabel {#1} \hfill ] + \ignorespaces + } + +% This is the version for use with backref feature. +\cs_new:Npn \__csl_lbibitem_back_ref:nnn [#1]#2#3\par + { + \__csl_lbibitem_plain:nn [#1] {#2} + #3 + \prop_get:NnNT \g__csl_back_ref_info_prop {#2} \l_tmpa_tl + { + \c_space_tl + \exp_args:NV \__csl_print_back_refs:n \l_tmpa_tl + } + \par + } + +\cs_new:Npn \__csl_print_back_refs:n #1 + % #1: list of {<page>}{<label>}{anchor} + { + \clist_set:Nn \l_tmpa_clist {#1} + % To remove duplicates + \prop_clear:N \l_tmpa_prop + % Output seq + \seq_clear:N \l_tmpa_seq + \clist_map_inline:Nn \l_tmpa_clist { \__csl_print_back_ref_aux:nnn ##1 } + \backref { \seq_use:Nn \l_tmpa_seq { ,~ } } + } + +\cs_new:Npn \__csl_print_back_ref_aux:nnn #1#2#3 + { + \str_if_eq:VnTF \l__csl_back_ref_type_str { page } + { + \prop_if_in:NnF \l_tmpa_prop {#1} + { + \bool_if:NTF \l__csl_hyperref_loaded_bool + { \seq_put_right:Nn \l_tmpa_seq { \hyperlink { page. #1 } {#1} } } + { \seq_put_right:Nn \l_tmpa_seq {#1} } + \prop_put:Nnn \l_tmpa_prop {#1} {#1} + } + } + { + % section + \prop_if_in:NnF \l_tmpa_prop {#2} + { + \bool_if:NTF \l__csl_hyperref_loaded_bool + { \seq_put_right:Nn \l_tmpa_seq { \hyperlink {#3} {#2} } } + { \seq_put_right:Nn \l_tmpa_seq {#2} } + \prop_put:Nnn \l_tmpa_prop {#2} {#2} + } + } + } + +% Hook +\cs_new:Npn \backref #1 {#1} + + +% For author-date bibliography +% \def\@bibitem#1{\item\if@filesw \immediate\write\@auxout +% {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces} +\cs_new:Npn \__csl_bibitem: + { + \bool_if:NTF \l__csl_back_ref_bool + { \__csl_bibitem_back_ref:nn } + { \__csl_bibitem_plain:n } + } + +\cs_set_eq:NN \@bibitem \__csl_bibitem: + +\cs_new:Npn \__csl_bibitem_plain:n #1 + { + \clist_gput_right:Nn \g__csl_bib_items_clist {#1} + \item + \ignorespaces + } + +\cs_new:Npn \__csl_bibitem_back_ref:nn #1#2\par + { + \__csl_bibitem_plain:n {#1} + #2 + % \prop_show:N \g__csl_back_ref_info_prop + \prop_get:NnNT \g__csl_back_ref_info_prop {#1} \l_tmpa_tl + { + \c_space_tl + \exp_args:NV \__csl_print_back_refs:n \l_tmpa_tl + } + \par + } + + +% ### Bibliography Headings and Environments + +\prop_new:N \l__csl_bib_env_begin_prop +\prop_new:N \l__csl_bib_env_end_prop +\prop_new:N \l__csl_bib_item_prop + +% \defbibenvironment{⟨name⟩}{⟨begin code⟩}{⟨end code⟩}{⟨item code⟩} +\NewDocumentCommand { \defbibenvironment } { m m m m } + { + \prop_put:Nnn \l__csl_bib_env_begin_prop {#1} {#2} + \prop_put:Nnn \l__csl_bib_env_end_prop {#1} {#3} + \prop_put:Nnn \l__csl_bib_item_prop {#1} {#4} + } + +% \defbibenvironment { bibliography } +% { } + + +% #1: bib heading name +% #2: bib heading title +\cs_new:Npn \__csl_make_bib_heading:nn #1#2 + { + \tl_if_empty:NTF \bibsection + { + \cs_if_exist:cF { __csl_head_ #1 :n } + { + \msg_error:nnn { citation-style-language } { bib-heading-undefined } + {#1} + } + \tl_if_blank:nTF {#2} + { \use:c { __csl_head_ #1 :n } } + { \use:c { __csl_head_ #1 :n } [#2] } + } + { \bibsection } + \tl_if_empty:NF \l__csl_bib_head_label_tl + { \exp_args:NV \label \l__csl_bib_head_label_tl } + } + +\msg_new:nnn { citation-style-language } { bib-heading-undefined } + { Bibliography~ heading~ '#1'~ undefined. } + +\keys_define:nn { csl / bib-heading } + { + heading .tl_set:N = \l__csl_bib_head_name_tl , + title .tl_set:N = \l__csl_bib_head_title_tl , + % label + } + +\cs_new:Npn \__csl_reset_heading_options: + { + \tl_set:Nn \l__csl_bib_head_name_tl { bibliography } + \tl_set:Nn \l__csl_bib_head_title_tl { } + } + +\NewDocumentCommand { \printbibheading } { O { } } + { + % We can't use a group here. + % See <https://github.com/plk/biblatex/issues/1278>. + \__csl_reset_heading_options: + \keys_set:nn { csl / bib-heading } {#1} + \exp_args:NVV \__csl_make_bib_heading:nn + \l__csl_bib_head_name_tl \l__csl_bib_head_title_tl + \__csl_reset_heading_options: + } + +% \defbibheading { ⟨name⟩}[⟨title⟩]{⟨code⟩} +\NewDocumentCommand { \defbibheading } { m O { \bibname } } + { + \expandafter \newcommand \csname __csl_head_ #1 :n \endcsname [1] [ {#2} ] + } + +\cs_if_exist:NTF \chapter + { + % `book` or `report` + \defbibheading { bibliography } [ \bibname ] + { + \chapter* {#1} + \@mkboth { \MakeUppercase {#1} } { \MakeUppercase {#1} } + } + \defbibheading { biblist } [ \biblistname ] + { + \chapter* {#1} + \@mkboth { \MakeMarkcase {#1} } { \MakeMarkcase {#1} } + } + \defbibheading { bibintoc } [ \bibname ] + { + \chapter* {#1} + \addcontentsline { toc } { chapter } {#1} + \@mkboth { \MakeMarkcase {#1} } { \MakeMarkcase {#1} } + } + \defbibheading { biblistintoc } [ \biblistname ] + { + \chapter* {#1} + \addcontentsline { toc } { chapter } {#1} + \@mkboth { \MakeMarkcase {#1} } { \MakeMarkcase {#1} } + } + \defbibheading { bibnumbered } [ \bibname ] + { \chapter {#1} } + \defbibheading { biblistnumbered } [ \biblistname ] + { \chapter {#1} } + \defbibheading { subbibliography } [ \refname ] + { + \section* {#1} + \if@twoside + \markright { \MakeMarkcase {#1} } + \fi + } + \defbibheading { subbibintoc } [ \refname ] + { + \section* {#1} + \addcontentsline { toc } { section } {#1} + \if@twoside + \markright { \MakeMarkcase {#1} } + \fi + } + \defbibheading { subbibnumbered } [ \refname ] + { \section {#1} } + } + { + % `article` + \defbibheading { bibliography } [ \refname ] + { + \section* {#1} + \@mkboth { \MakeUppercase {#1} } { \MakeUppercase {#1} } + } + \defbibheading { biblist } [ \biblistname ] + { + \section* {#1} + \@mkboth { \MakeMarkcase {#1} } { \MakeMarkcase {#1} } + } + \defbibheading { bibintoc } [ \refname ] + { + \section* {#1} + \addcontentsline { toc } { section } {#1} + \@mkboth { \MakeMarkcase {#1} } { \MakeMarkcase {#1} } + } + \defbibheading { biblistintoc } [ \biblistname ] + { + \section* {#1} + \addcontentsline { toc } { section } {#1} + \@mkboth { \MakeMarkcase {#1} } { \MakeMarkcase {#1} } + } + \defbibheading { bibnumbered } [ \refname ] + { \section {#1} } + \defbibheading { biblistnumbered } [ \biblistname ] + { \section {#1} } + \defbibheading { subbibliography } [ \refname ] + { \subsection* {#1} } + \defbibheading { subbibintoc } [ \refname ] + { + \subsection* {#1} + \addcontentsline { toc } { subsection } {#1} + } + \defbibheading { subbibnumbered } [ \refname ] + { \subsection {#1} } + } + +\defbibheading { none } { } + + +% Bibliography notes + +\prop_new:N \l__csl_bib_notes_prop + +% #1: name +% #2: text +\NewDocumentCommand { \defbibnote } { m m } + { \prop_put:Nnn \l__csl_bib_notes_prop {#1} {#2} } + +% #1: note name +\cs_new:Npn \__csl_print_bib_note:n #1 + { + \tl_if_empty:nF {#1} + { + \prop_get:NnNF \l__csl_bib_notes_prop {#1} \l_tmpa_tl + { + \msg_error:nnn { citation-style-language } { bib-note-undefined } + {#1} + } + \tl_if_empty:NF \l_tmp_tl + { + \group_begin: + % \cs_set_eq:NN \newrefsection \relax + % \cs_set_eq:NN \newrefsegment \relax + \noindent + \tl_use:N \l_tmpa_tl + \par \nobreak + \group_end: + } + } + } + +\msg_new:nnn { citation-style-language } { bib-note-undefined } + { Bibliography~ note~ '#1'~ undefined. } + + + +% ### Bibliography Categories + +\prop_new:N \l__csl_categories_prop + +% \DeclareBibliographyCategory{⟨category⟩} +\NewDocumentCommand \DeclareBibliographyCategory { m } + { + \prop_put:Nnn \l__csl_categories_prop { #1 } { } + } + +% \addtocategory{⟨category⟩}{⟨keys⟩} +\NewDocumentCommand \addtocategory { m m } + { + \prop_get:NnNTF \l__csl_categories_prop {#1} \l_tmpa_tl + { + \tl_if_empty:NF \l_tmpa_tl + { \tl_put_right:Nn \l_tmpa_tl { , } } + \tl_put_right:Nn \l_tmpa_tl {#2} + \prop_put:NnV \l__csl_categories_prop {#1} \l_tmpa_tl + } + { + \msg_error:nnn { citation-style-language } { category-not-declared } + {#1} + } + } + +% Set categories in Lua module or write to aux file. +% This procesure is at `\printbibligoraphy` to allow \addtocategory in main text. +\cs_new:Npn \__csl_set_categories: + { + % Set categories + \prop_if_empty:NF \l__csl_categories_prop + { + \tl_clear:N \l_tmpa_tl + \prop_map_inline:Nn \l__csl_categories_prop + { + \tl_if_empty:NF \l_tmpa_tl + { \tl_put_right:Nn \l_tmpa_tl { , } } + \tl_put_right:Nn \l_tmpa_tl { ##1 = {##2} } + } + \sys_if_engine_luatex:T + { \lua_now:e { csl.set_categories("\l_tmpa_tl") } } + { + \tl_put_left:Nx \l_tmpa_tl { categories = \c_left_brace_str } + \tl_put_right:NV \l_tmpa_tl \c_right_brace_str + \exp_args:NV \__csl_write_aux_options:n \l_tmpa_tl + } + } + } + +\msg_new:nnn { citation-style-language } { category-not-declared } + { Category~ '#1'~ not~ declared. } + + +% ### Page break in bibliography + +% See <https://github.com/plk/biblatex/blob/e16f4aaa5d9857c7b844bbcbe246f0535fd334e9/tex/latex/biblatex/biblatex.def#L219-L258> + +\cs_new:Npn \__csl_set_bib_page_break: + { + \bool_if:NTF \l__csl_bib_entry_page_break_bool + { \__csl_set_bib_allow_break: } + { \__csl_set_bib_no_break: } + } + +% The following code allows linebreaks before numbers and letters. +% This is often the only way to break DOIs. It also allows breaks +% after hyphens and adjusts \Urlmuskip to add some stretchability +% to URLs. + +\cs_new:Npn \__csl_set_bib_allow_break: + { + \sloppy + \int_set:Nn \clubpenalty { 4000 } + \int_set_eq:NN \@clubpenalty \clubpenalty + \int_set:Nn \widowpenalty { 4000 } + % \sfcode`\.\@m + \frenchspacing + } + +\cs_new:Npn \__csl_set_bib_no_break: + { + \sloppy + \int_set:Nn \interlinepenalty { 5000 } + \int_set:Nn \widowpenalty { 10000 } + \int_set:Nn \clubpenalty { 10000 } + \int_set_eq:NN \@clubpenalty \clubpenalty + \raggedbottom + \frenchspacing + } + + +% ### Urls in bibliography +% Taken from `biblatex`'s \biburlsetup +% https://github.com/plk/biblatex/blob/dev/tex/latex/biblatex/biblatex.def + +\int_new:N \l__csl_url_big_break_penalty_int +\int_new:N \l__csl_url_break_penalty_int +\int_new:N \l__csl_url_num_penalty_int +\int_new:N \l__csl_url_uc_penalty_int +\int_new:N \l__csl_url_lc_penalty_int + +\int_set:Nn \l__csl_url_big_break_penalty_int { 100 } +\int_set:Nn \l__csl_url_break_penalty_int { 200 } +% Allow linebreaks before numbers and letters. +% Taken from `xurl.sty`. +\int_set:Nn \l__csl_url_num_penalty_int { 9000 } +\int_set:Nn \l__csl_url_uc_penalty_int { 9000 } +\int_set:Nn \l__csl_url_lc_penalty_int { 8000 } + +\muskip_new:N \l__csl_url_big_muskip +\muskip_new:N \l__csl_url_num_muskip +\muskip_new:N \l__csl_url_uc_muskip +\muskip_new:N \l__csl_url_lc_muskip + +\muskip_set:Nn \l__csl_url_big_muskip { 0mu plus 3mu } +\muskip_set:Nn \l__csl_url_num_muskip { 0mu } +\muskip_set:Nn \l__csl_url_uc_muskip { 0mu } +\muskip_set:Nn \l__csl_url_lc_muskip { 0mu } + +\cs_new:Npn \__csl_bib_url_setup: + { + \urlstyle { same } + \muskip_set_eq:NN \Urlmuskip \l__csl_url_big_muskip + \mathchardef \UrlBigBreakPenalty = \l__csl_url_big_break_penalty_int + \mathchardef \UrlBreakPenalty = \l__csl_url_break_penalty_int + % \int_set_eq:NN doesn't work here + % \int_set_eq:NN \UrlBigBreakPenalty \l__csl_url_big_break_penalty_int + % \int_set_eq:NN \UrlBreakPenalty \l__csl_url_break_penalty_int + \tl_set:Nn \UrlBigBreaks { \do \: \do \- } + \tl_set:Nn \UrlBreaks + { + \do \. \do \@ \do \/ \do \\ \do \! \do \_ \do \| \do \; \do \> \do \] + \do \) \do \} \do \, \do \? \do \' \do \+ \do \= \do \# \do \$ \do \& + \do \* \do \^ \do \" + } + \int_compare:nNnT { \l__csl_url_num_penalty_int } > { 0 } + { + \clist_map_inline:nn + { \1 , \2 , \3 , \4 , \5 , \6 , \7 , \8 , \9 , \0 } + { + \tl_put_right:Nn \UrlSpecials + { + \do ##1 + { + \mathchar`##1 + \mskip \l__csl_url_num_muskip + \penalty \l__csl_url_num_penalty_int + } + } + } + } + \int_compare:nNnT { \l__csl_url_uc_penalty_int } > { 0 } + { + \clist_map_inline:nn + { + \A , \B , \C , \D , \E , \F , \G , \H , \I , \J , + \K , \L , \M , \N , \O , \P , \Q , \R , \S , \T , + \U , \V , \W , \X , \Y , \Z + } + { + \tl_put_right:Nn \UrlSpecials + { + \do ##1 + { + \mathchar`##1 + \mskip \l__csl_url_uc_muskip + \penalty \l__csl_url_uc_penalty_int + } + } + } + } + \int_compare:nNnT { \l__csl_url_lc_penalty_int } > { 0 } + { + \clist_map_inline:nn + { + \a , \b , \c , \d , \e , \f , \g , \h , \i , \j , + \k , \l , \m , \n , \o , \p , \q , \r , \s , \t , + \u , \v , \w , \x , \y , \z + } + { + \tl_put_right:Nn \UrlSpecials + { + \do ##1 + { + \mathchar`##1 + \mskip \l__csl_url_lc_muskip + \penalty \l__csl_url_lc_penalty_int + } + } + } + } + \cs_set_eq:NN \do \exp_not:N + } diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-cite.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-cite.sty new file mode 100644 index 00000000000..5c4b229bffd --- /dev/null +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-cite.sty @@ -0,0 +1,524 @@ +% +% Copyright (c) 2021-2023 Zeping Lee +% Released under the MIT License. +% Repository: https://github.com/zepinglee/citeproc-lua +% + +% ## Citation commands + +\DeclareDocumentCommand \cite { o o m } + { \__csl_cite:nnn {#1} {#2} {#3} } + +\NewDocumentCommand \parencite { o o m } + { \__csl_cite:nnn {#1} {#2} {#3} } + +\NewDocumentCommand \citep { o o m } + { \__csl_cite:nnn {#1} {#2} {#3} } + +\NewDocumentCommand \textcite { o o m } + { \__csl_text_cite:nnn {#1} {#2} {#3} } + +\NewDocumentCommand \citet { o o m } + { \__csl_text_cite:nnn {#1} {#2} {#3} } + +\NewDocumentCommand \footcite { o o m } + { \__csl_cite:nnn {#1} {#2} {#3} } + + +% \cites[⟨prenote⟩][⟨postnote⟩]{⟨key⟩}...[⟨prenote⟩][⟨postnote⟩]{⟨key⟩} +\NewDocumentCommand \cites { } + { \__csl_cites: } + +\NewDocumentCommand \citeauthor { o o m } + { \__csl_cite_author:nnn {#1} {#2} {#3} } + + +\seq_new:N \l__csl_cite_keys_seq +\seq_new:N \l__csl_citation_items_seq +\prop_new:N \l__csl_citation_properties_prop +\prop_new:N \l__csl_citation_info_prop + +% \__csl_cite:nnn #1#2#3 +\cs_new:Npn \__csl_cite:nnn #1#2#3 + { + \tl_if_blank:nTF {#3} + { \__csl_print_undefined_citation:n {#3} } + { + \seq_clear:N \l__csl_cite_keys_seq + \seq_clear:N \l__csl_citation_items_seq + \prop_clear:N \l__csl_citation_properties_prop + \__csl_process_cite_input:nnn {#1} {#2} {#3} + \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq + \__csl_make_citation:N \l__csl_citation_info_prop + } + } + + +\cs_new:Npn \__csl_text_cite:nnn #1#2#3 + { + \seq_clear:N \l__csl_cite_keys_seq + \seq_clear:N \l__csl_citation_items_seq + \prop_clear:N \l__csl_citation_properties_prop + \__csl_process_cite_input:nnn {#1} {#2} {#3} + \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq + \prop_put:Nnn \l__csl_citation_properties_prop { noteIndex } { 0 } + \prop_put:Nnn \l__csl_citation_properties_prop { mode } { composite } + % \bool_set_false:N \l__csl_note_bool + \__csl_make_citation:N \l__csl_citation_info_prop + } + + +\cs_new:Npn \__csl_cites: + { + \seq_clear:N \l__csl_cite_keys_seq + \seq_clear:N \l__csl_citation_items_seq + \prop_clear:N \l__csl_citation_properties_prop + \__csl_next_cites:nnn + } + +\NewDocumentCommand \__csl_next_cites:nnn { o o g } + { + \tl_if_novalue:nTF {#3} + { + \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq + \__csl_make_citation:N \l__csl_citation_info_prop + } + { + \__csl_process_cite_input:nnn {#1} {#2} {#3} + \__csl_next_cites:nnn + } + } + + +\cs_new:Npn \__csl_cite_author:nnn #1#2#3 + { + \seq_clear:N \l__csl_cite_keys_seq + \seq_clear:N \l__csl_citation_items_seq + \prop_clear:N \l__csl_citation_properties_prop + \__csl_process_cite_input:nnn {#1} {#2} {#3} + \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq + \prop_put:Nnn \l__csl_citation_properties_prop { noteIndex } { 0 } + \prop_put:Nnn \l__csl_citation_properties_prop { mode } { author-only } + \bool_set_false:N \l__csl_note_bool + \__csl_make_citation:N \l__csl_citation_info_prop + } + + +% Appends the cite key into \l__csl_cite_keys_seq and cite-items into +% \l__csl_citation_items_seq +% #1, #2: prenote/postnote +% #3: keys +\cs_new:Npn \__csl_process_cite_input:nnn #1#2#3 + { + \tl_if_novalue:nTF {#2} + { + \tl_if_novalue:nTF {#1} + { \__csl_process_cite_input_aux:nnn { } { } {#3} } + { \__csl_process_cite_input_aux:nnn { } {#1} {#3} } + } + { \__csl_process_cite_input_aux:nnn {#1} {#2} {#3} } + } + +\cs_new:Npn \__csl_process_cite_input_aux:nnn #1#2#3 + % #1: prenote, #2: postnote, #3: keys + % Return: "{id={ITEM-1},{locator=6},...}, {id={ITEM-2},...}, ..." + { + \int_zero:N \l_tmpa_int + \clist_map_inline:nn {#3} + { + \int_incr:N \l_tmpa_int + \seq_put_right:Nn \l__csl_cite_keys_seq {##1} + \int_compare:nNnTF { \l_tmpa_int } = { 1 } + { \__csl_process_cite_item:nnn {#1} {#2} {##1} } + { \__csl_process_cite_item:nnn { } { } {##1} } + } + } + + +\prop_new:N \l__csl_cite_item_prop +\tl_new:N \l__csl_prefix_tl +\tl_new:N \l__csl_suffix_tl + +\cs_new:Npn \__csl_process_cite_item:nnn #1#2#3 + % #1: prenote, #2: postnote, #3: key + % Save "{id={ITEM},locator={42},label={page}}" into \l__csl_citation_items_seq + { + \prop_clear:N \l__csl_cite_item_prop + \prop_put:Nnn \l__csl_cite_item_prop { id } {#3} + % \bool_if:T \l__csl_suppress_author_bool + % { \prop_put:Nnn \l__csl_cite_item_prop { suppress-author } { true } } + % \bool_if:T \l__csl_author_only_bool + % { \prop_put:Nnn \l__csl_cite_item_prop { author-only } { true } } + \tl_if_empty:nF {#1} + { + \tl_set:Nn \l__csl_prefix_tl {#1} + \tl_put_right:NV \l__csl_prefix_tl \l__csl_prefix_separator_tl + \prop_put:NnV \l__csl_cite_item_prop { prefix } \l__csl_prefix_tl + } + \tl_if_empty:nF {#2} + { + \tl_if_in:nnTF {#2} { = } + { \keys_set:nn { csl / cite-item } {#2} } + { + \regex_match:nnTF { \d+ } {#2} + { \__csl_set_locator:nn { page } {#2} } + { + \tl_set:Nn \l__csl_suffix_tl {#2} + \tl_put_left:NV \l__csl_suffix_tl \l__csl_suffix_separator_tl + \prop_put:NnV \l__csl_cite_item_prop { suffix } \l__csl_suffix_tl + } + } + } + \__csl_serialize_prop:NN \l__csl_cite_item_prop \l_tmpa_tl + \tl_put_left:NV \l_tmpa_tl { \c_left_brace_str } + \tl_put_right:NV \l_tmpa_tl { \c_right_brace_str } + \seq_put_right:NV \l__csl_citation_items_seq \l_tmpa_tl + } + +\cs_new:Npn \__csl_set_locator:nn #1#2 + { + \prop_put:Nnn \l__csl_cite_item_prop { label } {#1} + \prop_put:Nnn \l__csl_cite_item_prop { locator } {#2} + } + +\keys_define:nn { csl / cite-item } + { + prefix .prop_put:N = \l__csl_cite_item_prop, + suffix .prop_put:N = \l__csl_cite_item_prop, + locator .prop_put:N = \l__csl_cite_item_prop, + label .prop_put:N = \l__csl_cite_item_prop, + suppress-author .prop_put:N = \l__csl_cite_item_prop, + author-only .prop_put:N = \l__csl_cite_item_prop, + uris .prop_put:N = \l__csl_cite_item_prop, + % Locators. + act .code:n = { \__csl_set_locator:nn { act } {#1} } , + appendix .code:n = { \__csl_set_locator:nn { appendix } {#1} } , + article .code:n = { \__csl_set_locator:nn { article-locator } {#1} } , + book .code:n = { \__csl_set_locator:nn { book } {#1} } , + canon .code:n = { \__csl_set_locator:nn { canon } {#1} } , + chapter .code:n = { \__csl_set_locator:nn { chapter } {#1} } , + column .code:n = { \__csl_set_locator:nn { column } {#1} } , + elocation .code:n = { \__csl_set_locator:nn { elocation } {#1} } , + equation .code:n = { \__csl_set_locator:nn { equation } {#1} } , + figure .code:n = { \__csl_set_locator:nn { figure } {#1} } , + folio .code:n = { \__csl_set_locator:nn { folio } {#1} } , + issue .code:n = { \__csl_set_locator:nn { issue } {#1} } , + line .code:n = { \__csl_set_locator:nn { line } {#1} } , + note .code:n = { \__csl_set_locator:nn { note } {#1} } , + opus .code:n = { \__csl_set_locator:nn { opus } {#1} } , + page .code:n = { \__csl_set_locator:nn { page } {#1} } , + paragraph .code:n = { \__csl_set_locator:nn { paragraph } {#1} } , + part .code:n = { \__csl_set_locator:nn { part } {#1} } , + rule .code:n = { \__csl_set_locator:nn { rule } {#1} } , + scene .code:n = { \__csl_set_locator:nn { scene } {#1} } , + section .code:n = { \__csl_set_locator:nn { section } {#1} } , + sub-verbo .code:n = { \__csl_set_locator:nn { sub-verbo } {#1} } , + supplement .code:n = { \__csl_set_locator:nn { supplement } {#1} } , + table .code:n = { \__csl_set_locator:nn { table } {#1} } , + timestamp .code:n = { \__csl_set_locator:nn { timestamp } {#1} } , + title .code:n = { \__csl_set_locator:nn { title-locator } {#1} } , + verse .code:n = { \__csl_set_locator:nn { verse } {#1} } , + version .code:n = { \__csl_set_locator:nn { version } {#1} } , + volume .code:n = { \__csl_set_locator:nn { volume } {#1} } , + % Citation properties + infix .prop_put:N = \l__csl_citation_properties_prop, + } + + +\tl_new:N \l__csl_citation_id_tl +\tl_new:N \l__csl_cite_items_tl +\tl_new:N \l__csl_note_index_tl + +% Load the cite keys and prepare: +% - \l__csl_citation_id_tl +% - \l__csl_citation_properties_prop +% +% #1: \l__csl_cite_keys_seq +% #2: \l__csl_citation_items_seq +\cs_new:Npn \__csl_process_citation_info:NN #1#2 + { + \__csl_process_citation_id:NN \l__csl_citation_id_tl #1 + \__csl_get_note_index:N \l__csl_note_index_tl + \prop_put:NnV \l__csl_citation_properties_prop { noteIndex } \l__csl_note_index_tl + \__csl_add_back_ref_info: + } + + +\tl_new:N \l__csl_back_ref_tl +\prop_new:N \g__csl_back_ref_info_prop +\prop_new:N \l__csl_back_ref_section_pop + +% Provide empty \@currentHref when hyperref is not loaded. +\cs_new:Npn \@currentHref {} + +% TODO: write backref info to .brf file or .aux file +\cs_new:Npn \__csl_add_back_ref_info: + { + % Same as the second argument of backref's \backcite + % \thepage: the page number + % \@currentlabel: the current label of the citation + % \@currentHref: the current anchor name + \tl_if_empty:NTF \@currentlabel + { + \tl_set:Nx \l__csl_back_ref_tl + { { \thepage } { (document) } { Doc-Start } } + } + { + \tl_set:Nx \l__csl_back_ref_tl + { { \thepage } { \@currentlabel } { \@currentHref } } + } + \seq_map_inline:Nn \l__csl_cite_keys_seq + { + \prop_get:NnNTF \g__csl_back_ref_info_prop {##1} \l_tmpa_tl + { + \tl_put_right:Nn \l_tmpa_tl { , } + \tl_put_right:NV \l_tmpa_tl \l__csl_back_ref_tl + \prop_gput:NnV \g__csl_back_ref_info_prop {##1} \l_tmpa_tl + } + { + \prop_gput:NnV \g__csl_back_ref_info_prop {##1} + \l__csl_back_ref_tl + } + } + } + + +\tl_new:N \l__csl_citation_info_tl +\tl_new:N \l__csl_citation_tl +\prop_new:N \g__csl_citations_prop + +\tl_new:N \l__csl_citation_properties_tl + +% Write citation info to aux and print the citation contents. +% #1: \l__csl_citation_info_prop +\cs_new:Npn \__csl_make_citation:N #1 + { + \prop_clear:N \l__csl_citation_info_prop + % citationID + \prop_put:NnV \l__csl_citation_info_prop { citationID } \l__csl_citation_id_tl + % citationItems + \__csl_serialize_seq:NN \l__csl_citation_items_seq \l__csl_cite_items_tl + \prop_put:NnV \l__csl_citation_info_prop { citationItems } \l__csl_cite_items_tl + % properties + \__csl_serialize_prop:NN \l__csl_citation_properties_prop \l__csl_citation_properties_tl + \prop_put:NnV \l__csl_citation_info_prop { properties } \l__csl_citation_properties_tl + \__csl_serialize_prop:NN \l__csl_citation_info_prop \l__csl_citation_info_tl + % Write to .aux file + % \tl_show:N \l__csl_citation_info_tl + \exp_args:NV \__csl_write_aux_citation:n \l__csl_citation_info_tl + \bool_if:NT \l__csl_regression_test_bool + { \tl_show:N \l__csl_citation_info_tl } + % Print the citation string + \prop_get:NVNTF \g__csl_citations_prop \l__csl_citation_id_tl + \l__csl_citation_tl + { \__csl_print_citation:N \l__csl_citation_tl } + { + \bool_if:NTF \l__csl_engine_initialized_bool + { + % \tl_show:N \l__csl_citation_info_tl + % \tl_set:Nf \l__csl_citation_tl + % { \exp_args:NV \__csl_cite_aux:n \l__csl_citation_info_tl } + \group_begin: + \char_set_catcode_other:N \% + \char_set_catcode_other:N \# + \exp_args:NV \__csl_cite_aux:n \l__csl_citation_info_tl + \__csl_print_citation:N \l__csl_citation_tl + \group_end: + } + { + \exp_args:Nx \__csl_print_undefined_citation:n + { \seq_use:Nn \l__csl_cite_keys_seq { ,~ } } + } + } + } + +\cs_new:Npn \__csl_cite_aux:n #1 + { \lua_now:e { csl.cite("\lua_escape:n {#1}") } } + +% #1: seq +% #2: tl +\cs_new:Npn \__csl_serialize_seq:NN #1#2 + { + \tl_clear:N #2 + \seq_map_inline:Nn #1 + { + \tl_if_empty:NF #2 + { \tl_put_right:Nn #2 { , } } + \tl_put_right:Nn #2 { ##1 } + } + } + +% #1: prop +% #2: tl +\cs_new:Npn \__csl_serialize_prop:NN #1#2 + { + \tl_clear:N #2 + \prop_map_inline:Nn #1 + { + \tl_if_empty:NF #2 + { \tl_put_right:Nn #2 { , } } + \tl_put_right:Nn #2 { ##1 = { ##2 } } + } + } + +\tl_new:N \l__csl_cite_keys_tl +\tl_new:N \l__csl_citation_count_tl +\int_new:N \l__csl_citation_count_int +\prop_new:N \g__csl_citations_count_prop + +\cs_new:Npn \__csl_process_citation_id:NN #1#2 + % #1: \l__csl_citation_id_tl + % #2: \l__csl_cite_keys_seq + % Set \l__csl_citation_id_tl = "ITEM-1,ITEM-2@4". + { + \tl_set:Nx \l__csl_cite_keys_tl + { \seq_use:Nn #2 { , } } + % \prop_show:N \g__csl_citations_count_prop + % \tl_show:N \l__csl_cite_keys_tl + \prop_get:NVNTF \g__csl_citations_count_prop \l__csl_cite_keys_tl + \l__csl_citation_count_tl + { + \int_set:Nn \l__csl_citation_count_int { \l__csl_citation_count_tl } + \int_incr:N \l__csl_citation_count_int + } + { \int_set_eq:NN \l__csl_citation_count_int \c_one_int } + \prop_gput:NVV \g__csl_citations_count_prop \l__csl_cite_keys_tl + \l__csl_citation_count_int + \tl_set:Nx #1 + { \l__csl_cite_keys_tl @ \int_use:N \l__csl_citation_count_int } + } + + +\int_new:N \g__csl_pseudo_note_index_int +\int_gset:Nn \g__csl_pseudo_note_index_int { 0 } + +% Save the note number to \l__csl_note_index_tl +% TODO: multiple citations in a note +\cs_new:Npn \__csl_get_note_index:N #1 + % #1: \l__csl_note_index_tl + { + \bool_if:NTF \l__csl_note_bool + { + \int_set_eq:Nc \l_tmpa_int { c@ \@mpfn } + \int_incr:N \l_tmpa_int + \tl_set:Nx #1 { \int_use:N \l_tmpa_int } + } + { + \tl_if_empty:NTF \l__csl_class_tl + { + % The style class (in-text/note) is undetermined. + \int_set_eq:Nc \l_tmpa_int { c@ \@mpfn } + \int_gincr:N \g__csl_pseudo_note_index_int + \int_add:Nn \l_tmpa_int { \g__csl_pseudo_note_index_int } + \tl_set:Nx #1 { \int_use:N \l_tmpa_int } + } + { \tl_set:Nx #1 { 0 } } + } + } + + +\cs_new:Npn \__csl_write_aux_citation:n #1 + % #1: citation info "{<citationID>}{{id=ITEM-1},{id=ITEM-2}}{<noteIndex>}" + { + \if@filesw + \iow_now:Nn \@auxout { \csl@aux@cite {#1} } + \fi + } + + +% #1: \l__csl_citation_tl +\cs_new:Npn \__csl_print_citation:N #1 + { + \bool_if:NT \l__csl_regression_test_bool + { \tl_show:N #1 } + \bool_if:NTF \l__csl_note_bool + { \footnote {#1} } + {#1} + } + + +\cs_new:Npn \__csl_print_undefined_citation:n #1 + % #1: keys + { + \G@refundefinedtrue + \msg_warning:nnn { citation-style-language } { citation / undefined } {#1} + \tl_if_blank:nTF {#1} + { \tl_set:Nn \l__csl_citation_tl { [ \textbf { ? } ] } } + { \tl_set:Nn \l__csl_citation_tl { [ \textbf {#1} ] } } + \bool_if:NT \l__csl_regression_test_bool + { \tl_show:N \l__csl_citation_tl } + \group_begin: + \reset@font \l__csl_citation_tl + \group_end: + } + +\msg_new:nnn { citation-style-language } { citation / undefined } + { Citation~ `#1'~ on~ page~ \thepage \space undefined~ \msg_line_context: . } + + +\DeclareDocumentCommand \nocite { m } + { \__csl_no_cite:n {#1} } + + +\cs_new:Npn \__csl_no_cite:n #1 + { + \seq_clear:N \l__csl_cite_keys_seq + \seq_clear:N \l__csl_citation_items_seq + \__csl_process_cite_input:nnn { } { } {#1} + \tl_set:Nx \l__csl_cite_items_tl + { \seq_use:Nn \l__csl_citation_items_seq { , } } + \tl_set:Nx \l__csl_citation_info_tl + { + citationID = { @nocite } , + citationItems = { \l__csl_cite_items_tl } , + properties = { noteIndex = { 0 } } + } + \bool_if:NT \l__csl_regression_test_bool + { \tl_show:N \l__csl_citation_info_tl } + \exp_args:NV \__csl_no_cite_write_aux:n \l__csl_citation_info_tl + \sys_if_engine_luatex:T + { \lua_now:n { csl.nocite("#1") } } + \tl_clear:N \l__csl_citation_tl + \bool_if:NT \l__csl_regression_test_bool + { \tl_show:N \l__csl_citation_tl } +} + + +\cs_new:Npn \__csl_no_cite_write_aux:n #1 + { + \__csl_if_preamble:TF + { + \AtBeginDocument + { \exp_args:Nx \__csl_write_aux_citation:n { #1 } } + } + { \exp_args:Nx \__csl_write_aux_citation:n { #1 } } + } + + +\prg_new_conditional:Nnn \__csl_if_preamble: { T , F , TF } + { + \if_meaning:w \@begindocumenthook \@undefined + \prg_return_false: + \else + \prg_return_true: + \fi + } + + +% Used in aux files to register cite items. +% #1: a citation object +\cs_set:Npn \csl@aux@cite #1 + { + \sys_if_engine_luatex:T + { \lua_now:e { csl.register_citation_info("\lua_escape:n {#1}") } } + } + + +\cs_new:Npn \cslcitation #1#2 + { \prop_gput:Nnn \g__csl_citations_prop {#1} {#2} } + + +% This command is for use with hyperref. +% #1: cite id +% #2: cite contents +\cs_new:Npn \cslcite #1#2 {#2} diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty new file mode 100644 index 00000000000..db70f54c1ce --- /dev/null +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-compatible.sty @@ -0,0 +1,102 @@ +% +% Copyright (c) 2021-2023 Zeping Lee +% Released under the MIT License. +% Repository: https://github.com/zepinglee/citeproc-lua +% + +% ## Compatibilities with other packages + +% ### `babel` + +% This should be disabled. +\AtEndOfPackageFile* { babel } + { + \RenewDocumentCommand \nocite { m } + { + % \@safe@activestrue\org@nocite{#1}\@safe@activesfalse + \@safe@activestrue + \__csl_no_cite:n {#1} + \@safe@activesfalse + } + \cs_set_eq:NN \bbl@cite@choice \relax + \cs_set_eq:NN \@lbibitem \__csl_lbibitem_plain:nn + \cs_set_eq:NN \@bibitem \__csl_bibitem_plain:n + } + + +% ### `biblatex` +% The following doesn't really make `csl` compatible with `biblatex`. +% It just provides commands to make it accepting `biblatex`'s database. + +\ProvideDocumentCommand { \hyphen } { } + { + \nobreak - \nobreak + \hskip \z@skip + } + + +% ### `csquotes` + +\AtEndOfPackageFile* { csquotes } + { + \BlockquoteDisable + { + \cs_set_eq:NN \__csl_process_citation_info:NN \use_none:nn + \cs_set_eq:NN \__csl_make_citation:N \use_none:n + } + } + + +% ### `hyperref` + +% The hyperref package also patches \bibcite but it cannot provide hyperlinks +% when used with csl. +\bool_new:N \l__csl_hyperref_loaded_bool +\AtEndOfPackageFile* { hyperref } + { + \bool_set_true:N \l__csl_hyperref_loaded_bool + % Pakcage "hyperref" redefines \@lbibitem and \bibitem and we need to + % recover them. + \cs_gset_eq:NN \@lbibitem \__csl_lbibitem: + \cs_gset_eq:NN \@bibitem \__csl_bibitem: + \cs_gset_eq:NN \__csl_lbibitem_plain:nn \__csl_hyperref_lbibitem:nn + \cs_gset_eq:NN \__csl_bibitem_plain:n \__csl_hyperref_bibitem:n + \cs_gset_eq:NN \cslcite \__csl_hyperref_cite_item:nn + } + +\cs_set:Npn \__csl_hyperref_cite_item:nn #1#2 + { \hyper@@link [ cite ] { } { cite. #1 \@extra@b@citeb } { #2 } } + +\cs_new:Npn \__csl_hyperref_lbibitem:nn [#1]#2 + { + \clist_gput_right:Nn \g__csl_bib_items_clist {#2} + \@skiphyperreftrue + \H@item[% + \ifx\Hy@raisedlink\@empty + \hyper@anchorstart{cite.#2\@extra@b@citeb}% + \@BIBLABEL{#1}% + \hyper@anchorend + \else + \Hy@raisedlink{% + \hyper@anchorstart{cite.#2\@extra@b@citeb}\hyper@anchorend + }% + \@BIBLABEL{#1}% + \fi + \hfill + ]% + \@skiphyperreffalse + \ignorespaces + } + +\cs_new:Npn \__csl_hyperref_bibitem:n #1 + { + \clist_gput_right:Nn \g__csl_bib_items_clist {#1} + \@skiphyperreftrue \H@item \@skiphyperreffalse + \Hy@raisedlink + { + \hyper@anchorstart + { cite. #1 \@extra@b@citeb } \relax + \hyper@anchorend + } + \ignorespaces + } diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-data.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-data.sty new file mode 100644 index 00000000000..f3fc7f13b18 --- /dev/null +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-data.sty @@ -0,0 +1,10 @@ +% +% Copyright (c) 2021-2023 Zeping Lee +% Released under the MIT License. +% Repository: https://github.com/zepinglee/citeproc-lua +% + +% ## Bibliography commands + +\NewDocumentCommand \addbibresource { o m } + { \clist_put_right:Nn \l__csl_bib_resources_clist {#2} } diff --git a/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-init.sty b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-init.sty new file mode 100644 index 00000000000..53aea6d4f5e --- /dev/null +++ b/Master/texmf-dist/tex/latex/citation-style-language/citation-style-language-init.sty @@ -0,0 +1,306 @@ +% +% Copyright (c) 2021-2023 Zeping Lee +% Released under the MIT License. +% Repository: https://github.com/zepinglee/citeproc-lua +% + +% ## Initialization at `\begin{document}` + +\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: } + } + + +\clist_new:N \g__csl_aux_bib_files_clist + +\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 + \edef \csl@style { \g__csl_aux_bibstyle_tl } + } + { \exp_args:Nx \__csl_write_aux_bibstyle:n { \l__csl_style_tl } } + \clist_if_empty:NTF \l__csl_bib_resources_clist + { \clist_set_eq:NN \l__csl_bib_resources_clist \g__csl_aux_bib_files_clist } + { + \exp_args:Nx \__csl_write_aux_bibdata:n + { \clist_use:Nn \l__csl_bib_resources_clist { , } } + } + \__csl_write_aux_csl_options: + } + +\cs_new:Npn \__csl_write_aux_bibstyle:n #1 + { + \if@filesw + \iow_now:Nx \@auxout { \token_to_str:N \csl@aux@style {#1} } + \fi + } + +\cs_new:Npn \__csl_write_aux_bibdata:n #1 + { + \if@filesw + % Full expansion for files like \jobname.bib + \iow_now:Nx \@auxout { \token_to_str:N \csl@aux@data {#1} } + \fi + } + +% In earlier time, \bibdata{xxx.json} was used but this causes latexmk unable +% to find xxx.json.bib and it refuses to run the $bibtex procedure. +% John Collins suggests using a different command than \bibdata. +\cs_new:Npn \csl@aux@data #1 + { \clist_gput_right:Nn \g__csl_aux_bib_files_clist {#1} } + + + +\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 + +\cs_new:Npn \__csl_get_style_class: { + \bool_if:NT \l__csl_engine_initialized_bool + { + \tl_set:Nx \l__csl_class_tl { \lua_now:n { csl.get_style_class() } } + \tl_if_eq:NnT \l__csl_class_tl { note } + { \bool_set_true:N \l__csl_note_bool } + } +} + + +\clist_new:N \l__csl_options_clist + +\bool_new:N \l__csl_engine_initialized_bool + +\prop_set_from_keyval:Nn \l__csl_language_code_map_prop + { + 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, + } + + +\cs_new:Npn \__csl_write_aux_csl_options: + { + \clist_clear:N \l__csl_options_clist + % locale + \tl_if_empty:NT \l__csl_locale_tl + { + \tl_if_exist:NT \bbl@main@language + { + \prop_get:NVN \l__csl_language_code_map_prop \bbl@main@language + \l__csl_locale_tl + } + } + \tl_if_empty:NF \l__csl_locale_tl + { + \clist_put_right:Nx \l__csl_options_clist + { locale = \l__csl_locale_tl } + } + % linking + \@ifpackageloaded { hyperref } + { \clist_put_right:Nn \l__csl_options_clist { linking = true } } + { } + % write to aux file + \prop_if_empty:NF \l__csl_options_clist + { + \exp_args:Nx \__csl_write_aux_options:n + { \clist_use:Nn \l__csl_options_clist { , } } + } + } + +\cs_new:Npn \__csl_write_aux_options:n #1 + { + \if@filesw + \iow_now:Nn \@auxout { \csl@aux@options {#1} } + \fi + } + +\cs_new:Npn \csl@aux@options #1 { } + + +\tl_new:N \g__csl_bibliography_setup_tl + +% Load .bbl at the beginning of document to save one pass of latex. +% In this procedure, the \cslcitation command is processed and the contents +% of `thebibliography` is stored into \g__csl_bibliographies_prop. +\cs_new:Npn \__csl_load_bbl: + { + % The \@input@ prints "No file ....bbl" in the .log file from which + % the latexmk decides to run $bibtex or not. + \__csl_collect_bibliography:n { \@input@ { \jobname .bbl } } + % Execute the \cslsetup part to set the style class. + % \tl_show:N \g__csl_bibliography_setup_tl + \tl_use:N \g__csl_bibliography_setup_tl + % \bool_show:N \l__csl_note_bool + } + + +% A document may have multiple bibliographies or biblists and they are stored +% in `\g__csl_bibliographies_prop` by their index. +\prop_new:N \g__csl_bibliographies_prop + + +% Collection the bibliography into \g__csl_bibliographies_prop +\cs_new:Npn \__csl_collect_bibliography:n #1 + { + \group_begin: + % URLs may contain "%" and "#" characters. + \char_set_catcode_other:N \% + \char_set_catcode_other:N \# + \RenewDocumentCommand \cslsetup { m } + { \tl_gset:Nn \g__csl_bibliography_setup_tl { \cslsetup { ##1 } } } + \RenewDocumentEnvironment { thebibliography } { m +b } + { + \tl_set:Nn \l__csl_bib_index_tl { 1 } + \keys_set:nn { csl / bib-options } {##1} + \prop_gput:NVn \g__csl_bibliographies_prop \l__csl_bib_index_tl + { + \begin { thebibliography } {##1} + ##2 + \end { thebibliography } + } + } + { } + % Perform the execution + #1 + \group_end: + } + +% \msg_new:nnn { citation-style-language } { file / non-exist } +% { No~ file~ #1. } 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 5566737b49b..0e97c76dd5d 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,13 +9,14 @@ \RequirePackage{expl3} \RequirePackage{xparse} -\ProvidesExplPackage {citation-style-language} {2023-04-02} {v0.4.0} +\ProvidesExplPackage {citation-style-language} {2023-04-12} {v0.4.1} {Citation Style Language for LaTeX} \RequirePackage { l3keys2e } \RequirePackage { filehook } \RequirePackage { url } + % Check incompatible packages \msg_new:nnn { citation-style-language } { incompatible-package } { The~ `#1'~ package~ is~ incompatible~ with~ `citation-style-language'. } @@ -32,651 +33,18 @@ } -% Check l3build regression-test -\bool_new:N \l__csl_regression_test_bool -% \if_meaning:w \ASSERT \@undefined -% \else -% \bool_set_true:N \l__csl_regression_test_bool -% \fi - - +% Load Lua module in LuaTeX \sys_if_engine_luatex:T { \lua_now:n { csl = require("citeproc-latex") } } +% Global options + \NewDocumentCommand \cslsetup { m } { \keys_set:nn { csl } {#1} } -\cs_new:Npn \csl@aux@options #1 { } - - -\DeclareDocumentCommand \cite { o o m } - { \__csl_cite:nnn {#1} {#2} {#3} } - -\NewDocumentCommand \parencite { o o m } - { \__csl_cite:nnn {#1} {#2} {#3} } - -\NewDocumentCommand \citep { o o m } - { \__csl_cite:nnn {#1} {#2} {#3} } - -\NewDocumentCommand \textcite { o o m } - { \__csl_text_cite:nnn {#1} {#2} {#3} } - -\NewDocumentCommand \citet { o o m } - { \__csl_text_cite:nnn {#1} {#2} {#3} } - -\NewDocumentCommand \footcite { o o m } - { \__csl_cite:nnn {#1} {#2} {#3} } - - -% \cites[⟨prenote⟩][⟨postnote⟩]{⟨key⟩}...[⟨prenote⟩][⟨postnote⟩]{⟨key⟩} -\NewDocumentCommand \cites { } - { \__csl_cites: } - -\NewDocumentCommand \citeauthor { o o m } - { \__csl_cite_author:nnn {#1} {#2} {#3} } - - -\seq_new:N \l__csl_cite_keys_seq -\seq_new:N \l__csl_citation_items_seq -\prop_new:N \l__csl_citation_properties_prop -\prop_new:N \l__csl_citation_info_prop - -% \__csl_cite:nnn #1#2#3 -\cs_new:Npn \__csl_cite:nnn #1#2#3 - { - \tl_if_blank:nTF {#3} - { \__csl_print_undefined_citation:n {#3} } - { - \seq_clear:N \l__csl_cite_keys_seq - \seq_clear:N \l__csl_citation_items_seq - \prop_clear:N \l__csl_citation_properties_prop - \__csl_process_cite_input:nnn {#1} {#2} {#3} - \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq - \__csl_make_citation:N \l__csl_citation_info_prop - } - } - - -\cs_new:Npn \__csl_text_cite:nnn #1#2#3 - { - \seq_clear:N \l__csl_cite_keys_seq - \seq_clear:N \l__csl_citation_items_seq - \prop_clear:N \l__csl_citation_properties_prop - \__csl_process_cite_input:nnn {#1} {#2} {#3} - \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq - \prop_put:Nnn \l__csl_citation_properties_prop { noteIndex } { 0 } - \prop_put:Nnn \l__csl_citation_properties_prop { mode } { composite } - % \bool_set_false:N \l__csl_note_bool - \__csl_make_citation:N \l__csl_citation_info_prop - } - - -\cs_new:Npn \__csl_cites: - { - \seq_clear:N \l__csl_cite_keys_seq - \seq_clear:N \l__csl_citation_items_seq - \prop_clear:N \l__csl_citation_properties_prop - \__csl_next_cites:nnn - } - -\NewDocumentCommand \__csl_next_cites:nnn { o o g } - { - \tl_if_novalue:nTF {#3} - { - \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq - \__csl_make_citation:N \l__csl_citation_info_prop - } - { - \__csl_process_cite_input:nnn {#1} {#2} {#3} - \__csl_next_cites:nnn - } - } - - -\cs_new:Npn \__csl_cite_author:nnn #1#2#3 - { - \seq_clear:N \l__csl_cite_keys_seq - \seq_clear:N \l__csl_citation_items_seq - \prop_clear:N \l__csl_citation_properties_prop - \__csl_process_cite_input:nnn {#1} {#2} {#3} - \__csl_process_citation_info:NN \l__csl_cite_keys_seq \l__csl_citation_items_seq - \prop_put:Nnn \l__csl_citation_properties_prop { noteIndex } { 0 } - \prop_put:Nnn \l__csl_citation_properties_prop { mode } { author-only } - \bool_set_false:N \l__csl_note_bool - \__csl_make_citation:N \l__csl_citation_info_prop - } - - -% Appends the cite key into \l__csl_cite_keys_seq and cite-items into -% \l__csl_citation_items_seq -% #1, #2: prenote/postnote -% #3: keys -\cs_new:Npn \__csl_process_cite_input:nnn #1#2#3 - { - \tl_if_novalue:nTF {#2} - { - \tl_if_novalue:nTF {#1} - { \__csl_process_cite_input_aux:nnn { } { } {#3} } - { \__csl_process_cite_input_aux:nnn { } {#1} {#3} } - } - { \__csl_process_cite_input_aux:nnn {#1} {#2} {#3} } - } - -\cs_new:Npn \__csl_process_cite_input_aux:nnn #1#2#3 - % #1: prenote, #2: postnote, #3: keys - % Return: "{id={ITEM-1},{locator=6},...}, {id={ITEM-2},...}, ..." - { - \int_zero:N \l_tmpa_int - \clist_map_inline:nn {#3} - { - \int_incr:N \l_tmpa_int - \seq_put_right:Nn \l__csl_cite_keys_seq {##1} - \int_compare:nNnTF { \l_tmpa_int } = { 1 } - { \__csl_process_cite_item:nnn {#1} {#2} {##1} } - { \__csl_process_cite_item:nnn { } { } {##1} } - } - } - - -\prop_new:N \l__csl_cite_item_prop -\tl_new:N \l__csl_prefix_tl -\tl_new:N \l__csl_suffix_tl - -\cs_new:Npn \__csl_process_cite_item:nnn #1#2#3 - % #1: prenote, #2: postnote, #3: key - % Save "{id={ITEM},locator={42},label={page}}" into \l__csl_citation_items_seq - { - \prop_clear:N \l__csl_cite_item_prop - \prop_put:Nnn \l__csl_cite_item_prop { id } {#3} - % \bool_if:T \l__csl_suppress_author_bool - % { \prop_put:Nnn \l__csl_cite_item_prop { suppress-author } { true } } - % \bool_if:T \l__csl_author_only_bool - % { \prop_put:Nnn \l__csl_cite_item_prop { author-only } { true } } - \tl_if_empty:nF {#1} - { - \tl_set:Nn \l__csl_prefix_tl {#1} - \tl_put_right:NV \l__csl_prefix_tl \l__csl_prefix_separator_tl - \prop_put:NnV \l__csl_cite_item_prop { prefix } \l__csl_prefix_tl - } - \tl_if_empty:nF {#2} - { - \tl_if_in:nnTF {#2} { = } - { \keys_set:nn { csl / cite-item } {#2} } - { - \regex_match:nnTF { \d+ } {#2} - { \__csl_set_locator:nn { page } {#2} } - { - \tl_set:Nn \l__csl_suffix_tl {#2} - \tl_put_left:NV \l__csl_suffix_tl \l__csl_suffix_separator_tl - \prop_put:NnV \l__csl_cite_item_prop { suffix } \l__csl_suffix_tl - } - } - } - \__csl_serialize_prop:NN \l__csl_cite_item_prop \l_tmpa_tl - \tl_put_left:NV \l_tmpa_tl { \c_left_brace_str } - \tl_put_right:NV \l_tmpa_tl { \c_right_brace_str } - \seq_put_right:NV \l__csl_citation_items_seq \l_tmpa_tl - } - -\cs_new:Npn \__csl_set_locator:nn #1#2 - { - \prop_put:Nnn \l__csl_cite_item_prop { label } {#1} - \prop_put:Nnn \l__csl_cite_item_prop { locator } {#2} - } - -\keys_define:nn { csl / cite-item } - { - prefix .prop_put:N = \l__csl_cite_item_prop, - suffix .prop_put:N = \l__csl_cite_item_prop, - locator .prop_put:N = \l__csl_cite_item_prop, - label .prop_put:N = \l__csl_cite_item_prop, - suppress-author .prop_put:N = \l__csl_cite_item_prop, - author-only .prop_put:N = \l__csl_cite_item_prop, - uris .prop_put:N = \l__csl_cite_item_prop, - % Locators. - act .code:n = { \__csl_set_locator:nn { act } {#1} } , - appendix .code:n = { \__csl_set_locator:nn { appendix } {#1} } , - article .code:n = { \__csl_set_locator:nn { article-locator } {#1} } , - book .code:n = { \__csl_set_locator:nn { book } {#1} } , - canon .code:n = { \__csl_set_locator:nn { canon } {#1} } , - chapter .code:n = { \__csl_set_locator:nn { chapter } {#1} } , - column .code:n = { \__csl_set_locator:nn { column } {#1} } , - elocation .code:n = { \__csl_set_locator:nn { elocation } {#1} } , - equation .code:n = { \__csl_set_locator:nn { equation } {#1} } , - figure .code:n = { \__csl_set_locator:nn { figure } {#1} } , - folio .code:n = { \__csl_set_locator:nn { folio } {#1} } , - issue .code:n = { \__csl_set_locator:nn { issue } {#1} } , - line .code:n = { \__csl_set_locator:nn { line } {#1} } , - note .code:n = { \__csl_set_locator:nn { note } {#1} } , - opus .code:n = { \__csl_set_locator:nn { opus } {#1} } , - page .code:n = { \__csl_set_locator:nn { page } {#1} } , - paragraph .code:n = { \__csl_set_locator:nn { paragraph } {#1} } , - part .code:n = { \__csl_set_locator:nn { part } {#1} } , - rule .code:n = { \__csl_set_locator:nn { rule } {#1} } , - scene .code:n = { \__csl_set_locator:nn { scene } {#1} } , - section .code:n = { \__csl_set_locator:nn { section } {#1} } , - sub-verbo .code:n = { \__csl_set_locator:nn { sub-verbo } {#1} } , - supplement .code:n = { \__csl_set_locator:nn { supplement } {#1} } , - table .code:n = { \__csl_set_locator:nn { table } {#1} } , - timestamp .code:n = { \__csl_set_locator:nn { timestamp } {#1} } , - title .code:n = { \__csl_set_locator:nn { title-locator } {#1} } , - verse .code:n = { \__csl_set_locator:nn { verse } {#1} } , - version .code:n = { \__csl_set_locator:nn { version } {#1} } , - volume .code:n = { \__csl_set_locator:nn { volume } {#1} } , - % Citation properties - infix .prop_put:N = \l__csl_citation_properties_prop, - } - - -\tl_new:N \l__csl_citation_id_tl -\tl_new:N \l__csl_cite_items_tl -\tl_new:N \l__csl_note_index_tl - -% Load the cite keys and prepare: -% - \l__csl_citation_id_tl -% - \l__csl_citation_properties_prop -% -% #1: \l__csl_cite_keys_seq -% #2: \l__csl_citation_items_seq -\cs_new:Npn \__csl_process_citation_info:NN #1#2 - { - \__csl_process_citation_id:NN \l__csl_citation_id_tl #1 - \__csl_get_note_index:N \l__csl_note_index_tl - \prop_put:NnV \l__csl_citation_properties_prop { noteIndex } \l__csl_note_index_tl - \__csl_add_back_ref_info: - } - - -\tl_new:N \l__csl_back_ref_tl -\prop_new:N \g__csl_back_ref_info_prop -\prop_new:N \l__csl_back_ref_section_pop - -% Provide empty \@currentHref when hyperref is not loaded. -\cs_new:Npn \@currentHref {} - -% TODO: write backref info to .brf file or .aux file -\cs_new:Npn \__csl_add_back_ref_info: - { - % Same as the second argument of backref's \backcite - % \thepage: the page number - % \@currentlabel: the current label of the citation - % \@currentHref: the current anchor name - \tl_if_empty:NTF \@currentlabel - { - \tl_set:Nx \l__csl_back_ref_tl - { { \thepage } { (document) } { Doc-Start } } - } - { - \tl_set:Nx \l__csl_back_ref_tl - { { \thepage } { \@currentlabel } { \@currentHref } } - } - \seq_map_inline:Nn \l__csl_cite_keys_seq - { - \prop_get:NnNTF \g__csl_back_ref_info_prop {##1} \l_tmpa_tl - { - \tl_put_right:Nn \l_tmpa_tl { , } - \tl_put_right:NV \l_tmpa_tl \l__csl_back_ref_tl - \prop_gput:NnV \g__csl_back_ref_info_prop {##1} \l_tmpa_tl - } - { - \prop_gput:NnV \g__csl_back_ref_info_prop {##1} - \l__csl_back_ref_tl - } - } - } - - -\tl_new:N \l__csl_citation_info_tl -\tl_new:N \l__csl_citation_tl -\prop_new:N \g__csl_citations_prop - -\tl_new:N \l__csl_citation_properties_tl - -% Write citation info to aux and print the citation contents. -% #1: \l__csl_citation_info_prop -\cs_new:Npn \__csl_make_citation:N #1 - { - \prop_clear:N \l__csl_citation_info_prop - % citationID - \prop_put:NnV \l__csl_citation_info_prop { citationID } \l__csl_citation_id_tl - % citationItems - \__csl_serialize_seq:NN \l__csl_citation_items_seq \l__csl_cite_items_tl - \prop_put:NnV \l__csl_citation_info_prop { citationItems } \l__csl_cite_items_tl - % properties - \__csl_serialize_prop:NN \l__csl_citation_properties_prop \l__csl_citation_properties_tl - \prop_put:NnV \l__csl_citation_info_prop { properties } \l__csl_citation_properties_tl - \__csl_serialize_prop:NN \l__csl_citation_info_prop \l__csl_citation_info_tl - % Write to .aux file - % \tl_show:N \l__csl_citation_info_tl - \exp_args:NV \__csl_write_aux_citation:n \l__csl_citation_info_tl - \bool_if:NT \l__csl_regression_test_bool - { \tl_show:N \l__csl_citation_info_tl } - % Print the citation string - \prop_get:NVNTF \g__csl_citations_prop \l__csl_citation_id_tl - \l__csl_citation_tl - { \__csl_print_citation:N \l__csl_citation_tl } - { - \bool_if:NTF \l__csl_engine_initialized_bool - { - % \tl_show:N \l__csl_citation_info_tl - % \tl_set:Nf \l__csl_citation_tl - % { \exp_args:NV \__csl_cite_aux:n \l__csl_citation_info_tl } - \group_begin: - \char_set_catcode_other:N \% - \char_set_catcode_other:N \# - \exp_args:NV \__csl_cite_aux:n \l__csl_citation_info_tl - \__csl_print_citation:N \l__csl_citation_tl - \group_end: - } - { - \exp_args:Nx \__csl_print_undefined_citation:n - { \seq_use:Nn \l__csl_cite_keys_seq { ,~ } } - } - } - } - -\cs_new:Npn \__csl_cite_aux:n #1 - { \lua_now:e { csl.cite("\lua_escape:n {#1}") } } - -% #1: seq -% #2: tl -\cs_new:Npn \__csl_serialize_seq:NN #1#2 - { - \tl_clear:N #2 - \seq_map_inline:Nn #1 - { - \tl_if_empty:NF #2 - { \tl_put_right:Nn #2 { , } } - \tl_put_right:Nn #2 { ##1 } - } - } - -% #1: prop -% #2: tl -\cs_new:Npn \__csl_serialize_prop:NN #1#2 - { - \tl_clear:N #2 - \prop_map_inline:Nn #1 - { - \tl_if_empty:NF #2 - { \tl_put_right:Nn #2 { , } } - \tl_put_right:Nn #2 { ##1 = { ##2 } } - } - } - -\tl_new:N \l__csl_cite_keys_tl -\tl_new:N \l__csl_citation_count_tl -\int_new:N \l__csl_citation_count_int -\prop_new:N \g__csl_citations_count_prop - -\cs_new:Npn \__csl_process_citation_id:NN #1#2 - % #1: \l__csl_citation_id_tl - % #2: \l__csl_cite_keys_seq - % Set \l__csl_citation_id_tl = "ITEM-1,ITEM-2@4". - { - \tl_set:Nx \l__csl_cite_keys_tl - { \seq_use:Nn #2 { , } } - % \prop_show:N \g__csl_citations_count_prop - % \tl_show:N \l__csl_cite_keys_tl - \prop_get:NVNTF \g__csl_citations_count_prop \l__csl_cite_keys_tl - \l__csl_citation_count_tl - { - \int_set:Nn \l__csl_citation_count_int { \l__csl_citation_count_tl } - \int_incr:N \l__csl_citation_count_int - } - { \int_set_eq:NN \l__csl_citation_count_int \c_one_int } - \prop_gput:NVV \g__csl_citations_count_prop \l__csl_cite_keys_tl - \l__csl_citation_count_int - \tl_set:Nx #1 - { \l__csl_cite_keys_tl @ \int_use:N \l__csl_citation_count_int } - } - - -\int_new:N \g__csl_pseudo_note_index_int -\int_gset:Nn \g__csl_pseudo_note_index_int { 0 } - -% Save the note number to \l__csl_note_index_tl -% TODO: multiple citations in a note -\cs_new:Npn \__csl_get_note_index:N #1 - % #1: \l__csl_note_index_tl - { - \bool_if:NTF \l__csl_note_bool - { - \int_set_eq:Nc \l_tmpa_int { c@ \@mpfn } - \int_incr:N \l_tmpa_int - \tl_set:Nx #1 { \int_use:N \l_tmpa_int } - } - { - \tl_if_empty:NTF \l__csl_class_tl - { - % The style class (in-text/note) is undetermined. - \int_set_eq:Nc \l_tmpa_int { c@ \@mpfn } - \int_gincr:N \g__csl_pseudo_note_index_int - \int_add:Nn \l_tmpa_int { \g__csl_pseudo_note_index_int } - \tl_set:Nx #1 { \int_use:N \l_tmpa_int } - } - { \tl_set:Nx #1 { 0 } } - } - } - - -\cs_new:Npn \__csl_write_aux_citation:n #1 - % #1: citation info "{<citationID>}{{id=ITEM-1},{id=ITEM-2}}{<noteIndex>}" - { - \if@filesw - \iow_now:Nn \@auxout { \csl@aux@cite {#1} } - \fi - } - - -% #1: \l__csl_citation_tl -\cs_new:Npn \__csl_print_citation:N #1 - { - \bool_if:NT \l__csl_regression_test_bool - { \tl_show:N #1 } - \bool_if:NTF \l__csl_note_bool - { \footnote {#1} } - {#1} - } - - -\cs_new:Npn \__csl_print_undefined_citation:n #1 - % #1: keys - { - \G@refundefinedtrue - \msg_warning:nnn { citation-style-language } { citation / undefined } {#1} - \tl_if_blank:nTF {#1} - { \tl_set:Nn \l__csl_citation_tl { [ \textbf { ? } ] } } - { \tl_set:Nn \l__csl_citation_tl { [ \textbf {#1} ] } } - \bool_if:NT \l__csl_regression_test_bool - { \tl_show:N \l__csl_citation_tl } - \group_begin: - \reset@font \l__csl_citation_tl - \group_end: - } - -\msg_new:nnn { citation-style-language } { citation / undefined } - { Citation~ `#1'~ on~ page~ \thepage \space undefined~ \msg_line_context: . } - - -\DeclareDocumentCommand \nocite { m } - { \__csl_no_cite:n {#1} } - - -\cs_new:Npn \__csl_no_cite:n #1 - { - \seq_clear:N \l__csl_cite_keys_seq - \seq_clear:N \l__csl_citation_items_seq - \__csl_process_cite_input:nnn { } { } {#1} - \tl_set:Nx \l__csl_cite_items_tl - { \seq_use:Nn \l__csl_citation_items_seq { , } } - \tl_set:Nx \l__csl_citation_info_tl - { - citationID = { @nocite } , - citationItems = { \l__csl_cite_items_tl } , - properties = { noteIndex = { 0 } } - } - \bool_if:NT \l__csl_regression_test_bool - { \tl_show:N \l__csl_citation_info_tl } - \exp_args:NV \__csl_no_cite_write_aux:n \l__csl_citation_info_tl - \sys_if_engine_luatex:T - { \lua_now:n { csl.nocite("#1") } } - \tl_clear:N \l__csl_citation_tl - \bool_if:NT \l__csl_regression_test_bool - { \tl_show:N \l__csl_citation_tl } -} - - -\cs_new:Npn \__csl_no_cite_write_aux:n #1 - { - \__csl_if_preamble:TF - { - \AtBeginDocument - { \exp_args:Nx \__csl_write_aux_citation:n { #1 } } - } - { \exp_args:Nx \__csl_write_aux_citation:n { #1 } } - } - - -\prg_new_conditional:Nnn \__csl_if_preamble: { T , F , TF } - { - \if_meaning:w \@begindocumenthook \@undefined - \prg_return_false: - \else - \prg_return_true: - \fi - } - - -% Used in aux files to register cite items. -% #1: a citation object -\cs_set:Npn \csl@aux@cite #1 - { - \sys_if_engine_luatex:T - { \lua_now:e { csl.register_citation_info("\lua_escape:n {#1}") } } - } - - -\cs_new:Npn \cslcitation #1#2 - { \prop_gput:Nnn \g__csl_citations_prop {#1} {#2} } - - -% This command is for use with hyperref. -% #1: cite id -% #2: cite contents -\cs_new:Npn \cslcite #1#2 {#2} - - -\keys_define:nn { csl / bibliography } - { - type .code:n = \__csl_add_filter_condition:nn { type } {#1} , - nottype .code:n = \__csl_add_filter_condition_negative:nn { type } {#1} , % subtype .code:n = \__csl_add_filter_condition:nn { subtype } {#1} , - % notsubtype .code:n = \__csl_add_filter_condition_negative:nn { subtype } {#1} , - keyword .code:n = \__csl_add_filter_condition:nn { keyword } {#1} , - notkeyword .code:n = \__csl_add_filter_condition_negative:nn { keyword } {#1} , - category .code:n = \__csl_add_filter_condition:nn { categories } {#1} , - notcategory .code:n = \__csl_add_filter_condition_negative:nn { categories } {#1} , - % filter .tl_set:N = \l__csl_bibliography_nottype_tl , - } - -\seq_new:N \l__bibliography_filter_conditions_seq -\tl_new:N \l__bibliography_filter_conditions_tl - -\cs_new:Npn \__csl_add_filter_condition:nn #1#2 - { - \seq_put_right:Nn \l__bibliography_filter_conditions_seq - { - { - field = #1 , - value = #2 - } - } - } - -\cs_new:Npn \__csl_add_filter_condition_negative:nn #1#2 - { - \seq_put_right:Nn \l__bibliography_filter_conditions_seq - { - { - field = #1, - value = #2, - negative = true - } - } - } - - -\NewDocumentCommand \printbibliography { O { } } - { - % Set categories - \prop_if_empty:NF \l__csl_categories_prop - { - \tl_clear:N \l_tmpa_tl - \prop_map_inline:Nn \l__csl_categories_prop - { - \tl_if_empty:NF \l_tmpa_tl - { \tl_put_right:Nn \l_tmpa_tl { , } } - \tl_put_right:Nn \l_tmpa_tl { ##1 = {##2} } - } - \sys_if_engine_luatex:T - { \lua_now:e { csl.set_categories("\l_tmpa_tl") } } - { - \tl_put_left:Nx \l_tmpa_tl { categories = \c_left_brace_str } - \tl_put_right:NV \l_tmpa_tl \c_right_brace_str - \exp_args:NV \__csl_write_aux_options:n \l_tmpa_tl - } - } - % Bibliography filter - \seq_clear:N \l__bibliography_filter_conditions_seq - \keys_set:nn { csl / bibliography } {#1} - \tl_clear:N \l__bibliography_filter_conditions_tl - \seq_if_empty:NF \l__bibliography_filter_conditions_seq - { - \tl_set:Nx \l__bibliography_filter_conditions_tl - { select = \c_left_brace_str } - \tl_put_right:Nx \l__bibliography_filter_conditions_tl - { \seq_use:Nn \l__bibliography_filter_conditions_seq { , } } - \tl_put_right:NV \l__bibliography_filter_conditions_tl - { \c_right_brace_str } - % Write to aux file - \sys_if_engine_luatex:F - { - \tl_set:Nx \l_tmpa_tl { bib-filter = \c_left_brace_str } - \tl_put_right:NV \l_tmpa_tl { \l__bibliography_filter_conditions_tl } - \tl_put_right:NV \l_tmpa_tl { \c_right_brace_str } - \exp_args:NV \__csl_write_aux_options:n \l_tmpa_tl - } - } - % Collect the bibliography to token list - \sys_if_engine_luatex:T - { - \bool_if:NT \l__csl_engine_initialized_bool - { - \__csl_collect_bibliography:n - { - \lua_now:e - { csl.bibliography("\l__bibliography_filter_conditions_tl") } - } - } - } - % Print the bibliography - \tl_if_empty:NTF \g__csl_bibliography_tl - { \msg_warning:nn { citation-style-language } { bibliography / empty } } - { - \bool_if:NT \l__csl_regression_test_bool - { - \seq_set_split:NnV \l__csl_bibliography_seq { \par } \g__csl_bibliography_tl - \seq_show:N \l__csl_bibliography_seq - } - \tl_use:N \g__csl_bibliography_tl - } - } - -\msg_new:nnn { citation-style-language } { bibliography / empty } - { The~ bibliography~ is~ empty. } - +\bool_new:N \l__csl_regression_test_bool \tl_new:N \l__csl_style_tl \newcommand \csl@style {} % For latex2e interface \tl_new:N \l__csl_class_tl @@ -694,11 +62,6 @@ \bool_new:N \l__csl_bib_entry_page_break_bool \tl_new:N \l__csl_bib_item_sep_tl \tl_new:N \l__csl_bib_hang_tl -\bool_new:N \l__csl_hanging_indent_bool -\tl_new:N \l__csl_line_spacing_tl -\tl_new:N \l__csl_entry_spacing_tl - -\tl_set:Nn \l__csl_back_ref_type_str { page } \keys_define:nn { csl } @@ -728,451 +91,6 @@ bib-entry-page-break .bool_set:N = \l__csl_bib_entry_page_break_bool , bib-item-sep .tl_set:N = \l__csl_bib_item_sep_tl , bib-hang .tl_set:N = \l__csl_bib_hang_tl , - hanging-indent .bool_set:N = \l__csl_hanging_indent_bool , - line-spacing .tl_set:N = \l__csl_line_spacing_tl , - entry-spacing .tl_set:N = \l__csl_entry_spacing_tl , - } - -\keys_set:nn { csl } - { - prefix-separator = { ~ } , - suffix-separator = { , ~ } , - bib-entry-page-break = true , - bib-hang = { 1 em } , - line-spacing = { 1 } , - entry-spacing = { 1 } , - } - - -\ProcessKeysPackageOptions { csl } - -\bool_new:N \l__csl_engine_initialized_bool - -\prop_set_from_keyval:Nn \l__csl_language_code_map_prop - { - 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, - } - -\tl_new:N \g__csl_bibliography_tl -\tl_new:N \g__csl_bibliography_setup_tl -\seq_new:N \l__csl_bibliography_seq - - -\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: } - } - - -\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 - \edef \csl@style { \g__csl_aux_bibstyle_tl } - } - { \exp_args:Nx \__csl_write_aux_bibstyle:n { \l__csl_style_tl } } - \clist_if_empty:NTF \l__csl_bib_resources_clist - { \clist_set_eq:NN \l__csl_bib_resources_clist \g__csl_aux_bib_files_clist } - { - \exp_args:Nx \__csl_write_aux_bibdata:n - { \clist_use:Nn \l__csl_bib_resources_clist { , } } - } - \__csl_write_aux_csl_options: - } - -\cs_new:Npn \__csl_write_aux_bibstyle:n #1 - { - \if@filesw - \iow_now:Nx \@auxout { \token_to_str:N \csl@aux@style {#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 - -\cs_new:Npn \__csl_get_style_class: { - \bool_if:NT \l__csl_engine_initialized_bool - { - \tl_set:Nx \l__csl_class_tl { \lua_now:n { csl.get_style_class() } } - \tl_if_eq:NnT \l__csl_class_tl { note } - { \bool_set_true:N \l__csl_note_bool } - } -} - - -\clist_new:N \l__csl_options_clist - -\cs_new:Npn \__csl_write_aux_csl_options: - { - \clist_clear:N \l__csl_options_clist - % locale - \tl_if_empty:NT \l__csl_locale_tl - { - \tl_if_exist:NT \bbl@main@language - { - \prop_get:NVN \l__csl_language_code_map_prop \bbl@main@language - \l__csl_locale_tl - } - } - \tl_if_empty:NF \l__csl_locale_tl - { - \clist_put_right:Nx \l__csl_options_clist - { locale = \l__csl_locale_tl } - } - % linking - \@ifpackageloaded { hyperref } - { \clist_put_right:Nn \l__csl_options_clist { linking = true } } - { } - % write to aux file - \prop_if_empty:NF \l__csl_options_clist - { - \exp_args:Nx \__csl_write_aux_options:n - { \clist_use:Nn \l__csl_options_clist { , } } - } - } - -\cs_new:Npn \__csl_write_aux_options:n #1 - { - \if@filesw - \iow_now:Nn \@auxout { \csl@aux@options {#1} } - \fi - } - - -% Load .bbl at the beginning of document to save one pass of latex. -% In this procedure, the \cslcitation command is processed and the contents -% of `thebibliography` is stored into \g__csl_bibliography_tl. -\cs_new:Npn \__csl_load_bbl: - { - % The \@input@ prints "No file ....bbl" in the .log file from which - % the latexmk decides to run $bibtex or not. - \__csl_collect_bibliography:n { \@input@ { \jobname .bbl } } - % Execute the \cslsetup part to set the style class. - % \tl_show:N \g__csl_bibliography_setup_tl - \tl_use:N \g__csl_bibliography_setup_tl - % \bool_show:N \l__csl_note_bool - } - -% Collection the bibliography (as well as \cslsetup) into \g__csl_bibliography_setup_tl -\cs_new:Npn \__csl_collect_bibliography:n #1 - { - \group_begin: - % URLs may contain "%" and "#" characters. - \char_set_catcode_other:N \% - \char_set_catcode_other:N \# - \RenewDocumentCommand \cslsetup { m } - { \tl_gset:Nn \g__csl_bibliography_setup_tl { \cslsetup { ##1 } } } - \RenewDocumentEnvironment { thebibliography } { m +b } - { - \tl_gset:Nn \g__csl_bibliography_tl - { - \begin { thebibliography } {##1} - ##2 - \end { thebibliography } - } - } - { } - % Perform the execution - #1 - \tl_if_empty:NF \g__csl_bibliography_setup_tl - { - \tl_gput_left:Nn \g__csl_bibliography_tl { \par } - \tl_gput_left:NV \g__csl_bibliography_tl \g__csl_bibliography_setup_tl - } - \group_end: - } - -% \msg_new:nnn { citation-style-language } { file / non-exist } -% { No~ file~ #1. } - - -\DeclareDocumentCommand \bibliographystyle { m } - { - \__csl_if_preamble:F - { \__csl_write_aux_bibstyle:n {#1} } - \tl_set:Nn \l__csl_style_tl {#1} - } - -\tl_new:N \g__csl_aux_bibstyle_tl -\cs_set:Npn \csl@aux@style #1 - { \tl_gset:Nn \g__csl_aux_bibstyle_tl {#1} } - - -\NewDocumentCommand \addbibresource { o m } - { \clist_put_right:Nn \l__csl_bib_resources_clist {#2} } - - -% In earlier time, \bibdata{xxx.json} was used but this causes latexmk unable -% to find xxx.json.bib and it refuses to run the $bibtex procedure. -% John Collins suggests using a different command than \bibdata. -\clist_new:N \g__csl_aux_bib_files_clist -\cs_new:Npn \csl@aux@data #1 - { \clist_gput_right:Nn \g__csl_aux_bib_files_clist {#1} } - - -\DeclareDocumentCommand \bibliography { m } - { - \__csl_write_aux_bibdata:n {#1} - \printbibliography - } - -\cs_new:Npn \__csl_write_aux_bibdata:n #1 - { - \if@filesw - % Full expansion for files like \jobname.bib - \iow_now:Nx \@auxout { \token_to_str:N \csl@aux@data {#1} } - \fi - } - - -% Used for debugging and testing -\clist_new:N \g__csl_bib_items_clist -% Backref -\bool_set_false:N \l__csl_back_ref_bool - -% For numeric or label-style bibliography -% \def\@lbibitem[#1]#2{\item[\@biblabel{#1}\hfill]\if@filesw -% {\let\protect\noexpand -% \immediate -% \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces} -\cs_new:Npn \__csl_lbibitem_plain:nn [#1]#2 - { - \clist_gput_right:Nn \g__csl_bib_items_clist {#2} - \item [ \@biblabel {#1} \hfill ] - \ignorespaces - } - -\cs_new:Npn \__csl_lbibitem_back_ref:nnn [#1]#2#3\par - { - \__csl_lbibitem_plain:nn [#1] {#2} - #3 - \prop_get:NnNT \g__csl_back_ref_info_prop {#2} \l_tmpa_tl - { - \c_space_tl - \exp_args:NV \__csl_print_back_refs:n \l_tmpa_tl - } - \par - } - -\cs_new:Npn \__csl_print_back_refs:n #1 - % #1: list of {<page>}{<label>}{anchor} - { - \clist_set:Nn \l_tmpa_clist {#1} - % To remove duplicates - \prop_clear:N \l_tmpa_prop - % Output seq - \seq_clear:N \l_tmpa_seq - \clist_map_inline:Nn \l_tmpa_clist { \__csl_print_back_ref_aux:nnn ##1 } - \backref { \seq_use:Nn \l_tmpa_seq { ,~ } } - } - -\cs_new:Npn \__csl_print_back_ref_aux:nnn #1#2#3 - { - \str_if_eq:VnTF \l__csl_back_ref_type_str { page } - { - \prop_if_in:NnF \l_tmpa_prop {#1} - { - \bool_if:NTF \l__csl_hyperref_loaded_bool - { \seq_put_right:Nn \l_tmpa_seq { \hyperlink { page. #1 } {#1} } } - { \seq_put_right:Nn \l_tmpa_seq {#1} } - \prop_put:Nnn \l_tmpa_prop {#1} {#1} - } - } - { - % section - \prop_if_in:NnF \l_tmpa_prop {#2} - { - \bool_if:NTF \l__csl_hyperref_loaded_bool - { \seq_put_right:Nn \l_tmpa_seq { \hyperlink {#3} {#2} } } - { \seq_put_right:Nn \l_tmpa_seq {#2} } - \prop_put:Nnn \l_tmpa_prop {#2} {#2} - } - } - } - -% Hook -\cs_new:Npn \backref #1 {#1} - -\cs_new:Npn \__csl_lbibitem: - { - \bool_if:NTF \l__csl_back_ref_bool - { \__csl_lbibitem_back_ref:nnn } - { \__csl_lbibitem_plain:nn } - } - -\cs_set_eq:NN \@lbibitem \__csl_lbibitem: - - -% For author-date bibliography -% \def\@bibitem#1{\item\if@filesw \immediate\write\@auxout -% {\string\bibcite{#1}{\the\value{\@listctr}}}\fi\ignorespaces} -\cs_new:Npn \__csl_bibitem: - { - \bool_if:NTF \l__csl_back_ref_bool - { \__csl_bibitem_back_ref:nn } - { \__csl_bibitem_plain:n } - } - -\cs_set_eq:NN \@bibitem \__csl_bibitem: - -\cs_new:Npn \__csl_bibitem_plain:n #1 - { - \clist_gput_right:Nn \g__csl_bib_items_clist {#1} - \item - \ignorespaces - } - -\cs_new:Npn \__csl_bibitem_back_ref:nn #1#2\par - { - \__csl_bibitem_plain:n {#1} - #2 - % \prop_show:N \g__csl_back_ref_info_prop - \prop_get:NnNT \g__csl_back_ref_info_prop {#1} \l_tmpa_tl - { - \c_space_tl - \exp_args:NV \__csl_print_back_refs:n \l_tmpa_tl - } - \par } \cs_new:Npn \__csl_set_back_ref:n #1 @@ -1189,372 +107,38 @@ } } - -% CSL outputs the whole label thus the brackets are removed from \@biblabel -% \def\@biblabel#1{[#1]} -\cs_set:Npn \@biblabel #1 {#1} - - -% Bibliography heading -\cs_if_exist:cTF { chapter } - { - \tl_set:Nn \bibsection - { - \chapter* - { - \bibname - \@mkboth - { \MakeUppercase { \bibname } } - { \MakeUppercase { \bibname } } - } - } - } - { - \tl_set:Nn \bibsection - { - \section* - { - \refname - \@mkboth - { \MakeUppercase { \refname } } - { \MakeUppercase { \refname } } - } - } - } - -\tl_new:N \l__csl_bib_preamble_tl - -\tl_new:N \l__csl_bib_postamble_tl - -\dim_new:N \l__csl_bib_hang_dim - -\cs_new:Npn \__csl_set_bib_label_spacing:n #1 - { - \bool_if:NTF \l__csl_hanging_indent_bool - { - \dim_set:Nn \l__csl_bib_hang_dim { \l__csl_bib_hang_tl } - \dim_set_eq:NN \leftmargin \l__csl_bib_hang_dim - \dim_set:Nn \itemindent { - \leftmargin } - } - { - \settowidth \labelwidth { \@biblabel {#1} } - \dim_set_eq:NN \leftmargin \labelwidth - \dim_add:Nn \leftmargin { \labelsep } - } - } - -% In standard LaTeX classes (10pt), the vertical sep of bibliographic item is -% \itemsep (4\p@ \@plus2\p@ \@minus\p@) + \parsep (4\p@ \@plus2\p@ \@minus\p@) -% = 8pt plus 4pt minus 2pt -\cs_new:Npn \__csl_set_bib_item_sep: - { - \skip_zero:N \parsep - \tl_if_empty:NTF \l__csl_bib_item_sep_tl - { - \skip_set:Nn \itemsep - { - 8 pt plus 4 pt minus 2 pt * \dim_ratio:nn { 1 em } { 8 pt } - * \l__csl_entry_spacing_tl - } - } - { \skip_set:Nn \itemsep { \l__csl_bib_item_sep_tl } } - } - - -% See <https://github.com/plk/biblatex/blob/e16f4aaa5d9857c7b844bbcbe246f0535fd334e9/tex/latex/biblatex/biblatex.def#L219-L258> - -\cs_new:Npn \__csl_set_bib_allow_break: - { - \sloppy - \int_set:Nn \clubpenalty { 4000 } - \int_set_eq:NN \@clubpenalty \clubpenalty - \int_set:Nn \widowpenalty { 4000 } - % \sfcode`\.\@m - \frenchspacing - } - -\cs_new:Npn \__csl_set_bib_no_break: - { - \sloppy - \int_set:Nn \interlinepenalty { 5000 } - \int_set:Nn \widowpenalty { 10000 } - \int_set:Nn \clubpenalty { 10000 } - \int_set_eq:NN \@clubpenalty \clubpenalty - \raggedbottom - \frenchspacing - } - -\cs_new:Npn \__csl_set_bib_page_break: - { - \bool_if:NTF \l__csl_bib_entry_page_break_bool - { \__csl_set_bib_allow_break: } - { \__csl_set_bib_no_break: } - } - - -% Taken from `biblatex`'s \biburlsetup -% https://github.com/plk/biblatex/blob/dev/tex/latex/biblatex/biblatex.def - -\int_new:N \l__csl_url_big_break_penalty_int -\int_new:N \l__csl_url_break_penalty_int -\int_new:N \l__csl_url_num_penalty_int -\int_new:N \l__csl_url_uc_penalty_int -\int_new:N \l__csl_url_lc_penalty_int - -\int_set:Nn \l__csl_url_big_break_penalty_int { 100 } -\int_set:Nn \l__csl_url_break_penalty_int { 200 } -% Allow linebreaks before numbers and letters. -% Taken from `xurl.sty`. -\int_set:Nn \l__csl_url_num_penalty_int { 9000 } -\int_set:Nn \l__csl_url_uc_penalty_int { 9000 } -\int_set:Nn \l__csl_url_lc_penalty_int { 8000 } - -\muskip_new:N \l__csl_url_big_muskip -\muskip_new:N \l__csl_url_num_muskip -\muskip_new:N \l__csl_url_uc_muskip -\muskip_new:N \l__csl_url_lc_muskip - -\muskip_set:Nn \l__csl_url_big_muskip { 0mu plus 3mu } -\muskip_set:Nn \l__csl_url_num_muskip { 0mu } -\muskip_set:Nn \l__csl_url_uc_muskip { 0mu } -\muskip_set:Nn \l__csl_url_lc_muskip { 0mu } - -\cs_new:Npn \__csl_bib_url_setup: - { - \urlstyle { same } - \muskip_set_eq:NN \Urlmuskip \l__csl_url_big_muskip - \mathchardef \UrlBigBreakPenalty = \l__csl_url_big_break_penalty_int - \mathchardef \UrlBreakPenalty = \l__csl_url_break_penalty_int - % \int_set_eq:NN doesn't work here - % \int_set_eq:NN \UrlBigBreakPenalty \l__csl_url_big_break_penalty_int - % \int_set_eq:NN \UrlBreakPenalty \l__csl_url_break_penalty_int - \tl_set:Nn \UrlBigBreaks { \do \: \do \- } - \tl_set:Nn \UrlBreaks - { - \do \. \do \@ \do \/ \do \\ \do \! \do \_ \do \| \do \; \do \> \do \] - \do \) \do \} \do \, \do \? \do \' \do \+ \do \= \do \# \do \$ \do \& - \do \* \do \^ \do \" - } - \int_compare:nNnT { \l__csl_url_num_penalty_int } > { 0 } - { - \clist_map_inline:nn - { \1 , \2 , \3 , \4 , \5 , \6 , \7 , \8 , \9 , \0 } - { - \tl_put_right:Nn \UrlSpecials - { - \do ##1 - { - \mathchar`##1 - \mskip \l__csl_url_num_muskip - \penalty \l__csl_url_num_penalty_int - } - } - } - } - \int_compare:nNnT { \l__csl_url_uc_penalty_int } > { 0 } - { - \clist_map_inline:nn - { - \A , \B , \C , \D , \E , \F , \G , \H , \I , \J , - \K , \L , \M , \N , \O , \P , \Q , \R , \S , \T , - \U , \V , \W , \X , \Y , \Z - } - { - \tl_put_right:Nn \UrlSpecials - { - \do ##1 - { - \mathchar`##1 - \mskip \l__csl_url_uc_muskip - \penalty \l__csl_url_uc_penalty_int - } - } - } - } - \int_compare:nNnT { \l__csl_url_lc_penalty_int } > { 0 } - { - \clist_map_inline:nn - { - \a , \b , \c , \d , \e , \f , \g , \h , \i , \j , - \k , \l , \m , \n , \o , \p , \q , \r , \s , \t , - \u , \v , \w , \x , \y , \z - } - { - \tl_put_right:Nn \UrlSpecials - { - \do ##1 - { - \mathchar`##1 - \mskip \l__csl_url_lc_muskip - \penalty \l__csl_url_lc_penalty_int - } - } - } - } - \cs_set_eq:NN \do \exp_not:N - } - -% The above code allows linebreaks before numbers and letters. -% This is often the only way to break DOIs. It also allows breaks -% after hyphens and adjusts \Urlmuskip to add some stretchability -% to URLs. - - -% It will be used for multi-bibliography. -\cs_new:Npn \__csl_reset_bib_format: - { - \keys_set:nn { csl } { - hanging-indent = false , - line-spacing = 1 , - entry-spacing = 1 , - } - } - -% \newenvironment{thebibliography}[1] -\RenewDocumentEnvironment { thebibliography } { m } - { - \bibsection - \dim_zero:N \parindent - \l__csl_bib_preamble_tl - \tl_if_eq:NnF \l__csl_line_spacing_tl { 1 } - { \linespread { \l__csl_line_spacing_tl } \selectfont } - \l__csl_bib_font_tl - \list { } - { - \__csl_set_bib_label_spacing:n {#1} - \__csl_set_bib_item_sep: - } - \sloppy - \__csl_set_bib_page_break: - \frenchspacing - \__csl_bib_url_setup: - \clist_gclear:N \g__csl_bib_items_clist - } - { - \l__csl_bib_postamble_tl - \tl_set:Nn \@noitemerr - { \msg_warning:nn { citation-style-language } { bibliography / empty } } - \endlist - \__csl_reset_bib_format: - } - - -% Bibliography Categories - -\prop_new:N \l__csl_categories_prop - -% \DeclareBibliographyCategory{⟨category⟩} -\NewDocumentCommand \DeclareBibliographyCategory { m } - { - \prop_put:Nnn \l__csl_categories_prop { #1 } { } - } - -% \addtocategory{⟨category⟩}{⟨keys⟩} -\NewDocumentCommand \addtocategory { m m } - { - \prop_get:NnNTF \l__csl_categories_prop {#1} \l_tmpa_tl - { - \tl_if_empty:NF \l_tmpa_tl - { \tl_put_right:Nn \l_tmpa_tl { , } } - \tl_put_right:Nn \l_tmpa_tl {#2} - \prop_put:NnV \l__csl_categories_prop {#1} \l_tmpa_tl - } - { - \msg_error:nnn { citation-style-language } { category-not-declared } - {#1} - } - } - - -\msg_new:nnn { citation-style-language } { category-not-declared } - { Category~ '#1'~ not~ declared. } - - -% Compatibilities with other packages - -% babel - -% This should be disabled. -\AtEndOfPackageFile* { babel } +% Default settings +\keys_set:nn { csl } { - \RenewDocumentCommand \nocite { m } - { - % \@safe@activestrue\org@nocite{#1}\@safe@activesfalse - \@safe@activestrue - \__csl_no_cite:n {#1} - \@safe@activesfalse - } - \cs_set_eq:NN \bbl@cite@choice \relax - \cs_set_eq:NN \@lbibitem \__csl_lbibitem_plain:nn - \cs_set_eq:NN \@bibitem \__csl_bibitem_plain:n + backref = false , + prefix-separator = { ~ } , + suffix-separator = { , ~ } , + bib-entry-page-break = true , + bib-hang = { 1 em } , } -% csquotes - -\AtEndOfPackageFile* { csquotes } - { - \BlockquoteDisable - { - \cs_set_eq:NN \__csl_process_citation_info:NN \use_none:nn - \cs_set_eq:NN \__csl_make_citation:N \use_none:n - } - } - +\ProcessKeysPackageOptions { csl } -% hyperref -% The hyperref package also patches \bibcite but it cannot provide hyperlinks -% when used with csl. -\bool_new:N \l__csl_hyperref_loaded_bool -\AtEndOfPackageFile* { hyperref } +\DeclareDocumentCommand \bibliographystyle { m } { - \bool_set_true:N \l__csl_hyperref_loaded_bool - % Pakcage "hyperref" redefines \@lbibitem and \bibitem and we need to - % recover them. - \cs_gset_eq:NN \@lbibitem \__csl_lbibitem: - \cs_gset_eq:NN \@bibitem \__csl_bibitem: - \cs_gset_eq:NN \__csl_lbibitem_plain:nn \__csl_hyperref_lbibitem:nn - \cs_gset_eq:NN \__csl_bibitem_plain:n \__csl_hyperref_bibitem:n - \cs_gset_eq:NN \cslcite \__csl_hyperref_cite_item:nn + \__csl_if_preamble:F + { \__csl_write_aux_bibstyle:n {#1} } + \tl_set:Nn \l__csl_style_tl {#1} } -\cs_set:Npn \__csl_hyperref_cite_item:nn #1#2 - { \hyper@@link [ cite ] { } { cite. #1 \@extra@b@citeb } { #2 } } +\tl_new:N \g__csl_aux_bibstyle_tl +\cs_set:Npn \csl@aux@style #1 + { \tl_gset:Nn \g__csl_aux_bibstyle_tl {#1} } -\cs_new:Npn \__csl_hyperref_lbibitem:nn [#1]#2 - { - \clist_gput_right:Nn \g__csl_bib_items_clist {#2} - \@skiphyperreftrue - \H@item[% - \ifx\Hy@raisedlink\@empty - \hyper@anchorstart{cite.#2\@extra@b@citeb}% - \@BIBLABEL{#1}% - \hyper@anchorend - \else - \Hy@raisedlink{% - \hyper@anchorstart{cite.#2\@extra@b@citeb}\hyper@anchorend - }% - \@BIBLABEL{#1}% - \fi - \hfill - ]% - \@skiphyperreffalse - \ignorespaces - } -\cs_new:Npn \__csl_hyperref_bibitem:n #1 - { - \clist_gput_right:Nn \g__csl_bib_items_clist {#1} - \@skiphyperreftrue \H@item \@skiphyperreffalse - \Hy@raisedlink - { - \hyper@anchorstart - { cite. #1 \@extra@b@citeb } \relax - \hyper@anchorend - } - \ignorespaces - } +% Load other modules +\input{citation-style-language-init.sty} +\input{citation-style-language-data.sty} +\input{citation-style-language-cite.sty} +\input{citation-style-language-bib.sty} +\input{citation-style-language-compatible.sty} \endinput |