citeformer.render.csl¶
Deterministic bibliography rendering via home-grown formatters.
Given a source list + the citation list emitted by generation, we produce
one Reference per unique cited source_id using a CitationFormatter
from citeformer.render.formatters. Fabricated citations (out of range)
are silently dropped — verify() surfaces them via the coverage check.
We stopped consuming citeproc-py in the home-grown rewrite (see
docs/decisions/004-citeproc-rewrite.md) because of accumulated quirks
(Chicago page-range crash, APA double-period, noisy CSL-JSON warnings)
and because Vancouver has no canonical bundled style in the upstream
CSL repo. The six built-in formatters cover the target styles with no
runtime citeproc-py dependency; users wanting arbitrary CSL files can
install citeproc-py directly and wrap it themselves.
GenerationResult.text continues to carry the model-emitted [N]
markers verbatim (see docs/decisions/002-inline-markers-stay-numeric.md).
Only Reference.inline_marker is rendered in the style’s native form.
Module Contents¶
Functions¶
Render a deterministic bibliography for the cited sources. |
|
Render a |
API¶
- citeformer.render.csl.render_references(sources: list[citeformer.core.Source], citations: list[citeformer.core.Citation], style_name: str) list[citeformer.core.Reference]¶
Render a deterministic bibliography for the cited sources.
Args: sources: All sources in scope (1-indexed positions). citations: Citations parsed from generated text. style_name: Bundled style (
"apa-7","ieee", …). Aliases ("apa","mla","chicago") also work.Returns: One
Referenceper unique in-range citedsource_id, in ascending id order. Each has the style’s native inline marker and the full bibliography entry.Raises: ValueError: If
style_nameisn’t a known built-in formatter.
- citeformer.render.csl.render_single_reference(source: citeformer.core.Source, *, style_name: str, number: int = 1) citeformer.core.Reference¶
Render a
Referencefor a singleSourcewithout a fullCitationlist.Handy for previewing what a source will look like before you feed it to the model — e.g. in docs, example notebooks, or user interfaces.
Args: source: The source to format. style_name: Bundled style or alias. number: Bibliography position to use for numeric styles; ignored by author-date styles.
Returns: A
Referencewith the style’s inline marker + full entry.