Skip to content

Commit 3838680

Browse files
authored
Merge pull request #8391 from quarto-dev/bugfix/8389
Fixes escaping bugs
2 parents 945b7d1 + 3bd8714 commit 3838680

File tree

5 files changed

+69
-2
lines changed

5 files changed

+69
-2
lines changed

src/resources/filters/customnodes/shortcodes.lua

+6-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,12 @@ function shortcodes_filter()
285285
Link = function(el)
286286
el.target = code_shortcode:match(el.target)
287287
return el
288-
end
288+
end,
289+
Span = function(el)
290+
if el.classes:includes("quarto-shortcode__-escaped") then
291+
return pandoc.Str(el.attributes["data-value"])
292+
end
293+
end,
289294
})
290295
return doc
291296
end

src/resources/filters/modules/patterns.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local html_table = tag(html_table_tag_name)
1313
local html_table_caption = tag("[Cc][Aa][Pp][Tt][Ii][Oo][Nn]")
1414
local html_paged_table = "<script data[-]pagedtable[-]source type=\"application/json\">"
1515
local html_gt_table = "<table class=\"gt_table\">"
16-
local engine_escape = "{({+([^}]+)}+)}"
16+
local engine_escape = "{({+([^<}]+)}+)}"
1717
local shortcode = "{{+<[^>]+>}+}"
1818
local latex_label = "(\\label{([^}]+)})"
1919
local latex_caption = "(\\caption{([^}]+)})"

src/resources/filters/quarto-pre/engine-escape.lua

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ function engine_escape()
2424
end
2525
return "```" .. engine
2626
end)
27+
28+
-- handles escaped inline code cells within a code block
29+
el.text = el.text:gsub("(`+)" .. patterns.engine_escape, "%1%2")
30+
2731
return el
2832
end,
2933

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
_quarto: {}
3+
foo: bar
4+
toc-title: Table of contents
5+
---
6+
7+
This doesn't unescape and should: `{r} 1.2`
8+
This evaluates: 1.2
9+
bar
10+
In a phrase: bar
11+
With quotes: `bar`
12+
{{< meta foo >}}
13+
In a phrase: {{< meta foo >}}
14+
With quotes: `{{< meta foo >}}`
15+
16+
`bar` There's no more bug here.
17+
18+
`{{< meta foo >}}` There's no more bug here.
19+
20+
{{< meta foo >}} Hello?
21+
22+
bar Hello?
23+
24+
Hello, `{{< meta foo >}}`, `bar`.
25+
26+
`` `{{< meta foo >}}` ``, `` `bar` ``.
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
engine: knitr
3+
format: markdown
4+
foo: bar
5+
_quarto:
6+
tests:
7+
markdown:
8+
ensureSnapshotMatches: true
9+
---
10+
11+
```
12+
This doesn't unescape and should: `{{r}} 1.2`
13+
This evaluates: `{r} 1.2`
14+
{{< meta foo >}}
15+
In a phrase: {{< meta foo >}}
16+
With quotes: `{{< meta foo >}}`
17+
{{{< meta foo >}}}
18+
In a phrase: {{{< meta foo >}}}
19+
With quotes: `{{{< meta foo >}}}`
20+
```
21+
22+
`{{< meta foo >}}` There's no more bug here.
23+
24+
`{{{< meta foo >}}}` There's no more bug here.
25+
26+
{{{< meta foo >}}} Hello?
27+
28+
{{< meta foo >}} Hello?
29+
30+
Hello, `{{{< meta foo >}}}`, `{{< meta foo >}}`.
31+
32+
`` `{{{< meta foo >}}}` ``, `` `{{< meta foo >}}` ``.

0 commit comments

Comments
 (0)