Skip to content

Commit 5f86f4b

Browse files
committed
Ensure proper types when setting custom node slots
1 parent 126e573 commit 5f86f4b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/resources/filters/ast/customnodes.lua

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -336,16 +336,21 @@ _quarto.ast = {
336336
return
337337
end
338338
local node = node_accessor(table)
339-
local t = pandoc.utils.type(value)
340-
quarto_assert(t ~= 'Div' and t ~= 'Span', "")
339+
local valtype = pandoc.utils.type(value)
340+
quarto_assert(valtype ~= 'Div' and valtype ~= 'Span', "")
341341
if index > #node.content then
342342
_quarto.ast.grow_scaffold(node, index)
343343
end
344-
local pt = pandoc.utils.type(value)
345-
if pt == "Block" or pt == "Inline" then
346-
node.content[index].content = {value}
344+
local inner_node = node.content[index]
345+
local innertype = pandoc.utils.type(inner_node)
346+
if innertype == 'Block' then
347+
inner_node.content = quarto.utils.as_blocks(value)
348+
elseif innertype == 'Inline' then
349+
inner_node.content = quarto.utils.as_inlines(value)
347350
else
348-
node.content[index].content = value
351+
warn(debug.traceback(
352+
'Cannot find the right content type for value ' .. valtype))
353+
inner_node.content = value
349354
end
350355
end
351356
}

0 commit comments

Comments
 (0)