citeformer.render.formatters

Home-grown CSL formatters.

Each concrete formatter is a CitationFormatter subclass that takes a CSL-JSON item (our Source.metadata) and a 1-indexed citation number and emits the inline marker + bibliography entry for its specific style. No citeproc-py involvement; quirks-free output owned by us.

Adding a new style is the skill at .claude/skills/add-citation-format/. The short version:

  1. Create src/citeformer/render/formatters/<name>.py with a subclass.

  2. Register it in _REGISTRY below (with any canonical aliases).

  3. Add fixtures to tests/unit/test_formatters.py covering at least the four canonical CSL types (book / article-journal / chapter / thesis).

Public API:

  • CitationFormatter — the base ABC.

  • Author — CSL-author record used across formatters.

  • get_formatter(name) — registry lookup.

  • available_formatters() — list of canonical style names.

Submodules

Package Contents

Functions

get_formatter

Look up and instantiate a formatter by style name.

available_formatters

Return the canonical list of built-in style identifiers (no aliases).

API

citeformer.render.formatters.get_formatter(name: str) citeformer.render.formatters._base.CitationFormatter

Look up and instantiate a formatter by style name.

Args: name: Style identifier (canonical or alias). Case-insensitive.

Returns: A fresh CitationFormatter instance. Formatters are stateless, so this is cheap to call per-generation.

Raises: ValueError: If name isn’t in the registry.

citeformer.render.formatters.available_formatters() list[str]

Return the canonical list of built-in style identifiers (no aliases).