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 (
Itemwith theItemTypeand variable vocabularies) mirroring the CSL-JSON shape a style formats; - an infallible BibTeX → CSL mapping (
item_from_bib_entry,library_from_bibliography) frommos-bibrecords; and - a CSL XML style parser (
parse_style) producing a typedStyleAST (<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 CSLItems. - 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
StyleAST. - 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 aChoose. - 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>. - CslParse
Error - A recoverable CSL parse error: a
CslParseErrorKindplus 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-formliteral.circamarks an approximate date. - Date
Element <date>: renders a date variable, localized or with explicit parts.- Date
Part - A
<date-part>child of<date>. - Date
Parts - 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).
- Name
Element - 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§
- CslParse
Error Kind - What went wrong while parsing a CSL style. Paired with a byte offset inside
a
CslParseError. - Date
Variable - CSL date variables (specification Appendix IV).
- Element
- A CSL rendering element.
- Item
Type - CSL item types (specification Appendix III).
- Match
- The
matchattribute on a condition set. - Name
Variable - CSL name variables (specification Appendix IV).
- Number
Variable - CSL number variables (specification Appendix IV).
- Sort
Target - What a
SortKeysorts on. - Standard
Variable - CSL string (“standard”) variables (specification Appendix IV).
- Style
Class - The
classof a CSL style. - Text
Source - What a
Textelement 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
inputas a CSL 1.0.2 style.