Skip to content

Commit

Permalink
fix(markdown): do not break before special prefix (#3347)
Browse files Browse the repository at this point in the history
  • Loading branch information
ikatyang authored and azz committed Nov 29, 2017
1 parent 562b4e1 commit 7670024
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/printer-markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function genericPrint(path, options, print) {
const nextNode = parentNode.children[index + 1];

// leading char that may cause different syntax
if (nextNode && /^>|^([-+*]|#{1,6})$/.test(nextNode.value)) {
if (nextNode && /^>|^([-+*]|#{1,6}|[0-9]+[.)])$/.test(nextNode.value)) {
return node.value === "" ? "" : " ";
}

Expand Down
9 changes: 9 additions & 0 deletions tests/markdown_paragraph/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc
- disallow identical titles.
* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) -
ensure expect is called correctly.
She grew up in an isolated village in the 19th century and met her father aged 29. Oh no, why are we in a numbered list now?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc
abc - abc abc abc
Expand All @@ -142,6 +144,9 @@ abc - abc abc abc
* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) -
ensure expect is called correctly.
She grew up in an isolated village in the 19th century and met her father
aged 29. Oh no, why are we in a numbered list now?
`;

exports[`special-prefix.md 2`] = `
Expand All @@ -164,6 +169,8 @@ abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc
- disallow identical titles.
* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) -
ensure expect is called correctly.
She grew up in an isolated village in the 19th century and met her father aged 29. Oh no, why are we in a numbered list now?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc - abc abc abc
Expand All @@ -184,6 +191,8 @@ abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc
* disallow identical titles.
* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) - ensure expect is called correctly.
She grew up in an isolated village in the 19th century and met her father aged 29. Oh no, why are we in a numbered list now?
`;

exports[`whitespace.md 1`] = `
Expand Down
2 changes: 2 additions & 0 deletions tests/markdown_paragraph/special-prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc abc
- disallow identical titles.
* [valid-expect](/packages/eslint-plugin-jest/docs/rules/valid-expect.md) -
ensure expect is called correctly.

She grew up in an isolated village in the 19th century and met her father aged 29. Oh no, why are we in a numbered list now?

0 comments on commit 7670024

Please sign in to comment.