Repository navigation
typst: report citations to inline-only references before Typst runs (bd-yjf99rzx) - #1166
Merged
Merged
Conversation
Typst renders that cite a key defined only in front-matter `references:` fail with Typst's raw label error, exactly as in Quarto 1. The plan keeps Quarto 1's behavior but stops before Typst with a new Q-21-5 error, warns with Q-21-6 when a bibliography file shadows an inline entry, and covers book renders. Unknown keys are split off to bd-74zz2qko. Includes the repro fixtures and probe scripts comparing q2 with Quarto 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…bd-yjf99rzx) Typst keeps Quarto 1's native-bibliography default, which reads only `bibliography:` files. A citation whose key exists only in front-matter `references:` therefore failed `typst compile` with a bare `label <key> does not exist` error, in Quarto 1 too. Keep that behavior, but check it before Typst runs: - Q-21-5 (error): a cited key is defined in `references:` and in no `bibliography:` file. It points at the citation and suggests `citeproc: true` or moving the entry into a .bib/.yml file. With a non-pdf `output-ext` Typst never runs, so it is a warning there. - Q-21-6 (warning): a cited key is also defined in a `bibliography:` file, so Typst silently ignores the inline entry. The check runs in PandocWriteStage::prepare(), shared by native and browser renders, and sees only citations that will reach Typst as `@key`, so it covers single documents, margin citations, and margin-mode books. Keys come from BibLaTeX (biblatex crate) and Hayagriva files; a file that cannot be read or parsed suppresses Q-21-5. `citeproc: true` turns the check off. Adds catalog entries, error pages, a Citations section in the Typst guide, and smoke-all fixtures for each case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…st-citations-inline-front
Contributor
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Typst output keeps Quarto 1's default of formatting citations with Typst's own bibliography, which reads only the files listed in
bibliography:. A citation whose key exists only in front-matterreferences:reached Typst as@keyand failedtypst compilewith a barelabel <key> does not exist in the document(Q-21-3). Quarto 1 fails the same way.Decision
We keep Quarto 1's behavior, so no automatic citeproc and no conversion of
references:for Typst. But when q2 knows Typst will fail, it stops first with a clear error. Documents that Quarto 1 renders still render.citeprocunsetreferences:references:and abibliography:file (Typst uses the file's entry)references:present but not cited; or cited keys all in.bibcitation-location: margin(single document or book) with an inline-only keyciteproc: trueFull investigation, including the q2 vs Quarto 1 probes:
claude-notes/plans/2026-11-07-typst-inline-references.md.Changes
crates/quarto-core/src/typst_citations.rs(new) is the check.Citenodes still in the final AST, i.e. the ones Typst will see as@key, and only at keys defined inreferences:..bibfiles (via thebiblatexcrate pampa already uses) and Hayagriva.ymlfiles.bibliography:file can't be read or parsed, Q-21-5 is suppressed, so q2 never refuses a file Typst might read.PandocWriteStage::prepare()runs the check for Typst. That one call covers native renders and browser (PandocPrepareStage) renders. Bibliography paths resolve with the same helper the PDF request uses.docs/errors/typst/, sidebar entries, and a "Citations" section in the Typst guide.Cargo.lockfiles gain one line:quarto-corenow depends onbiblatex 0.12.0, which was already in both lockfiles.For review
output-extother thanpdf, Typst never runs, so Q-21-5 is a warning there and the.typis still written. This wasn't in the plan; I decided it during implementation.citeproc: trueturns the check off entirely. In margin mode the vendored Lua margin handler then formats citations inside Pandoc, afterprepare(). I verified with akeep-typrender that no@keyremains.@keymatches a Typst label, e.g. a heading with that id, and the same key is defined only inreferences:. Typst would resolve that as a cross-reference. I judged it too unlikely to special-case.Tests
typst_citations.rs: each rule,citeproc: true, an unreadable file, source-only output,.biband Hayagriva key reading..bib, shadowed by Hayagriva.yml,citeproc: true, source-only;typst/inline-references-book-margin/).citeproc: truefixture still passes.Local verification
main, and 8,715 of 8,716 quarto-core and smoke-all tests after it, with pandoc 3.13 (CI's new pin).knitr::capture_tests::capture_classifies_pieces: this machine's R reportsrlang_errorwhere the test expectssimpleError. It passes in CI and onmain.cargo xtask verifysteps 1–4 and 6–14 pass, including the WASM hub-client build and tests. Lints, fmt and clippy are clean.q2 render docssucceeds: 421 of 421 pages, with no warnings from the new or edited pages.wasmtimecompiles C). The new code uses no platform-specific APIs; CI's Clippy (Windows) job covers it.Follow-up
bd-74zz2qko: report a cited key that is defined nowhere (a typo), which still fails with Typst's raw label error. It can reuse this key reading.🤖 Generated with Claude Code