diff --git a/src/resources/formats/typst/pandoc/quarto/typst-template.typ b/src/resources/formats/typst/pandoc/quarto/typst-template.typ index 219ac27a8d4..cf1f8dd669c 100644 --- a/src/resources/formats/typst/pandoc/quarto/typst-template.typ +++ b/src/resources/formats/typst/pandoc/quarto/typst-template.typ @@ -128,7 +128,7 @@ } block(above: 0em, below: 2em)[ #outline( - title: toc_title, + title: title, depth: toc_depth, indent: toc_indent ); diff --git a/tests/docs/smoke-all/typst/toc/strip-toc-title.lua b/tests/docs/smoke-all/typst/toc/strip-toc-title.lua new file mode 100644 index 00000000000..f86da508541 --- /dev/null +++ b/tests/docs/smoke-all/typst/toc/strip-toc-title.lua @@ -0,0 +1,6 @@ +-- Removes the toc-title metadata that Quarto adds before Pandoc runs, +-- causing article() to use its `toc_title: none` default. +function Meta(meta) + meta["toc-title"] = nil + return meta +end diff --git a/tests/docs/smoke-all/typst/toc/toc-title-auto-fallback.qmd b/tests/docs/smoke-all/typst/toc/toc-title-auto-fallback.qmd new file mode 100644 index 00000000000..5d2c6c6becf --- /dev/null +++ b/tests/docs/smoke-all/typst/toc/toc-title-auto-fallback.qmd @@ -0,0 +1,30 @@ +--- +title: "TOC title auto fallback" +lang: en +toc: true +format: + typst: + keep-typ: true + filters: + - strip-toc-title.lua +_quarto: + tests: + typst: + ensureTypstFileRegexMatches: + - # Patterns that MUST be found + # The outline is emitted, so the `if toc` branch of article() ran + - '#outline\(' + - # Patterns that must NOT be found + # No toc_title argument in the article() call: the filter removed the + # metadata, so article() falls back to its own `toc_title: none` default + - 'toc_title: \[' + ensurePdfRegexMatches: + - # Typst's `auto` outline title for lang: en + - 'Contents' +--- + +Quarto fills `toc-title` with a localized default before Pandoc runs, so the +Typst `article()` function normally receives a `toc_title` argument. This test +uses a Lua `Meta` filter to remove the key and reach the function's own +`toc_title: none` default. In that case, `outline(title: auto)` provides the +table of contents heading.