-
Notifications
You must be signed in to change notification settings - Fork 344
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
Space in file path can not be processed by typst #10181
Comments
This is not a YAML header for Quarto here. So the reproducible example is not ok. Can you share the real reproducible example you ran as I see I tried ---
format: typst
keep-typ: true
---

And it is working ok. |
Hi @cderv, thank you for the reminder -- I updated the post. It seems that the error only happen when the space is in the filepath AND the width is specified. |
Thanks for the new reproducible example. The problem lies in the typ filep produced
This shows that the spaces are encoded. And it happens only for all except the first. THis is the intermediate .typ content = This works
<this-works>
#box(image("image with space.png"))
= This also works
<this-also-works>
#box(width: 50%,image("image%20with%20space.png"))
= This does not work
<this-does-not-work>
#box(width: 50%,image("images/image%20with%20space.png"))
= This does not work
<this-does-not-work-1>
#block[
]
#grid(
columns: (50.0%, 50.0%), gutter: 1em, rows: 1,
rect(stroke: none, width: 100%)[
#box(width: 100%,image("images/image%20with%20space.png"))
],
rect(stroke: none, width: 100%)[
#box(width: 100%,image("images/image%20with%20space.png"))
], It does not happen with bare pandoc. So it comes from our processing it seems. |
This is interesting ! This is because Pandoc will unEscape strings in the writer. src' = T.pack $ unEscapeString $ T.unpack src -- #9389 It was reported in pandoc in January: and added in 3.1.12 They use a function from Haskell But we have our own, so we should probably use this in the right place... quarto-cli/src/resources/filters/common/url.lua Lines 4 to 24 in 03ccb80
|
diff --git a/src/resources/filters/quarto-post/typst.lua b/src/resources/filters/quarto-post/typst.lua
index 3ceefe686..6e0aba7ac 100644
--- a/src/resources/filters/quarto-post/typst.lua
+++ b/src/resources/filters/quarto-post/typst.lua
@@ -121,7 +121,7 @@ function render_typst_fixups()
attr_str = attr_str .. "height: " .. height .. ","
end
local escaped_src = image.src:gsub("\\", "\\\\"):gsub("\"", "\\\"")
- return pandoc.RawInline("typst", "#box(" .. attr_str .. "image(\"" .. escaped_src .. "\"))")
+ return pandoc.RawInline("typst", "#box(" .. attr_str .. "image(\"" .. fullyUrlDecode(escaped_src) .. "\"))")
end
return image |
The diff above fixes it. Though it modifies a block that I am not sure we still need based on the comment quarto-cli/src/resources/filters/quarto-post/typst.lua Lines 105 to 125 in 03ccb80
So maybe the real fix is to just rely on Pandoc processing
So it seems it is doing the right thing now and @cscheid I defer to you for decision |
Bug description
When adding image with space in filename, Typst gives error while other formats are fine
Update: it only happen in
#box
element (i.e., when specifying widthSteps to reproduce
quarto render report.qmd --to typst
Expected behavior
Render with no error
Actual behavior
Your environment
No response
Quarto check output
The text was updated successfully, but these errors were encountered: