Fix Markdown task list indentation drift (#19647)
# Conflicts: # tests/format/markdown/list/__snapshots__/format.test.js.snap
This commit is contained in:
1 parent
2158d480ab
commit
9ef216d6f3
4 files changed
+118
-10
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#### Prevent indentation drift in task-list code blocks (#19647 by @Austin1serb)
|
||||
|
||||
Indented code blocks inside task-list items no longer gain four spaces on each formatting pass.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
<!-- Prettier stable -->
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
<!-- Prettier main -->
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
```
|
||||
@@ -99,10 +99,7 @@ function printListItem(path, options, print, listPrefix) {
|
||||
prefix,
|
||||
printChildren(path, options, print, {
|
||||
processor({ node, isFirst }) {
|
||||
if (
|
||||
(isFirst && node.type !== "list") ||
|
||||
(node.type === "code" && node.isIndented)
|
||||
) {
|
||||
if (isFirst && node.type !== "list") {
|
||||
return align(" ".repeat(prefix.length), print());
|
||||
}
|
||||
|
||||
|
||||
@@ -1480,7 +1480,7 @@ tabWidth: 4
|
||||
|
||||
- foo
|
||||
|
||||
indented code block in bullet
|
||||
indented code block in bullet
|
||||
|
||||
---
|
||||
|
||||
@@ -1516,7 +1516,7 @@ tabWidth: 4
|
||||
|
||||
- [ ] foo
|
||||
|
||||
indented code block in checkbox item
|
||||
indented code block in checkbox item
|
||||
|
||||
---
|
||||
|
||||
@@ -1758,7 +1758,7 @@ tabWidth: 999
|
||||
|
||||
- foo
|
||||
|
||||
indented code block in bullet
|
||||
indented code block in bullet
|
||||
|
||||
---
|
||||
|
||||
@@ -1782,7 +1782,7 @@ tabWidth: 999
|
||||
|
||||
1. foo
|
||||
|
||||
indented code block in numbered item
|
||||
indented code block in numbered item
|
||||
|
||||
---
|
||||
|
||||
@@ -1794,7 +1794,7 @@ tabWidth: 999
|
||||
|
||||
- [ ] foo
|
||||
|
||||
indented code block in checkbox item
|
||||
indented code block in checkbox item
|
||||
|
||||
---
|
||||
|
||||
@@ -1861,7 +1861,7 @@ tabWidth: 999
|
||||
- item 1-1
|
||||
- item 1-2
|
||||
|
||||
indented code block
|
||||
indented code block
|
||||
|
||||
top level indented code block
|
||||
|
||||
@@ -4092,6 +4092,89 @@ proseWrap: "always"
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19644.md - {"proseWrap":"always","tabWidth":0} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
proseWrap: "always"
|
||||
tabWidth: 0
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
=====================================output=====================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19644.md - {"proseWrap":"always","tabWidth":4} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
proseWrap: "always"
|
||||
tabWidth: 4
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
=====================================output=====================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19644.md - {"proseWrap":"always","tabWidth":999} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
proseWrap: "always"
|
||||
tabWidth: 999
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
=====================================output=====================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19644.md - {"proseWrap":"always"} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
proseWrap: "always"
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
=====================================output=====================================
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`long-paragraph.md - {"proseWrap":"always","tabWidth":0} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
- [x] short first line.
|
||||
|
||||
second paragraph at six spaces that wraps
|
||||
onto another line here.
|
||||
Reference in new issue
Block a user