diff --git a/news/changelog-1.9.md b/news/changelog-1.9.md index 4027d87132..0ed821dd48 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 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) + ## 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. diff --git a/src/command/render/filters.ts b/src/command/render/filters.ts index fdb4281d4f..13edc22953 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 fdb86c1d11..3c0bfb38c7 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 d9639b02e1..dd052fa1a7 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, 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 0000000000..6f46712e54 --- /dev/null +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.lua @@ -0,0 +1,5 @@ +function Pandoc(doc) + if quarto.paths.typst() == nil then + crash() + end +end 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 0000000000..8e91ad0578 --- /dev/null +++ b/tests/docs/smoke-all/2025/12/05/typst-path-api.qmd @@ -0,0 +1,7 @@ +--- +format: html +filters: + - typst-path-api.lua +--- + +The Typst path is accessible.