Skip to content

Commit

Permalink
Use Quarto's built-in Typst exec as default when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
tarleb committed Oct 1, 2024
1 parent d6e6b34 commit 66476a6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
15 changes: 10 additions & 5 deletions _extensions/diagram/diagram.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ end
local io = require 'io'
local pandoc = require 'pandoc'
local system = require 'pandoc.system'
local utils = require 'pandoc.utils'
local utils = require 'pandoc.utils'
local List = require 'pandoc.List'
local stringify = utils.stringify
local with_temporary_directory = system.with_temporary_directory
local with_working_directory = system.with_working_directory
Expand Down Expand Up @@ -99,8 +100,7 @@ local function pipe (command, args, input)
if pandoc.utils.type(command) == 'List' then
command = command:map(stringify)
cmd = command:remove(1)
command:extend(args)
args = command
args = command .. args
else
cmd = stringify(command)
end
Expand Down Expand Up @@ -269,14 +269,19 @@ local cetz = {
#import "@preview/cetz:0.2.2"
#set page(width: auto, height: auto, margin: .5cm)
]]

local typst_code = preamble .. code

return with_temporary_directory("diagram", function (tmpdir)
return with_working_directory(tmpdir, function ()
local outfile = 'diagram.' .. format
local execpath = self.execpath
if not execpath and quarto and quarto.version >= '1.4' then
-- fall back to the Typst exec shipped with Quarto.
execpath = List{'quarto', 'typst'}
end
pipe(
self.execpath or 'typst',
execpath or 'typst',
{"compile", "-f", format, "-", outfile},
typst_code
)
Expand Down
5 changes: 0 additions & 5 deletions test/test-cetz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,3 @@ input-files: ['test/input-cetz.md']
filters:
- diagram.lua
to: html
metadata:
diagram:
engine:
cetz:
execpath: ['quarto', 'typst']

0 comments on commit 66476a6

Please sign in to comment.