-
Notifications
You must be signed in to change notification settings - Fork 330
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
perf: Use non-lazy AST traversal for filters when possible #11052
Conversation
8a04c2a
to
d7651cc
Compare
f1b9896
to
22ce9b0
Compare
4d683c6
to
51c8800
Compare
Hi @tarleb, the root cause of the Typst callout failures is that both with jog and without, the following quarto-cli/src/resources/filters/customnodes/callout.lua Lines 46 to 51 in bf93178
will initialize However, when the custom node is read later on to generate Typst,
on jog. quarto-cli/src/resources/filters/customnodes/callout.lua Lines 264 to 272 in bf93178
It's not the right solution, because we'd like to understand why it is converting (?) the title differently, but the following diff gets these tests passing: diff --git a/src/resources/filters/customnodes/callout.lua b/src/resources/filters/customnodes/callout.lua
index 8a9f4c17d..e9deaa2d2 100644
--- a/src/resources/filters/customnodes/callout.lua
+++ b/src/resources/filters/customnodes/callout.lua
@@ -261,10 +261,14 @@ function _callout_main()
end
end
if callout.attr.identifier == "" then
+ local title = callout.title
+ if not title or #title.content == 0 then
+ title = pandoc.Plain(_quarto.modules.callouts.displayName(callout.type))
+ end
return _quarto.format.typst.function_call("callout", {
{ "body", _quarto.format.typst.as_typst_content(callout.content) },
{ "title", _quarto.format.typst.as_typst_content(
- callout.title or pandoc.Plain(_quarto.modules.callouts.displayName(callout.type))
+ title
)},
{ "background_color", pandoc.RawInline("typst", background_color) },
{ "icon_color", pandoc.RawInline("typst", icon_color) }, |
This behaves mostly like the built-in `assert`, but respects the general Quarto scaffolding.
This also fixes unwanted behavior of `as_blocks`, which would treat a list of Inline elements as a list of singleton Plain elements, leading to bad results.
This also fixes unwanted behavior of `as_blocks`, which would treat a list of Inline elements as a list of singleton Plain elements, leading to bad results.
Minor performance improvement.
This allows to get reproducible output when running the filter multiple times.
If the metadata object is modified in a filter, then it should be returned, as otherwise the changes might be lost.
The `long` field of a caption can never be nil, but it can be an empty list.
67c4ca7
to
7ca4ad5
Compare
Jog can be enable on a per-filter basis by setting the `traverse` field to `jog`.
jog
Lua modulejog
resultsWelcome to the quarto GitHub repo!
We are always happy to hear feedback from our users.
To file a pull request, please follow these instructions carefully: https://yihui.org/issue/#bug-reports
If you're a collaborator from outside
quarto-dev
making changes larger than a typo, please make sure you have filed an individual or corporate contributor agreement. You can send the signed copy to [email protected].Also, please complete and keep the checklist below.
Description
Please describe your PR here.
Checklist
I have (if applicable):