Skip to content

Commit 2f9e73d

Browse files
committed
never again: do not confuse function() with local function()
1 parent 353e70d commit 2f9e73d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/resources/filters/ast/customnodes.lua

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ function resolve_custom_node(node)
1818
end
1919

2020
function run_emulated_filter(doc, filter, top_level)
21+
if filter._is_wrapped then
22+
return doc:walk(filter)
23+
end
24+
2125
local wrapped_filter = {}
2226
for k, v in pairs(filter) do
2327
wrapped_filter[k] = v
2428
end
2529

26-
function process_custom_inner(raw)
30+
local function process_custom_inner(raw)
2731
_quarto.ast.inner_walk(raw, wrapped_filter)
2832
end
2933

30-
function process_custom_preamble(custom_data, t, kind, custom_node)
34+
local function process_custom_preamble(custom_data, t, kind, custom_node)
3135
if custom_data == nil then
3236
return nil
3337
end
@@ -42,7 +46,7 @@ function run_emulated_filter(doc, filter, top_level)
4246
end
4347
end
4448

45-
function process_custom(custom_data, t, kind, custom_node)
49+
local function process_custom(custom_data, t, kind, custom_node)
4650
local result, recurse = process_custom_preamble(custom_data, t, kind, custom_node)
4751
if filter.traverse ~= "topdown" or recurse ~= false then
4852
if tisarray(result) then
@@ -131,11 +135,13 @@ function run_emulated_filter(doc, filter, top_level)
131135
end
132136
end
133137

134-
local result = doc:walk(wrapped_filter)
138+
wrapped_filter._is_wrapped = true
139+
140+
local result, recurse = doc:walk(wrapped_filter)
135141
if top_level and filter._filter_name ~= nil then
136142
add_trace(result, filter._filter_name)
137143
end
138-
return result
144+
return result, recurse
139145
end
140146

141147
function create_emulated_node(t, tbl, context)

0 commit comments

Comments
 (0)