Skip to content

Commit 4ad937b

Browse files
committed
handles filenames in code blocks like 1.2
1 parent 71696a6 commit 4ad937b

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/resources/filters/customnodes/decoratedcodeblock.lua

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ _quarto.ast.add_handler({
103103
return listingDiv
104104
end
105105
return el
106+
elseif _quarto.format.isMarkdownOutput() then
107+
-- see https://github.com/quarto-dev/quarto-cli/issues/5112
108+
--
109+
-- This is a narrow fix for the 1.3 regression.
110+
-- We still don't support listings output in markdown since that wasn't supported in 1.2 either.
111+
-- But that'll be done in 1.4 with crossrefs overhaul.
112+
113+
if node.filename then
114+
-- if we have a filename, add it as a header
115+
return pandoc.Div(
116+
{ pandoc.Plain{pandoc.Strong{pandoc.Str(node.filename)}}, el },
117+
pandoc.Attr("", {"code-with-filename"})
118+
)
119+
else
120+
return el
121+
end
106122
else
107123
-- return the code block unadorned
108124
-- this probably could be improved
@@ -111,10 +127,15 @@ _quarto.ast.add_handler({
111127
end,
112128

113129
inner_content = function(extended_node)
114-
return {}
130+
return {
131+
code_block = extended_node.code_block
132+
}
115133
end,
116134

117135
set_inner_content = function(extended_node, values)
136+
if values.code_block ~= nil then
137+
extended_node.code_block = values.code_block
138+
end
118139
return extended_node
119140
end,
120141

0 commit comments

Comments
 (0)