Skip to main content

Crate mos_csl

Crate mos_csl 

Source
Expand description

Citation Style Language (CSL) support for Mosaic (manifest §12).

This crate provides the data foundations for CSL 1.0.2; not a CSL processor. It ships:

  • a typed item data model (Item with the ItemType and variable vocabularies) mirroring the CSL-JSON shape a style formats;
  • an infallible BibTeX → CSL mapping (item_from_bib_entry, library_from_bibliography) from mos-bib records; and
  • a CSL XML style parser (parse_style) producing a typed Style AST (<style> / <info> / <citation> / <bibliography> / <macro> and the rendering elements).

Out of scope: the CSL processor itself: evaluating a style against items to render citations or bibliographies (formatting, sorting, disambiguation, name ordering, locales). This crate has no mos-eval / layout / PDF wiring.

Modules§

error 🔒
The local CSL style parse error type, CslParseError.
from_bibtex 🔒
Map parsed BibTeX records ([mos_bib::BibEntry]) into CSL Items.
item 🔒
The CSL item data model; the typed input data a CSL style formats.
parser 🔒
Parse a CSL 1.0.2 style document into the typed Style AST.
style 🔒
The typed CSL style AST produced by parse_style.

Structs§

Bibliography
The <bibliography> element: how bibliography entries are formatted.
Branch
One <if> / <else-if> branch of a Choose.
Choose
<choose>: conditional rendering.
Citation
The <citation> element: how cites are formatted.
Common
Common rendering attributes shared across most CSL elements (affixes, formatting, and delimiter). Unmodelled attributes are ignored by the parser.
Conditions
The conditions on an <if> / <else-if>.
CslParseError
A recoverable CSL parse error: a CslParseErrorKind plus the byte offset into the original input where the problem was detected.
Date
A CSL date-variable value: a single date, a range (start..end), or a free-form literal. circa marks an approximate date.
DateElement
<date>: renders a date variable, localized or with explicit parts.
DatePart
A <date-part> child of <date>.
DateParts
One date in a CSL Date; any subset of the parts may be present.
EtAl
The <et-al> child of <names>.
Group
<group>: a delimited, conditionally-suppressed run of elements.
Info
Style metadata (<info>). Only the commonly-needed fields are modelled.
Item
A single bibliographic item; the unit a CSL style formats.
Label
<label>: renders a term matching a variable.
Layout
A <layout>: an ordered list of rendering elements plus common attributes.
Name
A personal or institutional name (specification “Name” name-parts).
NameElement
The <name> child of <names> (a subset of its many options).
Names
<names>: renders one or more name variables.
Number
<number>: renders a number variable.
SortKey
One <key> in a <sort>.
Style
A parsed CSL style (the <style> root element).
Text
<text>: renders a variable, macro, term, or literal value.

Enums§

CslParseErrorKind
What went wrong while parsing a CSL style. Paired with a byte offset inside a CslParseError.
DateVariable
CSL date variables (specification Appendix IV).
Element
A CSL rendering element.
ItemType
CSL item types (specification Appendix III).
Match
The match attribute on a condition set.
NameVariable
CSL name variables (specification Appendix IV).
NumberVariable
CSL number variables (specification Appendix IV).
SortTarget
What a SortKey sorts on.
StandardVariable
CSL string (“standard”) variables (specification Appendix IV).
StyleClass
The class of a CSL style.
TextSource
What a Text element renders.

Functions§

item_from_bib_entry
Map one BibTeX entry to a CSL Item.
library_from_bibliography
Map a whole [Bibliography] to CSL items keyed by citation key.
parse_style
Parse input as a CSL 1.0.2 style.