fix(markdown): list prefix alignment: count spaces from correct place (#4041)
* test: add tests * fix(markdown): list prefix alignment: count spaces from correct place * docs: codeblock -> code blockmaster
parent
ca81bef73e
commit
b6c27893cc
|
@ -357,7 +357,7 @@ function printListItem(path, options, print, listPrefix) {
|
|||
}
|
||||
|
||||
const alignment = " ".repeat(
|
||||
clamp(options.tabWidth - listPrefix.length, 0, 3) // 4 will cause indented codeblock
|
||||
clamp(options.tabWidth - listPrefix.length, 0, 3) // 4+ will cause indented code block
|
||||
);
|
||||
return concat([alignment, align(alignment, childPath.call(print))]);
|
||||
}
|
||||
|
@ -366,12 +366,11 @@ function printListItem(path, options, print, listPrefix) {
|
|||
}
|
||||
|
||||
function alignListPrefix(prefix, options) {
|
||||
const prefixTrailingSpaces = prefix.match(/ *$/)[0].length;
|
||||
const additionalSpaces = getAdditionalSpaces();
|
||||
return (
|
||||
prefix +
|
||||
" ".repeat(
|
||||
prefixTrailingSpaces + additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
|
||||
additionalSpaces >= 4 ? 0 : additionalSpaces // 4+ will cause indented code block
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -1,5 +1,161 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`align.md 1`] = `
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
|
||||
`;
|
||||
|
||||
exports[`align.md 2`] = `
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
|
||||
`;
|
||||
|
||||
exports[`align.md 3`] = `
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
|
||||
`;
|
||||
|
||||
exports[`align.md 4`] = `
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
||||
|
||||
`;
|
||||
|
||||
exports[`checkbox.md 1`] = `
|
||||
- [ ] this is a long long long long long long long long long long long long long long paragraph.
|
||||
- [x] this is a long long long long long long long long long long long long long long paragraph.
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
1. 123
|
||||
|
||||
---
|
||||
|
||||
11. 123
|
||||
|
||||
---
|
||||
|
||||
111. 123
|
||||
|
||||
---
|
||||
|
||||
1111. 123
|
||||
|
||||
---
|
||||
|
||||
11111. 123
|
Loading…
Reference in New Issue