From 610a09e4be2c651f2b0f9d48bf4dafb68da5e48c Mon Sep 17 00:00:00 2001 From: Jack Hogan Date: Wed, 28 Oct 2026 17:17:23 +0000 Subject: [PATCH] Add citations: bibliography terms as `cite` targets, author-year and 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 --- README.md | 6 ++- docs/DIALECT.md | 35 ++++++++++++++++-- py/src/lib.rs | 30 +++++++++++++-- python/mdhtml/export.py | 6 ++- python/mdhtml/md.py | 34 +++++++++++++---- python/mdhtml/typst.py | 48 ++++++++++++++++++------ src/export_html.rs | 74 ++++++++++++++++++++++++++++++++----- src/resolve.rs | 81 ++++++++++++++++++++++++++++++++++------- tests/test_export.py | 55 ++++++++++++++++++++++++++++ 9 files changed, 317 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 3da948d..24e3a72 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The dialect deviates from CommonMark for three reasons: - Panels: `::: callout-note` (also `tip`, `important`, `warning`, `caution`) creates a callout. Add `collapse="true"` or `collapse="false"` for initially closed/open disclosure, or use `::: details` without a callout kind. The first heading is the panel title, not a document heading. These normalize to `div[data-panel]` with an optional `header` title and independent `data-callout` / `data-disclosure` properties. Ordinary divs stay ordinary. - Raw passthrough: a Pandoc-style raw attribute names the payload's format. Use exactly `{=name}` as a fenced code block's info string or immediately after inline code. Both forms render as an inert `