Skip to content

Commit

Permalink
fix(markdown): do not keep increasing backslashes for dollar sign (#5358
Browse files Browse the repository at this point in the history
)
  • Loading branch information
ikatyang committed Nov 7, 2018
1 parent e036251 commit 8cedb9d
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/language-markdown/preprocess.js
Expand Up @@ -46,7 +46,8 @@ function restoreUnescapedCharacter(ast, options) {
: Object.assign({}, node, {
value:
node.value !== "*" &&
node.value !== "_" && // handle these two cases in printer
node.value !== "_" &&
node.value !== "$" && // handle these cases in printer
isSingleCharRegex.test(node.value) &&
node.position.end.offset - node.position.start.offset !==
node.value.length
Expand Down
21 changes: 20 additions & 1 deletion tests/markdown_math/__snapshots__/jsfmt.spec.js.snap
@@ -1,5 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`dollar-sign.md - markdown-verify 1`] = `
$
\\$
\\\\$
\\\\\\$
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\$
\\$
\\\\\\$
\\\\\\$
`;

exports[`empty-block.md - markdown-verify 1`] = `
$$
$$
Expand Down Expand Up @@ -107,7 +126,7 @@ $$
---
\\\\$\\alpha\\$
\\$\\alpha\\$
---
Expand Down
7 changes: 7 additions & 0 deletions tests/markdown_math/dollar-sign.md
@@ -0,0 +1,7 @@
$

\$

\\$

\\\$
2 changes: 1 addition & 1 deletion tests/markdown_spec/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -3306,7 +3306,7 @@ exports[`example-284.md - markdown-verify 1`] = `
exports[`example-285.md - markdown-verify 1`] = `
\\!\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\\`\\{\\|\\}\\~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\\!\\"\\#\\\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\\`\\{\\|\\}\\~
\\!\\"\\#\\$\\%\\&\\'\\(\\)\\*\\+\\,\\-\\.\\/\\:\\;\\<\\=\\>\\?\\@\\[\\\\\\]\\^\\_\\\`\\{\\|\\}\\~
`;
Expand Down
Expand Up @@ -94,7 +94,7 @@ markdown\`
- \\\\\\\`
- \\\\ a
- \\\\\\\\
- \\\\$
- \\$
- \\u1234
\`;
Expand Down

0 comments on commit 8cedb9d

Please sign in to comment.