Skip to content

Commit 422e053

Browse files
committed
fix: improve filename escaping in DecoratedCodeBlock renderer
1 parent 3015d59 commit 422e053

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

src/resources/filters/customnodes/decoratedcodeblock.lua

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

0 commit comments

Comments
 (0)