feat(csl): Citation Style Language support (IEEE, Vancouver, AMA, ACS, Nature, APSA, Chicago author-date)#154
Conversation
Adds a citeproc-backed CSL formatting engine so citations can be rendered in thousands of journal/discipline styles beyond the four built-ins, starting with a bundled set: IEEE, Vancouver, AMA, ACS, Nature, APSA, and Chicago (author-date). - src/lib/citation/csl/to-csl-json.ts: maps all 28 source types to CSL-JSON (the citeproc input format) - src/lib/citation/csl/engine.ts: renders a single citation to text + inline HTML, and in-text markers ([1] or author-date), via citeproc - src/lib/citation/csl/styles.ts: lazy style registry (each style and the engine are code-split via dynamic import, ~402KB loaded only when a CSL style is used — never in the main bundle) - bundled styles + en-US locale generated by scripts/fetch-csl-styles.mjs from the CSL project (CC BY-SA 3.0) - index.ts: formatCitationAny / generateInTextCitationAny route built-in styles to the sync formatters and CSL ids to the engine - 16 new tests (converter + real citeproc output for numbered and author-date styles) https://claude.ai/code/session_019tCTyU5MpR5qdcnjV8UHfu
Wires the CSL engine into the UI so users can pick IEEE, Vancouver, AMA, ACS, Nature, APSA, or Chicago author-date wherever they pick a style: - generator (cite page): new "Journal & discipline styles" group in the style picker; generation, in-text copy, BibTeX/bulk/lookup paths now format via the async CSL-aware path with error handling - list view: "reformat all to" and per-citation re-style support CSL - add-citation modal: CSL options in its style select; live preview formats asynchronously with a cancellation guard - broaden the persisted Citation.style to a string so CSL style ids round-trip; saved citations already store formatted text/html, so lists and shares render CSL output without loading the engine https://claude.ai/code/session_019tCTyU5MpR5qdcnjV8UHfu
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (23)
📝 WalkthroughWalkthroughThis PR adds Citation Style Language (CSL) formatting support to the citation system. It integrates citeproc-js, implements a conversion layer from internal CitationFields to CSL JSON, bundles multiple CSL discipline styles, and refactors the UI to support async formatting across both built-in and CSL styles. ChangesCSL Citation Formatting Support
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
scripts/fetch-csl-styles.mjsOops! Something went wrong! :( ESLint: 9.39.2 A configuration object specifies rule " Common causes of this problem include:
Comment |
Summary
Adds Citation Style Language (CSL) support so OpenCitation goes beyond its four built-in styles into real journal/discipline styles — the headline feature for the researcher/professional audience. Starter set: IEEE, Vancouver, AMA, ACS, Nature, APSA, Chicago (author-date).
Sample output (validated in tests):
Architecture
src/lib/citation/csl/to-csl-json.ts— maps all 28 source types to CSL-JSON (pure, tested).csl/engine.ts— citeproc wrapper producing text + clean inline HTML + in-text markers ([1]/ author-date).csl/styles.ts— lazy style registry. The engine and each style are code-split viaimport(), so citeproc lands in a ~402 KB chunk that loads only when a CSL style is used — never in the main/cite bundle.index.ts—formatCitationAny/generateInTextCitationAnyroute built-ins to the sync formatters and CSL ids to the engine.scripts/fetch-csl-styles.mjsfrom the CSL project (CC BY-SA 3.0).Wired into
/cite): new "Journal & discipline styles" group; generation, in-text copy, and BibTeX/bulk/lookup paths format via the async CSL-aware path with error handling.Citation.stylebroadened tostringso CSL ids round-trip; saved citations store formatted text/html, so lists and shares render CSL output without loading the engine.Verification
Known follow-ups (not in this PR)
https://claude.ai/code/session_019tCTyU5MpR5qdcnjV8UHfu
Generated by Claude Code
Summary by CodeRabbit
New Features
Documentation
Dependencies
citeproclibrary for enhanced citation formatting capabilities.