fix(crossref): apply appendix-title to appendix cross-references#14617
fix(crossref): apply appendix-title to appendix cross-references#14617cderv wants to merge 2 commits into
Conversation
Documents the bug before the fix: in a PDF book, an appendix
cross-reference ignores `crossref.appendix-title` and falls back to the
default "Appendix" prefix, whereas HTML honors it. Only the
`language: crossref-apx-prefix` key currently drives the PDF prefix.
The test asserts the custom prefix ("Whatever") reaches the appendix
cross-reference in the merged book .tex. It is RED on current main and
turns green once the cross-reference path consults the crossref option.
Test block lives on index.qmd because the smoke-all harness only
resolves the merged book .tex when the test file is the book index.
) crossref.appendix-title and crossref.appendix-delim styled the appendix chapter heading (via formatChapterTitle) but the appendix cross-reference prefix was built solely from language.crossref-apx-prefix, so @sec-refs to an appendix rendered the default "Appendix N" regardless of appendix-title. mcanouil's language: crossref-apx-prefix workaround only papered over this. Two independent code paths build that prefix, both now prefer crossref.appendix-title (falling back to the language string), mirroring formatChapterTitle's precedence: - Lua refPrefix (crossref/format.lua): PDF, and HTML same-file references. - TS formatCrossref (book-crossrefs.ts): HTML cross-file references resolved at the book post-render stage. The HTML cross-file path can only be exercised after a full project render, so its smoke-all test uses render-project: true; the project pre-render only builds declared formats, so the fixture declares format: html. Documented this render-project behavior in the testing rules and llm-docs. The PDF/LaTeX appendix chapter heading itself (not the cross-reference) still ignores appendix-title/appendix-delim; that needs appendixname/KOMA work and is tracked separately in #14616.
✅ 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. |
|
Closing this — on re-reading the issue, it solves the wrong thing. Reviewing the code it does not seem right to use appendix-title as the prefix. The reported problem is the appendix chapter heading in PDF: HTML shows I'll reopen work focused on the PDF appendix heading itself. |
When a book sets
crossref.appendix-title, the appendix chapter heading uses it (e.g.Whatever A: Summaryin HTML), but cross-references to that appendix render the defaultAppendix Nprefix in PDF — the configured title is ignored. Thelanguage: crossref-apx-prefixworkaround from the issue only papers over the symptom and does nothing forappendix-delim.Root Cause
The appendix cross-reference prefix is built from
language.crossref-apx-prefixalone, nevercrossref.appendix-title. Two independent code paths build it:refPrefix(src/resources/filters/crossref/format.lua) — PDF, and HTML same-file references.formatCrossref(src/project/types/book/book-crossrefs.ts) — HTML cross-file references resolved at the book post-render stage.Fix
Both paths now prefer
crossref.appendix-titlewhen set, falling back to the language string — mirroring the precedenceformatChapterTitlealready uses for the appendix heading. Behavior is unchanged whenappendix-titleis unset.The HTML cross-file path only resolves after a full project render, so its smoke-all test uses
render-project: true. The project pre-render builds only declared formats, so the fixture declaresformat: html; thisrender-projectbehavior is now documented in the testing rules andllm-docs.The PDF/LaTeX appendix chapter heading itself (as opposed to cross-references) still ignores
appendix-title/appendix-delim; matching the HTMLWhatever A: Summaryheading in LaTeX needs\appendixname/KOMA work and is tracked separately in #14616.Test Plan
@sec-reference to an appendix showsSee Whatever A, notSee Appendix Aappendix-titleunset: appendix cross-references unchanged (defaultAppendix N)Fixes #11772