fix(markdown): force print spaces (#3225)

master
Ika 2017-11-11 15:05:07 +08:00 committed by GitHub
parent 49f578fb91
commit 92459047ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 5 deletions

View File

@ -41,7 +41,7 @@ function makeAlign(ind, n) {
indent: ind.indent,
align: {
spaces: ind.align.spaces + (typeof n === "number" ? " ".repeat(n) : n),
tabs: ind.align.tabs + (n ? "\t" : "")
tabs: ind.align.tabs + (typeof n === "number" ? (n ? "\t" : "") : n)
}
};
}

View File

@ -186,9 +186,10 @@ function genericPrint(path, options, print) {
)
) {
// indented code block
const alignment = " ".repeat(4);
return align(
4,
concat([" ".repeat(4), join(hardline, node.value.split("\n"))])
alignment,
concat([alignment, join(hardline, node.value.split("\n"))])
);
}
@ -239,7 +240,10 @@ function genericPrint(path, options, print) {
: isGitDiffFriendlyOrderedList ? 1 : node.start + index) +
(nthSiblingIndex % 2 === 0 ? ". " : ") ")
: nthSiblingIndex % 2 === 0 ? "* " : "- ";
return concat([prefix, align(prefix.length, childPath.call(print))]);
return concat([
prefix,
align(" ".repeat(prefix.length), childPath.call(print))
]);
}
});
}
@ -248,7 +252,7 @@ function genericPrint(path, options, print) {
node.checked === null ? "" : node.checked ? "[x] " : "[ ] ";
return concat([
prefix,
align(prefix.length, printChildren(path, options, print))
align(" ".repeat(prefix.length), printChildren(path, options, print))
]);
}
case "thematicBreak": {

View File

@ -0,0 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`example.md 1`] = `
- Top level list item 1
- Top level list item 2
- Nested List item 1
- Nested List item 2
- Sub-Nested List item 1
- Sub-Nested List item 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Top level list item 1
* Top level list item 2
* Nested List item 1
* Nested List item 2
* Sub-Nested List item 1
* Sub-Nested List item 2
`;

View File

@ -0,0 +1,6 @@
- Top level list item 1
- Top level list item 2
- Nested List item 1
- Nested List item 2
- Sub-Nested List item 1
- Sub-Nested List item 2

View File

@ -0,0 +1 @@
run_spec(__dirname, { parser: "markdown", useTabs: true });