fix(markdown): print `---`-style thematic break (#3148)

* fix(markdown): print `---`-style thematic break

* test: fix diff
master
Ika 2017-11-05 17:50:10 +08:00 committed by Lucas Azzola
parent d4768e1336
commit ec8deb6c0b
7 changed files with 60 additions and 42 deletions

View File

@ -218,13 +218,13 @@ function genericPrint(path, options, print) {
case "thematicBreak": {
const counter = getAncestorCounter(path, "list");
if (counter === -1) {
return "- - -";
return "---";
}
const nthSiblingIndex = getNthListSiblingIndex(
path.getParentNode(counter),
path.getParentNode(counter + 1)
);
return nthSiblingIndex % 2 === 0 ? "- - -" : "* * *";
return nthSiblingIndex % 2 === 0 ? "---" : "***";
}
case "linkReference":
return concat([

View File

@ -981,7 +981,7 @@ post](http://jlongster.com/A-Prettier-Formatter))
</details>
- - -
---
## What does Prettier do?
@ -2303,15 +2303,15 @@ Paragraph:
Code
- - -
---
- - -
---
- - -
---
- - -
---
- - -
---
* * *

View File

@ -88,15 +88,19 @@ exports[`example-10.md 1`] = `
`;
exports[`example-11.md 1`] = `
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
***
---
___
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
- - -
---
- - -
---
---
`;
@ -124,15 +128,19 @@ __
`;
exports[`example-15.md 1`] = `
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
***
***
***
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
- - -
---
- - -
---
---
`;
@ -154,35 +162,35 @@ Foo \\**\\*
exports[`example-18.md 1`] = `
_____________________________________
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
---
`;
exports[`example-19.md 1`] = `
- - -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
---
`;
exports[`example-20.md 1`] = `
** * ** * ** * **
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
---
`;
exports[`example-21.md 1`] = `
- - - -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
---
`;
exports[`example-22.md 1`] = `
- - - -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
---
`;
@ -208,7 +216,7 @@ exports[`example-25.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* foo
- - -
---
* bar
@ -221,7 +229,7 @@ bar
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo
- - -
---
bar
@ -245,7 +253,7 @@ exports[`example-28.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Foo
- - -
---
* Bar
@ -256,7 +264,7 @@ exports[`example-29.md 1`] = `
- * * *
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Foo
* - - -
* ---
`;
@ -411,15 +419,19 @@ exports[`example-45.md 1`] = `
`;
exports[`example-46.md 1`] = `
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
****
## foo
****
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
---
## foo
- - -
---
`;
@ -514,7 +526,7 @@ exports[`example-53.md 1`] = `
Foo
- - -
---
`;
@ -524,7 +536,7 @@ Foo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo
- - -
---
`;
@ -547,7 +559,7 @@ Foo = =
Foo
- - -
---
`;
@ -592,7 +604,7 @@ exports[`example-60.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Foo
- - -
---
`;
@ -613,7 +625,7 @@ exports[`example-62.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Foo
- - -
---
`;
@ -624,7 +636,7 @@ Bar
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo Bar
- - -
---
`;
@ -670,7 +682,7 @@ exports[`example-67.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* foo
- - -
---
`;
@ -680,7 +692,7 @@ exports[`example-68.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foo
- - -
---
`;
@ -690,7 +702,7 @@ exports[`example-69.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> foo
- - -
---
`;
@ -727,7 +739,7 @@ baz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo bar
- - -
---
baz
@ -741,7 +753,7 @@ baz
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Foo bar
- - -
---
baz
@ -865,7 +877,7 @@ Heading
foo
- - -
---
`;
@ -2191,7 +2203,7 @@ exports[`example-194.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> foo
- - -
---
`;
@ -2312,7 +2324,7 @@ exports[`example-206.md 1`] = `
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> aaa
- - -
---
> bbb

View File

@ -1,3 +1,5 @@
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
***
---
___

View File

@ -1,3 +1,5 @@
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
***
***
***

View File

@ -1,3 +1,5 @@
<!-- placeholder for continuous thematic breaks not being treated as yaml -->
****
## foo
****

View File

@ -4,15 +4,15 @@ exports[`list.md 1`] = `
- * * *
+ - - -
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* - - -
* ---
- * * *
- ***
`;
exports[`simple.md 1`] = `
***
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- - -
---
`;