Skip to content

Commit 8cedb9d

Browse files
authored
fix(markdown): do not keep increasing backslashes for dollar sign (#5358)
1 parent e036251 commit 8cedb9d

5 files changed

Lines changed: 31 additions & 4 deletions

File tree

src/language-markdown/preprocess.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ function restoreUnescapedCharacter(ast, options) {
4646
: Object.assign({}, node, {
4747
value:
4848
node.value !== "*" &&
49-
node.value !== "_" && // handle these two cases in printer
49+
node.value !== "_" &&
50+
node.value !== "$" && // handle these cases in printer
5051
isSingleCharRegex.test(node.value) &&
5152
node.position.end.offset - node.position.start.offset !==
5253
node.value.length

tests/markdown_math/__snapshots__/jsfmt.spec.js.snap

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`dollar-sign.md - markdown-verify 1`] = `
4+
$
5+
6+
\\$
7+
8+
\\\\$
9+
10+
\\\\\\$
11+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12+
\\$
13+
14+
\\$
15+
16+
\\\\\\$
17+
18+
\\\\\\$
19+
20+
`;
21+
322
exports[`empty-block.md - markdown-verify 1`] = `
423
$$
524
$$
@@ -107,7 +126,7 @@ $$
107126
108127
---
109128
110-
\\\\$\\alpha\\$
129+
\\$\\alpha\\$
111130
112131
---
113132

tests/markdown_math/dollar-sign.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$
2+
3+
\$
4+
5+
\\$
6+
7+
\\\$

tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3306,7 +3306,7 @@ exports[`example-284.md - markdown-verify 1`] = `
33063306
exports[`example-285.md - markdown-verify 1`] = `
33073307
\\!\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\\`\\{\\|\\}\\~
33083308
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3309-
\\!\\"\\#\\\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\\`\\{\\|\\}\\~
3309+
\\!\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\\`\\{\\|\\}\\~
33103310
33113311
`;
33123312

tests/multiparser_js_markdown/__snapshots__/jsfmt.spec.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ markdown\`
9494
- \\\\\\\`
9595
- \\\\ a
9696
- \\\\\\\\
97-
- \\\\$
97+
- \\$
9898
- \\u1234
9999
\`;
100100

0 commit comments

Comments
 (0)