LFM — The remark-citations Plugin and Its Spec
Hex-code footnote identifiers become sequentially-numbered citations at render time, so a citation can keep its stable ID while still displaying as [1], [2], [3] in reading order.
Changelog - 2026-04-22 (#1)
LFM: remark-citations plugin and spec
Overview
Added remark-citations — a remark plugin that transforms hex-code (or numeric/mixed) footnote identifiers into sequentially-numbered citations with structured metadata parsing. Bundled into the @lossless-group/lfm preset as part of the standard pipeline.
Changes by Area
1. New Plugin: packages/lfm/src/plugins/remark-citations.ts
Runs after remark-gfm (which creates footnoteReference and footnoteDefinition MDAST nodes). The plugin:
Walks the tree depth-first, collecting footnote references in document order
Assigns sequential indices (1, 2, 3...) by order of first appearance
Parses structured definitions:
[Title](URL), source domain,Published:/Updated:dates, year prefixesEnriches
footnoteReferencenodes withdata.citationIndexanddata.citationHexRemoves
footnoteDefinitionnodes from the tree (rendered separately via consumer's Sources component)Attaches
tree.data.citationswith ordered citation array and validation warningsSupports
source-refattributes on directive nodes for image source attributionValidates orphan references and unused definitions (build-time warnings)
2. LFM Preset Integration: packages/lfm/src/preset.ts
Added
remarkCitationsto the plugin chain, afterremarkCalloutsNew
citations: booleanoption inRemarkLfmOptions(default:true)
3. Exports: packages/lfm/src/index.ts
Exports
remarkCitationsplugin and types:Citation,CitationsData,CitationWarning,RemarkCitationsOptions
4. Build Config: packages/lfm/tsup.config.ts
Added
plugins/remark-citationsentry point
5. New Spec: context-v/specs/Remark-Citations-Plugin-for-Hex-Code-Footnote-Management.md
Full specification covering the problem, architecture, identifier modes, structured definition parsing, image directive integration, configuration, MDAST output contract, and test cases.
6. Updated Spec: context-v/specs/Codifying-a-Comprehensive-Extended-Markdown-Flavor-and-Shared-Package.md
Updated the main LFM spec to reference the citations plugin.
Files Changed Summary
New
packages/lfm/src/plugins/remark-citations.ts— Citation processing plugincontext-v/specs/Remark-Citations-Plugin-for-Hex-Code-Footnote-Management.md— Plugin specification
Modified
packages/lfm/src/index.ts— Added citations exportspackages/lfm/src/preset.ts— Wired citations into remarkLfm pipelinepackages/lfm/src/types/index.ts— Addedcitationsoption to RemarkLfmOptionspackages/lfm/tsup.config.ts— Added citations build entrycontext-v/specs/Codifying-a-Comprehensive-Extended-Markdown-Flavor-and-Shared-Package.md— Updated LFM specpnpm-lock.yaml— Lockfile update for workspace resolution
