perf: Use non-lazy AST traversal for filters when possible#11052
Closed
tarleb wants to merge 25 commits intoquarto-dev:mainfrom
Closed
perf: Use non-lazy AST traversal for filters when possible#11052tarleb wants to merge 25 commits intoquarto-dev:mainfrom
tarleb wants to merge 25 commits intoquarto-dev:mainfrom
Conversation
8a04c2a to
d7651cc
Compare
f1b9896 to
22ce9b0
Compare
4d683c6 to
51c8800
Compare
Member
|
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`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
jogLua modulejogresultsWelcome 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-devmaking changes larger than a typo, please make sure you have filed an individual or corporate contributor agreement. You can send the signed copy to jj@rstudio.com.Also, please complete and keep the checklist below.
Description
Please describe your PR here.
Checklist
I have (if applicable):