fix(markdown): stably print lists in front of whitespace-only trailing newline (#5024)

master
Ika 2018-09-01 12:14:53 +08:00 committed by GitHub
parent 55e620bdc7
commit 669282e32a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 112 additions and 1 deletions

View File

@ -379,7 +379,8 @@ const baseParser = {
astFormat: "mdast",
hasPragma: pragma.hasPragma,
locStart: node => node.position.start.offset,
locEnd: node => node.position.end.offset
locEnd: node => node.position.end.offset,
preprocess: text => text.replace(/\n\s+$/, "\n") // workaround for https://github.com/remarkjs/remark/issues/350
};
const markdownParser = Object.assign({}, baseParser, {

View File

@ -98,6 +98,82 @@ markdown\`
`;
exports[`issue-5021.js - babylon-verify 1`] = `
if (true) {
md\`
text1
- 123
- 456
text2
- 123
- 456
text3
- 123
- 456
\`;
}
if (true) {
md\`
text1
- 123
- 456
text2
- 123
- 456
text3
- 123
- 456
\`;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (true) {
md\`
text1
- 123
- 456
text2
- 123
- 456
text3
- 123
- 456
\`;
}
if (true) {
md\`
text1
- 123
- 456
text2
- 123
- 456
text3
- 123
- 456
\`;
}
`;
exports[`markdown.js - babylon-verify 1`] = `
export default function ReadMe() {
return md\`

View File

@ -0,0 +1,34 @@
if (true) {
md`
text1
- 123
- 456
text2
- 123
- 456
text3
- 123
- 456
`;
}
if (true) {
md`
text1
- 123
- 456
text2
- 123
- 456
text3
- 123
- 456
`;
}