Skip to main content

Module bibliography

Module bibliography 

Source
Expand description

Lower #bibliography(...) directives into a semantic node.

This is the source boundary only (manifest Β§4, MVP 4): the directive declares one bibliography database path, which is resolved relative to the current .mos source file and stashed on a [NodeKind::Bibliography] node. After lowering, citation keys are checked against the parsed BibTeX records from those declared sources. Rendering citation markers and bibliography entries is still a later slice.

Diagnostics:

  • MOS0040: #bibliography(...) called without a (non-empty) path.
  • MOS0042: #bibliography(...) declared more than one path; first wins.
  • MOS0020: the path argument is present but not a string.
  • MOS0015: an unknown keyword argument was supplied.
  • MOS0041: the resolved path does not point to a file on disk (a warning; the node is still emitted with its resolved path).
  • MOS0045: a citation key does not exist in a complete parsed bibliography set.
  • MOS0046: a citation key appears in more than one declared bibliography source.

StructsΒ§

BibliographyOrigin πŸ”’
LoadedBibliography πŸ”’

FunctionsΒ§

bibliography_path πŸ”’
Pull the single source path out of the directive arguments. A leading positional string (#bibliography("refs.bib")) or the named path:/src: forms are accepted, mirroring #image(...). Returns None (after emitting a diagnostic) when the path is missing, empty, or not a string.
citation_key_span πŸ”’
edit_distance πŸ”’
is_citation_key πŸ”’
load_bibliography πŸ”’
lower_bibliography_directive πŸ”’
Lower a top-level #bibliography("refs.bib") directive into a single [NodeKind::Bibliography] node hanging off the document root. The literal path is recorded under src; the path resolved against the source file’s directory is recorded under resolved_path so the later BibTeX reader can open the database without re-deriving the location.
nearest_citation_key πŸ”’
resolve_citations πŸ”’
Load every declared bibliography source, mark citation nodes whose keys exist in any parsed record set, and rewrite their visible text to a numeric label assigned by first-use order. Unknown citation keys emit MOS0045 once per citation node and keep their [?key?] placeholder.