-
Notifications
You must be signed in to change notification settings - Fork 320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
typst callouts are bracketed #9816
Comments
@gordonwoodhull I believe this happens because we already add the wrapping square brackets quarto-cli/src/resources/filters/modules/typst.lua Lines 18 to 21 in 92bfd31
So wrapping again in So either
diff --git a/src/resources/filters/customnodes/callout.lua b/src/resources/filters/customnodes/callout.lua
index e109802ce..2feda4752 100644
--- a/src/resources/filters/customnodes/callout.lua
+++ b/src/resources/filters/customnodes/callout.lua
@@ -389,10 +389,10 @@ function _callout_main()
if title == nil then
title = pandoc.Plain(_quarto.modules.callouts.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) },
+ { "body", callout.content },
+ { "title", title },
{ "background_color", pandoc.RawInline("typst", background_color) },
{ "icon_color", pandoc.RawInline("typst", icon_color) },
{ "icon", pandoc.RawInline("typst", "" .. icon .. "()")} diff --git a/src/resources/filters/modules/typst.lua b/src/resources/filters/modules/typst.lua
index 09a22e950..dde20b3cb 100644
--- a/src/resources/filters/modules/typst.lua
+++ b/src/resources/filters/modules/typst.lua
@@ -5,6 +5,14 @@
-- this module is exposed as quarto.format.typst
local function _main()
+ local function as_typst_content(content)
+ local result = pandoc.Blocks({})
+ result:insert(pandoc.RawInline("typst", "[\n"))
+ result:extend(quarto.utils.as_blocks(content) or {})
+ result:insert(pandoc.RawInline("typst", "]\n"))
+ return result
+ end
+
local function typst_function_call(name, params, keep_scaffold)
local result = pandoc.Blocks({})
result:insert(pandoc.RawInline("typst", "#" .. name .. "("))
@@ -16,9 +24,7 @@ local function _main()
elseif v.t == "RawInline" or v.t == "RawBlock" then
result:insert(v)
elseif type(v) == "userdata" or type(v) == "table" then
- result:insert(pandoc.RawInline("typst", "["))
- result:extend(quarto.utils.as_blocks(v) or {})
- result:insert(pandoc.RawInline("typst", "]"))
+ result:extend(as_typst_content(v))
else
result:extend(quarto.utils.as_blocks({pandoc.utils.stringify(v)}) or {})
end
@@ -55,14 +61,6 @@ local function _main()
end
end
- local function as_typst_content(content)
- local result = pandoc.Blocks({})
- result:insert(pandoc.RawInline("typst", "[\n"))
- result:extend(quarto.utils.as_blocks(content) or {})
- result:insert(pandoc.RawInline("typst", "]\n"))
- return result
- end
-
return {
function_call = typst_function_call,
as_typst_content = as_typst_content |
I'm sorry :( (I'm back as of today, so I'll fix this) |
This is annoying. What I would really like to have is some indication to whether a parameter that was passed to I think that means that callers of |
Interesting, I have been wondering what conventions we should use to know which "mode" of typst (code/content/math) is appropriate for a parameter. I agree, expecting code mode for function parameters is probably apt. It's a very clever system, not something I recall seeing in any other language. |
Yes, it indeed is! We could have custom Quarto AST nodes for TypstCode and TypstContent, but I don't think the juice is worth the squeeze in this case. Those are really most useful if the nodes are going to reside in the document for a while, and I don't think that's going to be the case for us. |
I'd like to add regression tests here that aren't a snapshot test. This requires finding the text content in a .pdf file. I first tested the Unix I then tested The question, then, is how to install this dependency in our test suite:
@cderv, what do you recommend? |
For windows poppler is a good choice as it is available. Best I know is to use Scoop manager to install this
then the pdftotext command will be on PATH. We just need a specific action to install scoop and the tool. I can do this. PS: the windows version I know is here. https://github.com/oschwartz10612/poppler-windows Another solution is to use R which is already available on runners with pdftools library which has functions based in But this would mean running from Deno |
Somehow #9690 caused Typst callouts to have an extra level of square brackets, which are rendered as text
Sample of Typst output for
dev-docs/feature-format-matrix/qmd-files/callout/document.qmd
:Likely incorrect fix - I ran out of time for now and couldn't pinpoint why this is happening... I'm sure there is a better way to to fix this!
The text was updated successfully, but these errors were encountered: