Skip to content

fix(typst-book): localize orange-book running header when lang is set#14525

Open
cderv wants to merge 13 commits into
mainfrom
fix/orange-book-typst-running-header-lang
Open

fix(typst-book): localize orange-book running header when lang is set#14525
cderv wants to merge 13 commits into
mainfrom
fix/orange-book-typst-running-header-lang

Conversation

@cderv
Copy link
Copy Markdown
Member

@cderv cderv commented May 18, 2026

When rendering a Typst book with lang: set to a non-English locale, the orange-book running header keeps the English Chapter N. prefix instead of the locale's word (e.g. Chapitre N. for lang: fr).

Root cause

The orange-book book(...) exposes a supplement-chapter parameter (default "Chapter") consumed by a show heading.where(level: 1): set heading(supplement: ...) rule that drives the running header. The Quarto-side typst-show.typ never passed this parameter to book.with(...), so the English default applied regardless of lang:. The same gap silently broke the existing list-of-figure-title / list-of-table-title pipes — they rendered as empty strings.

The localized values live in format.language["crossref-ch-prefix"] (loaded from _language-<lang>.yml). Until #14530, no general channel exposed format.language to Pandoc templates without leaking keys into rendered output via +yaml_metadata_block.

Fix

Consumes the $quarto.language.*$ Pandoc template-variable namespace introduced in #14530. The orange-book typst-show.typ migrates all three pipes (supplement-chapter, list-of-figure-title, list-of-table-title) to the new namespaced form via quarto-ext/orange-book#4, pulled in via quarto dev-call pull-git-subtree orange-book. The extension version is bumped to 0.2.0.

The interim Lua surfaceParamToMeta mechanism (which copied the three keys into Pandoc meta and triggered a YAML-leakage regression on tests/docs/smoke-all/2024/01/22/8389.md.snapshot) is removed.

User-override path via the crossref: block ($crossref.lof-title$ / $crossref.lot-title$) is preserved as the first cascade branch in the orange-book template.

list-of-figure-title and list-of-table-title use nested $if(...)$ guards so on pre-#14530 Quarto the argument is omitted entirely and book()'s built-in defaults apply. supplement-chapter gates on $if(quarto.language.crossref-ch-prefix)$...$endif$ so older Quarto versions fall through to book()'s "Chapter" literal default.

Related upstream observation

While auditing the migration, the orange-book book() implementation (@preview/orange-book:0.7.1 lib.typ:606-608) was found to call my-outline-sec(...) unconditionally — so lof: false / lot: false suppresses only the title arg, not the outline section itself. Pre-existing behavior, out of scope here. Tracked at quarto-ext/orange-book#5.

Documentation

