Module packages.bibtex.csl.engine
A rendering engine for CSL 1.0.2
Info:
- Copyright: License: MIT (c) 2024 Omikhleia
Public API: - (constructor) CslEngine(style, locale) -> CslEngine - CslEngine:cite(entries) -> string - CslEngine:reference(entries) -> string
The expected internal representation of a CSL entry is similar to CSL-JSON but with some differences:
Date fields are structured tables (not an array of numbers as in CSL-JSON). citation-number (mandatory) is supposed to have been added by the citation processor. locator (optional, also possibly added by the citation processor) is a table with label and value fields. names are parsed, as personal names (ex.
{ given = "George", family = "Smith" ... }
), or are literal strings (ex.{ literal = "T.C.B.S" }
).Important: while some consistency checks are performed, this engine is not intended to handle errors in the locale, style or input data. It is assumed that they are all valid.
THINGS NOT DONE - disambiguation logic (not done at all) - collapse logic in citations (not done at all) - other FIXME in the code on quite specific features
luacheck: no unused args
Functions
CslEngine:_init(style, locale, extras) | (Constructor) Create a new CSL engine. |
CslEngine:cite(entry) | Generate a citation string. |
CslEngine:reference(entry) | Generate a reference string. |
Functions
- CslEngine:_init(style, locale, extras)
-
(Constructor) Create a new CSL engine.
The optional extras table is for features not part of CSL 1.0.2.
Currently:
localizedPunctuation: boolean (default false) - use localized punctuation
Parameters:
- style CslStyle CSL style
- locale CslLocale CSL locale
- extras table Additional data to pass to the engine
Returns:
-
CslEngine
- CslEngine:cite(entry)
-
Generate a citation string.
Parameters:
- entry table List of CSL entries
Returns:
-
string
The XML citation string
- CslEngine:reference(entry)
-
Generate a reference string.
Parameters:
- entry table List of CSL entries
Returns:
-
string
The XML reference string