Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(markdown): do not keep increasing backslashes for dollar sign #5358

Merged
merged 3 commits into from Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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