Skip to content

Commit

Permalink
Merge pull request #11670 from quarto-dev/lua/expose-tinytex-path
Browse files Browse the repository at this point in the history
  • Loading branch information
cderv authored Dec 13, 2024
2 parents cb09d52 + 75df5c9 commit f366f92
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,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

Expand Down
2 changes: 2 additions & 0 deletions src/command/render/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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
},
};
}
Expand Down
6 changes: 6 additions & 0 deletions src/resources/lua-types/quarto/paths.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion src/resources/pandoc/datadir/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit f366f92

Please sign in to comment.