Skip to content

Commit

Permalink
add to _format instead
Browse files Browse the repository at this point in the history
  • Loading branch information
cscheid committed Apr 29, 2024
1 parent bf0cd0c commit e9259c0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/resources/filters/customnodes/callout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -695,9 +695,9 @@ end, function(callout)
title = pandoc.Plain(displayName(callout.type))
end

local typst_callout = quarto.format.typst.function_call("callout", {
{ "body", quarto.format.typst.as_typst_content(callout.content) },
{ "title", quarto.format.typst.as_typst_content(title) },
local typst_callout = _quarto.format.typst.function_call("callout", {
{ "body", _quarto.format.typst.as_typst_content(callout.content) },
{ "title", _quarto.format.typst.as_typst_content(title) },
{ "background_color", pandoc.RawInline("typst", background_color) },
{ "icon_color", pandoc.RawInline("typst", icon_color) },
{ "icon", pandoc.RawInline("typst", "" .. icon .. "()")}
Expand Down
10 changes: 8 additions & 2 deletions src/resources/filters/quarto-post/typst.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
--
-- renders AST nodes to Typst

-- FIXME Ideally this would go directly on init.lua, but
-- the module path set up doesn't appear to be working there.

local typst = require("modules/typst")
_quarto.format.typst = typst

function render_typst()
if not _quarto.format.isTypstOutput() then
return {}
Expand Down Expand Up @@ -60,8 +66,8 @@ function render_typst()
if el.classes:includes("unlisted") then
params:insert({"outlined", false})
end
params:insert({quarto.format.typst.as_typst_content(el.content)})
return quarto.format.typst.function_call("heading", params)
params:insert({_quarto.format.typst.as_typst_content(el.content)})
return _quarto.format.typst.function_call("heading", params)
end,
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/resources/lua-types/quarto/typst.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---@meta

quarto.format.typst = {}
_quarto.format.typst = {}

--[[
Create a node that represents a typst function call.
]]
---@param name string Name of function
---@param params table<string, any> Array of {param, value} pairs
---@return pandoc.Div
function quarto.format.typst.function_call(name, params) end
function _quarto.format.typst.function_call(name, params) end

--[[
Create a node that represents typst content (`[Hello, world]`). Use
this to ensure your output isn't interpreted as typst computations.
]]
---@param b64str string Base64 encoded string
---@param content any content
---@return pandoc.Blocks
function quarto.format.typst.as_typst_content(b64str) end
function _quarto.format.typst.as_typst_content(content) end
5 changes: 1 addition & 4 deletions src/resources/pandoc/datadir/_format.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local typst = require("modules/typst")

-- does the table contain a value
local function tcontains(t,value)
if t and type(t)=="table" and value then
Expand Down Expand Up @@ -290,6 +288,5 @@ return {
isDocusaurusOutput = isDocusaurusOutput,
isDashboardOutput = isDashboardOutput,
isEmailOutput = isEmailOutput,
parse_format = parse_format,
typst = typst
parse_format = parse_format
}

0 comments on commit e9259c0

Please sign in to comment.