Skip to content

Commit 09ad565

Browse files
committed
Force use of pandoc walk for some filters
1 parent 023f512 commit 09ad565

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

src/resources/filters/ast/customnodes.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function is_regular_node(node, name)
4141
return node
4242
end
4343

44-
function run_emulated_filter(doc, filter)
44+
function run_emulated_filter(doc, filter, force_use_walk)
4545
if doc == nil then
4646
return nil
4747
end
@@ -73,7 +73,10 @@ function run_emulated_filter(doc, filter)
7373
-- luacov: enable
7474
end
7575
end
76-
return _quarto.modules.jog(node, filter_param)
76+
_QUARTO_USE_WALK = force_use_walk
77+
local result = _quarto.modules.jog(node, filter_param)
78+
_QUARTO_USE_WALK = false
79+
return result
7780
end
7881

7982
-- performance: if filter is empty, do nothing

src/resources/filters/ast/emulatedfilter.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ inject_user_filters_at_entry_points = function(filter_list)
6868
end
6969
local filter = {
7070
name = entry_point .. "-user-" .. tostring(entry_point_counts[entry_point]),
71+
-- The filter might not work as expected when doing a non-lazy jog, so
72+
-- make sure it is processed with the default 'walk' function.
73+
force_pandoc_walk = true,
7174
}
7275
if is_many_filters then
7376
filter.filters = wrapped

src/resources/filters/ast/runemulation.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ local function run_emulated_filter_chain(doc, filters, afterFilterPass, profilin
7979
print(pandoc.write(doc, "native"))
8080
else
8181
_quarto.ast._current_doc = doc
82-
doc = run_emulated_filter(doc, v.filter)
82+
83+
doc = run_emulated_filter(doc, v.filter, v.force_pandoc_walk)
84+
8385
ensure_vault(doc)
8486

8587
add_trace(doc, v.name)
@@ -204,4 +206,4 @@ function run_as_extended_ast(specTable)
204206
end
205207

206208
return pandocFilterList
207-
end
209+
end

src/resources/filters/main.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,12 +417,12 @@ local quarto_finalize_filters = {
417417
local quarto_layout_filters = {
418418
{ name = "manuscript filtering", filter = manuscript() },
419419
{ name = "manuscript filtering", filter = manuscriptUnroll() },
420-
{ name = "layout-lightbox", filters = lightbox(), flags = { "has_lightbox" }},
420+
{ name = "layout-lightbox", filters = lightbox(), force_pandoc_walk = true, flags = { "has_lightbox" }},
421421
{ name = "layout-columns-preprocess", filter = columns_preprocess() },
422422
{ name = "layout-columns", filter = columns() },
423423
{ name = "layout-cites-preprocess", filter = cites_preprocess() },
424424
{ name = "layout-cites", filter = cites() },
425-
{ name = "layout-panels", filter = layout_panels() },
425+
{ name = "layout-panels", filter = layout_panels(), force_pandoc_walk = true },
426426
{ name = "post-fold-code-and-lift-codeblocks-from-floats", filter = fold_code_and_lift_codeblocks() },
427427
}
428428

@@ -435,7 +435,8 @@ local quarto_crossref_filters = {
435435
filter = crossref_preprocess_theorems(),
436436
flags = { "has_theorem_refs" } },
437437

438-
{ name = "crossref-combineFilters", filter = combineFilters({
438+
{ name = "crossref-combineFilters", force_pandoc_walk = true,
439+
filter = combineFilters({
439440
file_metadata(),
440441
qmd(),
441442
sections(),

src/resources/filters/modules/jog.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ local function jog(element, filter)
255255
end
256256
end
257257

258+
if _QUARTO_USE_WALK then
259+
return element:walk(filter)
260+
end
261+
258262
-- Create and call traversal function
259263
local jog_internal = make_jogger(filter, context)
260264
return jog_internal(element)

src/resources/filters/normalize/astpipeline.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ function quarto_ast_pipeline()
3535
code_filename(),
3636
normalize_fixup_data_uri_image_extension(),
3737
warn_on_stray_triple_colons(),
38-
})
38+
}),
39+
force_pandoc_walk = true,
3940
},
4041
{
4142
name = "normalize-combine-2",
@@ -44,6 +45,7 @@ function quarto_ast_pipeline()
4445
parse_floatreftargets(),
4546
parse_blockreftargets()
4647
}),
48+
force_pandoc_walk = true,
4749
},
4850
{
4951
name = "normalize-3",

0 commit comments

Comments
 (0)