From 2680e80adb56c0a445035c1b75d9e49cb5c62da2 Mon Sep 17 00:00:00 2001 From: Seiya <20365512+seiyab@users.noreply.github.com> Date: Wed, 10 Jun 2026 23:32:38 +0900 Subject: [PATCH] Add regression tests for Markdown (#19335) --- .../__snapshots__/format.test.js.snap | 97 +++++++++ tests/format/markdown/emphasis/issue-15032.md | 7 + tests/format/markdown/emphasis/issue-16160.md | 3 + tests/format/markdown/emphasis/issue-17286.md | 2 + tests/format/markdown/emphasis/issue-3837.md | 2 + tests/format/markdown/emphasis/issue-6112.md | 5 + .../__snapshots__/format.test.js.snap | 41 ++++ .../markdown/fenced-code-block/issue-17300.md | 15 ++ .../__snapshots__/format.test.js.snap | 10 +- .../parser-regression}/format.test.js | 0 .../link/parser-regression/issue-6078.md | 1 + .../__snapshots__/format.test.js.snap | 190 ++++++++++++++++++ .../list/parser-regression/format.test.js | 1 + .../list/parser-regression/issue-10063.md | 33 +++ .../list/parser-regression/issue-11202.md | 8 + .../list/parser-regression/issue-12677.md | 9 + .../issue-19146.md | 0 .../list/parser-regression/issue-19152.md | 2 + .../list/parser-regression/issue-7474.md | 3 + .../math/__snapshots__/format.test.js.snap | 26 +++ tests/format/markdown/math/issue-12793.md | 1 + tests/format/markdown/math/issue-16664.md | 1 + 22 files changed, 450 insertions(+), 7 deletions(-) create mode 100644 tests/format/markdown/emphasis/issue-15032.md create mode 100644 tests/format/markdown/emphasis/issue-16160.md create mode 100644 tests/format/markdown/emphasis/issue-17286.md create mode 100644 tests/format/markdown/emphasis/issue-3837.md create mode 100644 tests/format/markdown/emphasis/issue-6112.md create mode 100644 tests/format/markdown/fenced-code-block/issue-17300.md rename tests/format/markdown/{list/issue-19146 => link/parser-regression}/__snapshots__/format.test.js.snap (77%) rename tests/format/markdown/{list/issue-19146 => link/parser-regression}/format.test.js (100%) create mode 100644 tests/format/markdown/link/parser-regression/issue-6078.md create mode 100644 tests/format/markdown/list/parser-regression/__snapshots__/format.test.js.snap create mode 100644 tests/format/markdown/list/parser-regression/format.test.js create mode 100644 tests/format/markdown/list/parser-regression/issue-10063.md create mode 100644 tests/format/markdown/list/parser-regression/issue-11202.md create mode 100644 tests/format/markdown/list/parser-regression/issue-12677.md rename tests/format/markdown/list/{issue-19146 => parser-regression}/issue-19146.md (100%) create mode 100644 tests/format/markdown/list/parser-regression/issue-19152.md create mode 100644 tests/format/markdown/list/parser-regression/issue-7474.md create mode 100644 tests/format/markdown/math/issue-12793.md create mode 100644 tests/format/markdown/math/issue-16664.md diff --git a/tests/format/markdown/emphasis/__snapshots__/format.test.js.snap b/tests/format/markdown/emphasis/__snapshots__/format.test.js.snap index 7d8dec416..8c269c4b4 100644 --- a/tests/format/markdown/emphasis/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/emphasis/__snapshots__/format.test.js.snap @@ -32,6 +32,103 @@ _bug_? ================================================================================ `; +exports[`issue-3837.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +5 * 10 +a * b * c + +=====================================output===================================== +5 * 10 a * b * c + +================================================================================ +`; + +exports[`issue-6112.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +*[Italic link](../_link_including_underscores_.md)* + +--- + +_[Italic link](../_link_including_underscores_.md)_ + +=====================================output===================================== +_[Italic link](../_link_including_underscores_.md)_ + +--- + +_[Italic link](../_link_including_underscores_.md)_ + +================================================================================ +`; + +exports[`issue-15032.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +1: The **exponentiation (\`**\`)** operator. + +2: The *exponentiation (\`*\`)* operator. + +3: The _exponentiation (\`_\`)_ operator. + +4: The __exponentiation (\`__\`)__ operator. + +=====================================output===================================== +1: The **exponentiation (\`**\`)** operator. + +2: The _exponentiation (\`*\`)_ operator. + +3: The _exponentiation (\`_\`)_ operator. + +4: The **exponentiation (\`__\`)** operator. + +================================================================================ +`; + +exports[`issue-16160.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +- style\\_name = *dplr* +- style\\_name = _dplr_ +- style_name = _dplr_ + +=====================================output===================================== +- style\\_name = _dplr_ +- style\\_name = _dplr_ +- style_name = _dplr_ + +================================================================================ +`; + +exports[`issue-17286.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +Note: With {"NO\\_PROPAGATE"}, the client is expected to honour the {"errors"} in +the _response_ and prevent developers from reading a \`null\` produced by an + +=====================================output===================================== +Note: With {"NO\\_PROPAGATE"}, the client is expected to honour the {"errors"} in +the _response_ and prevent developers from reading a \`null\` produced by an + +================================================================================ +`; + exports[`nbsp.md - {"proseWrap":"always"} format 1`] = ` ====================================options===================================== parsers: ["markdown"] diff --git a/tests/format/markdown/emphasis/issue-15032.md b/tests/format/markdown/emphasis/issue-15032.md new file mode 100644 index 000000000..811f2d71a --- /dev/null +++ b/tests/format/markdown/emphasis/issue-15032.md @@ -0,0 +1,7 @@ +1: The **exponentiation (`**`)** operator. + +2: The *exponentiation (`*`)* operator. + +3: The _exponentiation (`_`)_ operator. + +4: The __exponentiation (`__`)__ operator. diff --git a/tests/format/markdown/emphasis/issue-16160.md b/tests/format/markdown/emphasis/issue-16160.md new file mode 100644 index 000000000..29c42da05 --- /dev/null +++ b/tests/format/markdown/emphasis/issue-16160.md @@ -0,0 +1,3 @@ +- style\_name = *dplr* +- style\_name = _dplr_ +- style_name = _dplr_ diff --git a/tests/format/markdown/emphasis/issue-17286.md b/tests/format/markdown/emphasis/issue-17286.md new file mode 100644 index 000000000..83b7d2942 --- /dev/null +++ b/tests/format/markdown/emphasis/issue-17286.md @@ -0,0 +1,2 @@ +Note: With {"NO\_PROPAGATE"}, the client is expected to honour the {"errors"} in +the _response_ and prevent developers from reading a `null` produced by an diff --git a/tests/format/markdown/emphasis/issue-3837.md b/tests/format/markdown/emphasis/issue-3837.md new file mode 100644 index 000000000..b8a849a29 --- /dev/null +++ b/tests/format/markdown/emphasis/issue-3837.md @@ -0,0 +1,2 @@ +5 * 10 +a * b * c diff --git a/tests/format/markdown/emphasis/issue-6112.md b/tests/format/markdown/emphasis/issue-6112.md new file mode 100644 index 000000000..7649bcf51 --- /dev/null +++ b/tests/format/markdown/emphasis/issue-6112.md @@ -0,0 +1,5 @@ +*[Italic link](../_link_including_underscores_.md)* + +--- + +_[Italic link](../_link_including_underscores_.md)_ diff --git a/tests/format/markdown/fenced-code-block/__snapshots__/format.test.js.snap b/tests/format/markdown/fenced-code-block/__snapshots__/format.test.js.snap index 20b38283f..9eeef0107 100644 --- a/tests/format/markdown/fenced-code-block/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/fenced-code-block/__snapshots__/format.test.js.snap @@ -1,5 +1,46 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing +exports[`issue-17300.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] + printWidth: 80 (default) | +=====================================input====================================== +> [NOTE] +> [Link](https://example.com) after link reference. +> +> [IMPORTANT] +> **Strong emphasis** after link reference. + +> [CRITICAL] +> _emphasis_ oafter link reference + +> **Strong emphasis** +> _emphasis_ + +[NOTE]: /note +[IMPORTANT]: /important +[CRITICAL]: /critical + +=====================================output===================================== +> [NOTE] +> [Link](https://example.com) after link reference. +> +> [IMPORTANT] +> **Strong emphasis** after link reference. + +> [CRITICAL] +> _emphasis_ oafter link reference + +> **Strong emphasis** +> _emphasis_ + +[NOTE]: /note +[IMPORTANT]: /important +[CRITICAL]: /critical + +================================================================================ +`; + exports[`snippet: #0 format 1`] = ` ====================================options===================================== parsers: ["markdown"] diff --git a/tests/format/markdown/fenced-code-block/issue-17300.md b/tests/format/markdown/fenced-code-block/issue-17300.md new file mode 100644 index 000000000..43a658734 --- /dev/null +++ b/tests/format/markdown/fenced-code-block/issue-17300.md @@ -0,0 +1,15 @@ +> [NOTE] +> [Link](https://example.com) after link reference. +> +> [IMPORTANT] +> **Strong emphasis** after link reference. + +> [CRITICAL] +> _emphasis_ oafter link reference + +> **Strong emphasis** +> _emphasis_ + +[NOTE]: /note +[IMPORTANT]: /important +[CRITICAL]: /critical diff --git a/tests/format/markdown/list/issue-19146/__snapshots__/format.test.js.snap b/tests/format/markdown/link/parser-regression/__snapshots__/format.test.js.snap similarity index 77% rename from tests/format/markdown/list/issue-19146/__snapshots__/format.test.js.snap rename to tests/format/markdown/link/parser-regression/__snapshots__/format.test.js.snap index ed6f59d62..c49826470 100644 --- a/tests/format/markdown/list/issue-19146/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/link/parser-regression/__snapshots__/format.test.js.snap @@ -1,19 +1,15 @@ // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing -exports[`issue-19146.md - {"proseWrap":"always"} format 1`] = ` +exports[`issue-6078.md - {"proseWrap":"always"} format 1`] = ` ====================================options===================================== parsers: ["markdown"] proseWrap: "always" printWidth: 80 (default) | =====================================input====================================== - - foo - - bar - - baz +[](http://example.com/path?a=1&b=2&c=3) =====================================output===================================== -- foo - - bar - - baz +[](http://example.com/path?a=1&b=2&c=3) ================================================================================ `; diff --git a/tests/format/markdown/list/issue-19146/format.test.js b/tests/format/markdown/link/parser-regression/format.test.js similarity index 100% rename from tests/format/markdown/list/issue-19146/format.test.js rename to tests/format/markdown/link/parser-regression/format.test.js diff --git a/tests/format/markdown/link/parser-regression/issue-6078.md b/tests/format/markdown/link/parser-regression/issue-6078.md new file mode 100644 index 000000000..910494a48 --- /dev/null +++ b/tests/format/markdown/link/parser-regression/issue-6078.md @@ -0,0 +1 @@ +[](http://example.com/path?a=1&b=2&c=3) diff --git a/tests/format/markdown/list/parser-regression/__snapshots__/format.test.js.snap b/tests/format/markdown/list/parser-regression/__snapshots__/format.test.js.snap new file mode 100644 index 000000000..ff12ac2aa --- /dev/null +++ b/tests/format/markdown/list/parser-regression/__snapshots__/format.test.js.snap @@ -0,0 +1,190 @@ +// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing + +exports[`issue-7474.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +1. - XXX + - XXX +2. XXX + +=====================================output===================================== +1. - XXX + - XXX +2. XXX + +================================================================================ +`; + +exports[`issue-10063.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +# Example 1 (compact list with code block) + +- Sibling item before +- A bullet point with bare text (not in a \`

\`), followed by a code block that includes an empty line + \`\`\`javascript + const foo = "bar"; + + console.log(foo); + \`\`\` +- Sibling item after + +# Example 2 (compact nested list with code block) + +- Parent bullet point which is not wrapped in \`

\` + - Sibling item before + - Item containing a code block that includes an empty line + \`\`\`javascript + const foo = "bar"; + + console.log(foo); + \`\`\` + - Sibling item after + +# Example 3 (like example 2, but doesn't trigger the bug) + +- It works as expected + - If the code block + - Does not have a line break + \`\`\`javascript + const foo = "bar"; + console.log(foo); + \`\`\` + - It doesn't affect other items + +=====================================output===================================== +# Example 1 (compact list with code block) + +- Sibling item before +- A bullet point with bare text (not in a \`

\`), followed by a code block that + includes an empty line + \`\`\`javascript + const foo = "bar"; + + console.log(foo); + \`\`\` +- Sibling item after + +# Example 2 (compact nested list with code block) + +- Parent bullet point which is not wrapped in \`

\` + - Sibling item before + - Item containing a code block that includes an empty line + \`\`\`javascript + const foo = "bar"; + + console.log(foo); + \`\`\` + - Sibling item after + +# Example 3 (like example 2, but doesn't trigger the bug) + +- It works as expected + - If the code block + - Does not have a line break + \`\`\`javascript + const foo = "bar"; + console.log(foo); + \`\`\` + - It doesn't affect other items + +================================================================================ +`; + +exports[`issue-11202.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +\`\`\`markdown + + +- +- +- +\`\`\` + + +=====================================output===================================== +\`\`\`markdown + + + +- +- +- +\`\`\` + +================================================================================ +`; + +exports[`issue-12677.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +5.1 **Section 1** + +- apple +- banana +- cherry + +5.2 **Section 2** + +Why is this section indented? + +=====================================output===================================== +5.1 **Section 1** + +- apple +- banana +- cherry + +5.2 **Section 2** + +Why is this section indented? + +================================================================================ +`; + +exports[`issue-19146.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== + - foo + - bar + - baz + +=====================================output===================================== +- foo + - bar + - baz + +================================================================================ +`; + +exports[`issue-19152.md - {"proseWrap":"always"} format 1`] = ` +====================================options===================================== +parsers: ["markdown"] +proseWrap: "always" + printWidth: 80 (default) | +=====================================input====================================== +- foo +- foo + +=====================================output===================================== +- foo +- foo + +================================================================================ +`; diff --git a/tests/format/markdown/list/parser-regression/format.test.js b/tests/format/markdown/list/parser-regression/format.test.js new file mode 100644 index 000000000..6ecc0af19 --- /dev/null +++ b/tests/format/markdown/list/parser-regression/format.test.js @@ -0,0 +1 @@ +runFormatTest(import.meta, ["markdown"], { proseWrap: "always" }); diff --git a/tests/format/markdown/list/parser-regression/issue-10063.md b/tests/format/markdown/list/parser-regression/issue-10063.md new file mode 100644 index 000000000..d4811a231 --- /dev/null +++ b/tests/format/markdown/list/parser-regression/issue-10063.md @@ -0,0 +1,33 @@ +# Example 1 (compact list with code block) + +- Sibling item before +- A bullet point with bare text (not in a `

`), followed by a code block that includes an empty line + ```javascript + const foo = "bar"; + + console.log(foo); + ``` +- Sibling item after + +# Example 2 (compact nested list with code block) + +- Parent bullet point which is not wrapped in `

` + - Sibling item before + - Item containing a code block that includes an empty line + ```javascript + const foo = "bar"; + + console.log(foo); + ``` + - Sibling item after + +# Example 3 (like example 2, but doesn't trigger the bug) + +- It works as expected + - If the code block + - Does not have a line break + ```javascript + const foo = "bar"; + console.log(foo); + ``` + - It doesn't affect other items diff --git a/tests/format/markdown/list/parser-regression/issue-11202.md b/tests/format/markdown/list/parser-regression/issue-11202.md new file mode 100644 index 000000000..d32b55134 --- /dev/null +++ b/tests/format/markdown/list/parser-regression/issue-11202.md @@ -0,0 +1,8 @@ +```markdown + + +- +- +- +``` + diff --git a/tests/format/markdown/list/parser-regression/issue-12677.md b/tests/format/markdown/list/parser-regression/issue-12677.md new file mode 100644 index 000000000..afb3583cb --- /dev/null +++ b/tests/format/markdown/list/parser-regression/issue-12677.md @@ -0,0 +1,9 @@ +5.1 **Section 1** + +- apple +- banana +- cherry + +5.2 **Section 2** + +Why is this section indented? diff --git a/tests/format/markdown/list/issue-19146/issue-19146.md b/tests/format/markdown/list/parser-regression/issue-19146.md similarity index 100% rename from tests/format/markdown/list/issue-19146/issue-19146.md rename to tests/format/markdown/list/parser-regression/issue-19146.md diff --git a/tests/format/markdown/list/parser-regression/issue-19152.md b/tests/format/markdown/list/parser-regression/issue-19152.md new file mode 100644 index 000000000..6aec61c00 --- /dev/null +++ b/tests/format/markdown/list/parser-regression/issue-19152.md @@ -0,0 +1,2 @@ +- foo +- foo diff --git a/tests/format/markdown/list/parser-regression/issue-7474.md b/tests/format/markdown/list/parser-regression/issue-7474.md new file mode 100644 index 000000000..fd20fd78f --- /dev/null +++ b/tests/format/markdown/list/parser-regression/issue-7474.md @@ -0,0 +1,3 @@ +1. - XXX + - XXX +2. XXX diff --git a/tests/format/markdown/math/__snapshots__/format.test.js.snap b/tests/format/markdown/math/__snapshots__/format.test.js.snap index 734bbe116..291f12842 100644 --- a/tests/format/markdown/math/__snapshots__/format.test.js.snap +++ b/tests/format/markdown/math/__snapshots__/format.test.js.snap @@ -40,6 +40,32 @@ $$ ================================================================================ `; +exports[`issue-12793.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] + printWidth: 80 (default) | +=====================================input====================================== +$ P\\Big(\\mathop{\\cup}\\limits^n_{i=1}A_i\\Big) = \\sum\\limits^n_{i=1}P(A_i) $ + +=====================================output===================================== +$ P\\Big(\\mathop{\\cup}\\limits^n_{i=1}A_i\\Big) = \\sum\\limits^n_{i=1}P(A_i) $ + +================================================================================ +`; + +exports[`issue-16664.md format 1`] = ` +====================================options===================================== +parsers: ["markdown"] + printWidth: 80 (default) | +=====================================input====================================== +$$ \\textrm{p-value} = 1 - \\sum_{x \\leq a} H(x | N, r_1, m_1) $$ + +=====================================output===================================== +$$ \\textrm{p-value} = 1 - \\sum_{x \\leq a} H(x | N, r_1, m_1) $$ + +================================================================================ +`; + exports[`math-like.md format 1`] = ` ====================================options===================================== parsers: ["markdown"] diff --git a/tests/format/markdown/math/issue-12793.md b/tests/format/markdown/math/issue-12793.md new file mode 100644 index 000000000..5c1c21e20 --- /dev/null +++ b/tests/format/markdown/math/issue-12793.md @@ -0,0 +1 @@ +$ P\Big(\mathop{\cup}\limits^n_{i=1}A_i\Big) = \sum\limits^n_{i=1}P(A_i) $ diff --git a/tests/format/markdown/math/issue-16664.md b/tests/format/markdown/math/issue-16664.md new file mode 100644 index 000000000..5134ff275 --- /dev/null +++ b/tests/format/markdown/math/issue-16664.md @@ -0,0 +1 @@ +$$ \textrm{p-value} = 1 - \sum_{x \leq a} H(x | N, r_1, m_1) $$