remark-citations plugin — hex-code footnote renumbering and structured definition parsing
New Plugin: remark-citations
Added remark-citations to the LFM pipeline. Transforms footnote identifiers (hex codes, numeric, or mixed) into sequentially-numbered citations with structured metadata parsing.
What It Does
Walks the MDAST depth-first, collecting
footnoteReferencenodes in document orderAssigns sequential indices (1, 2, 3...) by order of first appearance — not by identifier value
Parses structured definitions:
[Title](URL), source domain,Published:/Updated:dates, year prefixesEnriches
footnoteReferencenodes withdata.citationIndexanddata.citationHexRemoves
footnoteDefinitionnodes from the tree (consumers render viatree.data.citations)Attaches
tree.data.citationswithmap,orderedarray, andwarningsValidates orphan references and unused definitions at build time
Supports
source-refattributes on directive nodes for image source attribution
Identifier Modes
hex — Authors use hex codes (
[^a1b2c3]), plugin renumbers to[1],[2], etc.numeric — Authors use numbers (
[^1]), plugin auto-assigns hex codes for stabilitymixed (default) — Both styles accepted without warnings
Pipeline Position
Runs after remark-gfm (which creates footnote nodes) and after remark-callouts. Enabled by default via remarkLfm({ citations: true }).
Exports
remarkCitations— the plugin functionCitation,CitationsData,CitationWarning,RemarkCitationsOptions— TypeScript types
Files
New
src/plugins/remark-citations.ts— Plugin implementation
Modified
src/index.ts— Added citations exportssrc/preset.ts— Wired citations into remarkLfm pipelinesrc/types/index.ts— Addedcitationsoption toRemarkLfmOptionstsup.config.ts— Addedplugins/remark-citationsbuild entry