Skip to content

Commit 87f18c8

Browse files
authored
Merge pull request #13762 from mcanouil/feat/typst-path-lua-api
2 parents 912352e + fb2dd27 commit 87f18c8

File tree

6 files changed

+29
-0
lines changed

6 files changed

+29
-0
lines changed

news/changelog-1.9.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ All changes included in 1.9:
6868

6969
- ([#13414](https://github.com/quarto-dev/quarto-cli/issues/13414)): Be more forgiving when Confluence server returns malformed JSON response. (author: @m1no)
7070

71+
## Lua API
72+
73+
- ([#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)
74+
7175
## Other fixes and improvements
7276

7377
- ([#13402](https://github.com/quarto-dev/quarto-cli/issues/13402)): `nfpm` (<https://nfpm.goreleaser.com/>) 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.

src/command/render/filters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ import { pythonExec } from "../../core/jupyter/exec.ts";
9595
import { kTocIndent } from "../../config/constants.ts";
9696
import { isWindows } from "../../deno_ral/platform.ts";
9797
import { tinyTexBinDir } from "../../tools/impl/tinytex-info.ts";
98+
import { typstBinaryPath } from "../../core/typst.ts";
9899

99100
const kQuartoParams = "quarto-params";
100101

@@ -204,6 +205,7 @@ async function quartoEnvironmentParams(_options: PandocOptions) {
204205
"paths": {
205206
"Rscript": await rBinaryPath("Rscript"),
206207
"TinyTexBinDir": tinyTexBinDir(), // will be undefined if no tinytex found and quarto will look in PATH
208+
"Typst": typstBinaryPath(),
207209
},
208210
};
209211
}

src/resources/lua-types/quarto/paths.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ Returns the path to the `TinyTeX` bin directory that `quarto install tinytex` in
1313
]]
1414
---@return string|nil # Path to `TinyTeX` bin directory
1515
function quarto.paths.tinytex_bin_dir() end
16+
17+
--[[
18+
Returns the path to the Typst binary that Quarto itself would use for rendering Typst documents.
19+
This will be the value of the QUARTO_TYPST environment variable if set, or the path to the
20+
Typst binary bundled with Quarto.
21+
]]
22+
---@return string # Path to Typst binary
23+
function quarto.paths.typst() end

src/resources/pandoc/datadir/init.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,9 @@ quarto = {
990990
tinytex_bin_dir = function()
991991
return param('quarto-environment', nil).paths.TinyTexBinDir
992992
end,
993+
typst = function()
994+
return param('quarto-environment', nil).paths.Typst
995+
end,
993996
},
994997
json = json,
995998
base64 = base64,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function Pandoc(doc)
2+
if quarto.paths.typst() == nil then
3+
crash()
4+
end
5+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
format: html
3+
filters:
4+
- typst-path-api.lua
5+
---
6+
7+
The Typst path is accessible.

0 commit comments

Comments
 (0)