Skip to content

Add citations: bibliography terms as cite targets, author-year and numeric styles - #79

Closed
jackhogan wants to merge 1 commit into
equation_numberingfrom
citations
Closed

jackhogan wants to merge 1 commit into
equation_numberingfrom
citations

Conversation

@jackhogan

Copy link
Copy Markdown

Stacked on #78. A definition list inside a ::: {.references} container is a bibliography, and references to its terms are citations with their own rendering rules. The parser is unchanged: the references class on the container is the marker, and it joins math and footnotes as a reserved class word.

What changes

  • cite joins block, caption and text as a target kind. An id-bearing dt inside div.references registers as cite (doc_anchors and the HTML exporter both see the container).
  • [@dai2015] renders parenthetically, "(Dai and Le, 2015)"; prefix text goes inside, "(see Dai and Le, 2015)". [@dai2015]{ref=text} renders textually, "Dai and Le (2015)", splitting the label at its last ", " (a label with no comma renders as written). [-@dai2015] renders the label alone, for an author who writes the parentheses. A group [@a; @b] shares one pair of parentheses with "; " between entries. page, leaf and rel are errors on a citation.
  • cite='numeric' on mdhtml2html, md2gfm and mdhtml2typst numbers the entries in list order and renders "[1]", "[1, 3]", "Dai and Le [1]", relabelling each term with its number. Only terms with ids take a number, in every exporter.
  • The HTML exporter wraps every citation in <span class="cite"> with its links inside, so a viewer can attach a hover card from the entry each link targets. Typst escapes the numeric brackets; GFM bakes plain text.
  • Resolver gains set_cite_style, set_citenum, is_cite, cite_wrap and cite_sep, exposed to Python.
  • docs/DIALECT.md gains a "Citations" subsection under captions and cross-references; the README's reference sections mention the construct and the cite option.

Tests: test_citations in tests/test_export.py covers the three forms, groups, prefix text, a label with no comma, the numeric style in all three exporters, and the error cases.

🤖 Generated with Claude Code

…numeric styles

A definition list inside a `::: {.references}` container is a bibliography. Its id-bearing terms register as `cite` targets instead of `text`. `[@key]` renders parenthetically, "(Dai and Le, 2015)"; `{ref=text}` textually, "Dai and Le (2015)"; `-@` as the bare label. A group of citations shares one pair of parentheses with "; " between entries. `page`, `leaf` and `rel` are errors on a citation.

`cite='numeric'` on mdhtml2html, md2gfm and mdhtml2typst numbers the entries in list order, renders "[1]", "[1, 3]" and "Dai and Le [1]", and relabels each term with its number. The HTML exporter wraps every citation in `span.cite` so a page can attach a hover card from the entry its link targets.

`references` joins `math` and `footnotes` as a reserved class word. docs/DIALECT.md gains a citations section; the parser is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@jackhogan jackhogan closed this Oct 28, 2026
@jackhogan
jackhogan deleted the citations branch October 28, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant