Skip to content

Commit da9fb87

Browse files
committed
fix: escape newline, carriage return, and tab characters in filename
1 parent 6efcd12 commit da9fb87

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/resources/filters/customnodes/decoratedcodeblock.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@ _quarto.ast.add_renderer("DecoratedCodeBlock",
197197
CodeBlock = render_folded_block
198198
}) or pandoc.Blocks({})
199199
local blocks = pandoc.Blocks({})
200-
local escaped = node.filename:gsub('\\', '\\\\'):gsub('"', '\\"')
200+
local escaped = node.filename
201+
:gsub('\\', '\\\\')
202+
:gsub('"', '\\"')
203+
:gsub('\n', '\\n')
204+
:gsub('\r', '\\r')
205+
:gsub('\t', '\\t')
201206
blocks:insert(pandoc.RawBlock("typst",
202207
'#quarto-code-filename("' .. escaped .. '")['))
203208
blocks:extend(rendered)

0 commit comments

Comments
 (0)