From 7905e0a763d18791c181c6951c98b1e090755617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Fri, 5 Dec 2025 23:24:32 +0100 Subject: [PATCH 1/8] feat: expose Typst path in Lua API --- src/command/render/filters.ts | 2 ++ src/resources/lua-types/quarto/paths.lua | 8 ++++++++ src/resources/pandoc/datadir/init.lua | 3 +++ 3 files changed, 13 insertions(+) diff --git a/src/command/render/filters.ts b/src/command/render/filters.ts index fdb4281d4f2..13edc229530 100644 --- a/src/command/render/filters.ts +++ b/src/command/render/filters.ts @@ -95,6 +95,7 @@ import { pythonExec } from "../../core/jupyter/exec.ts"; import { kTocIndent } from "../../config/constants.ts"; import { isWindows } from "../../deno_ral/platform.ts"; import { tinyTexBinDir } from "../../tools/impl/tinytex-info.ts"; +import { typstBinaryPath } from "../../core/typst.ts"; const kQuartoParams = "quarto-params"; @@ -204,6 +205,7 @@ async function quartoEnvironmentParams(_options: PandocOptions) { "paths": { "Rscript": await rBinaryPath("Rscript"), "TinyTexBinDir": tinyTexBinDir(), // will be undefined if no tinytex found and quarto will look in PATH + "Typst": typstBinaryPath(), }, }; } diff --git a/src/resources/lua-types/quarto/paths.lua b/src/resources/lua-types/quarto/paths.lua index fdb86c1d115..3c0bfb38c7e 100644 --- a/src/resources/lua-types/quarto/paths.lua +++ b/src/resources/lua-types/quarto/paths.lua @@ -13,3 +13,11 @@ Returns the path to the `TinyTeX` bin directory that `quarto install tinytex` in ]] ---@return string|nil # Path to `TinyTeX` bin directory function quarto.paths.tinytex_bin_dir() end + +--[[ +Returns the path to the Typst binary that Quarto itself would use for rendering Typst documents. +This will be the value of the QUARTO_TYPST environment variable if set, or the path to the +Typst binary bundled with Quarto. +]] +---@return string # Path to Typst binary +function quarto.paths.typst() end diff --git a/src/resources/pandoc/datadir/init.lua b/src/resources/pandoc/datadir/init.lua index d9639b02e1c..dd052fa1a76 100644 --- a/src/resources/pandoc/datadir/init.lua +++ b/src/resources/pandoc/datadir/init.lua @@ -990,6 +990,9 @@ quarto = { tinytex_bin_dir = function() return param('quarto-environment', nil).paths.TinyTexBinDir end, + typst = function() + return param('quarto-environment', nil).paths.Typst + end, }, json = json, base64 = base64, From 9a3b73e001cd2353c694ee8ae3d1a6e4c90018a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Fri, 5 Dec 2025 23:24:47 +0100 Subject: [PATCH 2/8] test: add unit test for Typst path API --- tests/docs/smoke-all/2025/12/05/typst-path-api.lua | 7 +++++++ tests/docs/smoke-all/2025/12/05/typst-path-api.qmd | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 tests/docs/smoke-all/2025/12/05/typst-path-api.lua create mode 100644 tests/docs/smoke-all/2025/12/05/typst-path-api.qmd diff --git a/tests/docs/smoke-all/2025/12/05/typst-path-api.lua b/tests/docs/smoke-all/2025/12/05/typst-path-api.lua new file mode 100644 index 00000000000..d2b80b09c8a --- /dev/null +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.lua @@ -0,0 +1,7 @@ +function typst_path() + return quarto.paths.typst() +end + +return { + ["typst"] = typst_path +} diff --git a/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd new file mode 100644 index 00000000000..2ab06c60034 --- /dev/null +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd @@ -0,0 +1,12 @@ +--- +format: html +shortcodes: + - typst-path-api.lua +_quarto: + tests: + html: + ensureFileRegexMatches: + - ["

The Typst path is .+.

"] +--- + +The Typst path is "{{< typst >}}". From 2e807ee8a9c766500cf3a800146880961784300a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Fri, 5 Dec 2025 23:25:00 +0100 Subject: [PATCH 3/8] chore: update changelog --- news/changelog-1.9.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 4027d871323..8d3b0bededb 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -68,6 +68,10 @@ All changes included in 1.9: - ([#13414](https://github.com/quarto-dev/quarto-cli/issues/13414)): Be more forgiving when Confluence server returns malformed JSON response. (author: @m1no) +## Lua Filters and extensions + +- Add `quarto.paths.typst()` to Quarto's Lua API to resolve Typst binary path in Lua filters and extensions consistently with Quarto itself. + ## Other fixes and improvements - ([#13402](https://github.com/quarto-dev/quarto-cli/issues/13402)): `nfpm` () is now used to create the `.deb` package, and new `.rpm` package. Both Linux packages are also now built for `x86_64` (`amd64`) and `aarch64` (`arm64`) architectures. From ea3e91713d14ca6c28472a52af40e55db9f746a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Fri, 5 Dec 2025 23:29:07 +0100 Subject: [PATCH 4/8] chore: change section name in changelog --- news/changelog-1.9.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 8d3b0bededb..09280476b4d 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -68,9 +68,9 @@ All changes included in 1.9: - ([#13414](https://github.com/quarto-dev/quarto-cli/issues/13414)): Be more forgiving when Confluence server returns malformed JSON response. (author: @m1no) -## Lua Filters and extensions +## Quarto Lua API -- Add `quarto.paths.typst()` to Quarto's Lua API to resolve Typst binary path in Lua filters and extensions consistently with Quarto itself. +- Add `quarto.paths.typst()` to Quarto's Lua API to resolve Typst binary path in Lua filters and extensions consistently with Quarto itself. (author: @mcanouil) ## Other fixes and improvements From 35bb7c4cda1637b82969b8cd2dcc2a9286b96f8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Fri, 5 Dec 2025 23:31:46 +0100 Subject: [PATCH 5/8] chore: add PR URL to changelog entry --- news/changelog-1.9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 09280476b4d..04e90d9c6b7 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -70,7 +70,7 @@ All changes included in 1.9: ## Quarto Lua API -- Add `quarto.paths.typst()` to Quarto's Lua API to resolve Typst binary path in Lua filters and extensions consistently with Quarto itself. (author: @mcanouil) +- ([#13762](https://github.com/quarto-dev/quarto-cli/issues/13762)): Add `quarto.paths.typst()` to Quarto's Lua API to resolve Typst binary path in Lua filters and extensions consistently with Quarto itself. (author: @mcanouil) ## Other fixes and improvements From 06bf0b44bd03758cea584b3c6f783a74d5d8d416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sat, 6 Dec 2025 11:23:15 +0100 Subject: [PATCH 6/8] chore: drop Quarto from section header --- news/changelog-1.9.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 04e90d9c6b7..0ed821dd48a 100644 --- a/news/changelog-1.9.md +++ b/news/changelog-1.9.md @@ -68,7 +68,7 @@ All changes included in 1.9: - ([#13414](https://github.com/quarto-dev/quarto-cli/issues/13414)): Be more forgiving when Confluence server returns malformed JSON response. (author: @m1no) -## Quarto Lua API +## Lua API - ([#13762](https://github.com/quarto-dev/quarto-cli/issues/13762)): Add `quarto.paths.typst()` to Quarto's Lua API to resolve Typst binary path in Lua filters and extensions consistently with Quarto itself. (author: @mcanouil) From 7bb781d2e52c5653944721b1e647c53c74ba0575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Sat, 6 Dec 2025 11:30:05 +0100 Subject: [PATCH 7/8] test: make regexpta bit more specific --- tests/docs/smoke-all/2025/12/05/typst-path-api.qmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd index 2ab06c60034..8303b948c09 100644 --- a/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd @@ -6,7 +6,7 @@ _quarto: tests: html: ensureFileRegexMatches: - - ["

The Typst path is .+.

"] + - ["

The Typst path is .+typst.

"] --- -The Typst path is "{{< typst >}}". +The Typst path is `{{< typst >}}`. From fb2dd27174f08ac39297dceac86af462c9d20154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20Canouil?= <8896044+mcanouil@users.noreply.github.com> Date: Mon, 8 Dec 2025 10:26:13 +0100 Subject: [PATCH 8/8] test: use filters instead of shortcodes --- tests/docs/smoke-all/2025/12/05/typst-path-api.lua | 10 ++++------ tests/docs/smoke-all/2025/12/05/typst-path-api.qmd | 9 ++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/docs/smoke-all/2025/12/05/typst-path-api.lua b/tests/docs/smoke-all/2025/12/05/typst-path-api.lua index d2b80b09c8a..6f46712e54b 100644 --- a/tests/docs/smoke-all/2025/12/05/typst-path-api.lua +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.lua @@ -1,7 +1,5 @@ -function typst_path() - return quarto.paths.typst() +function Pandoc(doc) + if quarto.paths.typst() == nil then + crash() + end end - -return { - ["typst"] = typst_path -} diff --git a/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd index 8303b948c09..8e91ad0578a 100644 --- a/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd @@ -1,12 +1,7 @@ --- format: html -shortcodes: +filters: - typst-path-api.lua -_quarto: - tests: - html: - ensureFileRegexMatches: - - ["

The Typst path is .+typst.

"] --- -The Typst path is `{{< typst >}}`. +The Typst path is accessible.