llm-docs/localization-architecture.md (delivered with #14530) is updated in this branch: the in-flight forward-reference at the orange-book paragraph is replaced with the shipped channel-2d form, and frontmatter main_commit / analyzed_date are refreshed per .claude/rules/llm-docs-maintenance.md.

The subtree workflow guards introduced earlier in this branch (.claude/rules/extension-subtrees.md, dev-docs/subtree-extensions.md additions) remain.

Important

This branch contains subtree-pull commits and cannot be rebased — merge to main without rebasing. A merge commit from upstream/main is included on the branch to make the dependency on #14530 explicit.

Fixes #14524

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR

@posit-snyk-bot
Copy link
Copy Markdown
Collaborator

posit-snyk-bot commented May 18, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@gordonwoodhull
Copy link
Copy Markdown
Member

This is the right fix! But currently it needs to be made on:

https://github.com/quarto-ext/orange-book

Then once it’s on main on that repo, run

quarto dev-call pull-git-subtree orange-book

to update the subtree.

Modifying it directly will “work”, but only until the next time that repo is updated. (And won’t help anyone who might have forked that repo for their own changes.)

It’s debatable whether that repo needs to be a subtree extension instead of fully built-in. My rationale is that it is somewhat independent of Quarto; could get forked; we could switch to another fork or another extension. Glad to discuss.

https://github.com/quarto-dev/quarto-cli/blob/main/dev-docs/subtree-extensions.md

For that matter it’s also possible to push your changes back to the repo with git subtree push but I haven’t tried that.

@cderv
Copy link
Copy Markdown
Member Author

cderv commented May 18, 2026

How did I forgot !! 🤦 We discussed it. Sorry for this and thanks for the reminder.

@gordonwoodhull
Copy link
Copy Markdown
Member

gordonwoodhull commented May 18, 2026

You’ll also find that you can’t rebase the subtree & will get weird path errors if you try. So you’ll need to merge the branch without rebasing.

(The complexity has to go somewhere I guess. Subtrees are still less confusing than submodules IMO.)

cderv added 6 commits May 19, 2026 13:03
Surfaces crossref-ch-prefix, crossref-lof-title, and crossref-lot-title
from format.language into Pandoc YAML metadata so they resolve in the
orange-book typst-show.typ template. Adds a small surfaceParamToMeta
helper in common/meta.lua for reuse by future channel-2b localized
template vars.

The supplement-chapter parameter on book.with(...) drives the running
header via a show heading rule; without the meta surfacing it defaulted
to the English literal "Chapter" regardless of lang. The existing
list-of-figure-title and list-of-table-title pipes in the same template
were affected by the same gap and silently rendered as empty strings.

Fixes #14524
Maps the full lang: → rendered output pipeline across HTML, LaTeX/PDF,
and Typst. Documents the three downstream surfaces from format.language
(Lua filter params, explicit format.metadata copies in pandoc.ts, direct
TS reads in HTML extras) and the design split between crossref: block
(per-document overrides) and language: block (translations) per the
crossref schema.
Adds a path-scoped .claude/rules/ guard so files under
src/resources/extension-subtrees/ surface a "do not edit directly"
warning when touched. Fleshes out dev-docs/subtree-extensions.md
with explicit "Updating an extension" and "Recovery" sections
covering the rare in-tree-edit case.
… 9f786e1b4..b11e50490

b11e50490 Merge pull request #3 from quarto-ext/fix/localize-running-header
77a306cb0 Forward crossref-ch-prefix to book() for localized running header

git-subtree-dir: src/resources/extension-subtrees/orange-book
git-subtree-split: b11e50490d1b802c919e85bf94e1fb9d20977611
@cderv cderv force-pushed the fix/orange-book-typst-running-header-lang branch from 439af28 to add83ea Compare May 19, 2026 11:11
@cderv
Copy link
Copy Markdown
Member Author

cderv commented May 19, 2026

git subtree push was not adapted here. It was inspected al 20000+ commits to split before pushing the one change.

So now I understand how it works, and it is a nice way to externalize some work, and have monorepo + external repo.

Anyway, I did quarto-ext/orange-book#3 and then rebase the branch to edit change before calling dev-call command.

It should be good.

@cderv
Copy link
Copy Markdown
Member Author

cderv commented May 19, 2026

I don't like the way those language var are exposed. So I think want to make a deeper feature fix by leveraging newest --variable-json for language keys. I'll look into this.

@cderv cderv marked this pull request as draft May 19, 2026 12:59
# Conflicts:
#	llm-docs/localization-architecture.md
cderv added 5 commits May 21, 2026 17:26
… b11e50490..2b59b7672

2b59b7672 Migrate localized pipes to $quarto.language.* namespace (#4)
a094c0b69 Migrate localized pipes to $quarto.language.* namespace

git-subtree-dir: src/resources/extension-subtrees/orange-book
git-subtree-split: 2b59b76727f22bdcc3522ee56e2437f6abd81c36
The orange-book typst-show.typ template now consumes the localized
crossref strings via the $quarto.language.* Pandoc template-variable
namespace introduced upstream in #14530. The Lua-side surfaceParamToMeta
helper and the crossref/meta.lua key list it powered are no longer
needed and re-introduce YAML-header leakage for writers with
+yaml_metadata_block.

See llm-docs/localization-architecture.md (channel 2d) for the canonical
bulk channel.
References the new quarto-ext/orange-book PR #4 (supersedes #3) and the
quarto-cli #14530 mechanism the migration depends on.
…tion

Replaces the forward-reference to in-flight #14524 with the shipped form.
Refreshes main_commit / analyzed_date frontmatter per
.claude/rules/llm-docs-maintenance.md.
@cderv cderv marked this pull request as ready for review May 21, 2026 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Typst book running header not localized when lang: is set to a non-English locale

3 participants