Fix HTML block indentation drift in markdown list items (#19987)
Co-authored-by: fisker Cheung <lionkay@gmail.com>
This commit is contained in:
1 parent
0df4e49f14
commit
297117ab77
6 files changed
+157
-1
No files matched your search
@@ -0,0 +1,25 @@
|
||||
#### Fix HTML block indentation drift in markdown list items (#19987 by @lazerg)
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```markdown
|
||||
<!-- Input -->
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
<!-- Prettier stable (--tab-width=4) -->
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
<!-- Prettier main (--tab-width=4) -->
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
```
|
||||
@@ -99,7 +99,7 @@ function printListItem(path, options, print, listPrefix) {
|
||||
prefix,
|
||||
printChildren(path, options, print, {
|
||||
processor({ node, isFirst }) {
|
||||
if (isFirst && node.type !== "list") {
|
||||
if ((isFirst && node.type !== "list") || node.type === "html") {
|
||||
return align(" ".repeat(prefix.length), print());
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`issue-19986.md - {"tabWidth":4} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
tabWidth: 4
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
1. Enable images:
|
||||
|
||||
\`\`\`json
|
||||
{}
|
||||
\`\`\`
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
2. Continue.
|
||||
|
||||
=====================================output=====================================
|
||||
1. Enable images:
|
||||
|
||||
\`\`\`json
|
||||
{}
|
||||
\`\`\`
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
2. Continue.
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19986.md format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
1. Enable images:
|
||||
|
||||
\`\`\`json
|
||||
{}
|
||||
\`\`\`
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
2. Continue.
|
||||
|
||||
=====================================output=====================================
|
||||
1. Enable images:
|
||||
|
||||
\`\`\`json
|
||||
{}
|
||||
\`\`\`
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
2. Continue.
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19986-uneven-indent.md - {"tabWidth":4} format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
tabWidth: 4
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
=====================================output=====================================
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
|
||||
exports[`issue-19986-uneven-indent.md format 1`] = `
|
||||
====================================options=====================================
|
||||
parsers: ["markdown"]
|
||||
printWidth: 80 (default) |
|
||||
=====================================input======================================
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
=====================================output=====================================
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
================================================================================
|
||||
`;
|
||||
@@ -0,0 +1,2 @@
|
||||
runFormatTest(import.meta, ["markdown"], { tabWidth: 4 });
|
||||
runFormatTest(import.meta, ["markdown"]);
|
||||
@@ -0,0 +1,5 @@
|
||||
1. Enable images:
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
@@ -0,0 +1,11 @@
|
||||
1. Enable images:
|
||||
|
||||
```json
|
||||
{}
|
||||
```
|
||||
|
||||
<p align="center">
|
||||
<img alt="example">
|
||||
</p>
|
||||
|
||||
2. Continue.
|
||||
Reference in new issue
Block a user