From 7550720f9b600915947eed68d5bbe3a627fb76f2 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Thu, 12 Dec 2024 16:49:24 +0100 Subject: [PATCH 1/2] Export TinyTeX bin directory to Lua filter. This is useful for a filter to call `tlmgr` or other tools while they are not put on PATH by `quarto install tinytex` --- news/changelog-1.7.md | 1 + src/command/render/filters.ts | 2 ++ src/resources/pandoc/datadir/init.lua | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/news/changelog-1.7.md b/news/changelog-1.7.md index 55410deea6..ac8a57b2de 100644 --- a/news/changelog-1.7.md +++ b/news/changelog-1.7.md @@ -25,6 +25,7 @@ All changes included in 1.7: This also provides a new public function `quarto.utils.is_empty_node` that allows to check whether a node is empty, i.e., whether it's an empty list, has no child nodes, and contains no text. +- Expose new `quarto.paths.tinytex_bin_dir` in Quarto's Lua API. If TinyTeX is found by Quarto, this will be set to the path to the `bin` directory of the TinyTeX installation where command line tool are located (e.g., `pdflatex`, `tlmgr`, etc.). If TinyTeX is not found, this will be `nil`, meaning Quarto will use the system PATH to find the command line tools. ## Other Fixes and Improvements diff --git a/src/command/render/filters.ts b/src/command/render/filters.ts index 41548894fc..59ed456e72 100644 --- a/src/command/render/filters.ts +++ b/src/command/render/filters.ts @@ -93,6 +93,7 @@ import { isServerShinyPython } from "../../core/render.ts"; 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"; const kQuartoParams = "quarto-params"; @@ -205,6 +206,7 @@ async function quartoEnvironmentParams(_options: PandocOptions) { return { "paths": { "Rscript": await rBinaryPath("Rscript"), + "TinyTexBinDir": tinyTexBinDir(), // will be undefined if no tinytex found and quarto will look in PATH }, }; } diff --git a/src/resources/pandoc/datadir/init.lua b/src/resources/pandoc/datadir/init.lua index 4c7f1eecac..deb7ea47b6 100644 --- a/src/resources/pandoc/datadir/init.lua +++ b/src/resources/pandoc/datadir/init.lua @@ -2093,10 +2093,13 @@ quarto = { add_to_blocks = utils.add_to_blocks, }, paths = { + -- matches the path from `quartoEnvironmentParams` from src/command/render/filters.ts rscript = function() - -- matches the path from `quartoEnvironmentParams` from src/command/render/filters.ts return param('quarto-environment', nil).paths.Rscript end, + tinytex_bin_dir = function() + return param('quarto-environment', nil).paths.TinyTexBinDir + end, }, json = json, base64 = base64, From 75df5c9dd61b575ac7e52eeb8bcf38b095b40066 Mon Sep 17 00:00:00 2001 From: Christophe Dervieux Date: Fri, 13 Dec 2024 14:32:34 +0100 Subject: [PATCH 2/2] add associated lua-types --- src/resources/lua-types/quarto/paths.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/resources/lua-types/quarto/paths.lua b/src/resources/lua-types/quarto/paths.lua index c544699755..fdb86c1d11 100644 --- a/src/resources/lua-types/quarto/paths.lua +++ b/src/resources/lua-types/quarto/paths.lua @@ -7,3 +7,9 @@ Returns the path to the `Rscript` file that Quarto itself would use in its knitr ]] ---@return string # Path to `Rscript` file function quarto.paths.rscript() end + +--[[ +Returns the path to the `TinyTeX` bin directory that `quarto install tinytex` installed to, or nil if not found. +]] +---@return string|nil # Path to `TinyTeX` bin directory +function quarto.paths.tinytex_bin_dir() end