From e58ccfba65a568315747ccab192e1dbedabc37fe Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:13:52 +0530 Subject: [PATCH 1/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- src/rules.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/rules.ts b/src/rules.ts index 601c598a8c..1020d19acc 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -144,27 +144,27 @@ const _htmlInterrupt = edit(' {0,3}(?:)|<(?:(?:scrip // The underline may end with spaces or tabs (CommonMark ยง4.3). Internal // spaces or tabs still fail to match, and more than three spaces of indent // still do not. -const lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/; -const lheading = edit(lheadingCore) - .replace(/bull/g, bullet) // lists can interrupt +const lheadingCore = /^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|listInterrupt|fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/; +const createLheading = (listInterrupt: RegExp) => edit(lheadingCore) + .replace('listInterrupt', listInterrupt) + .replace(/bull/g, bullet) // a list can start a block with any number .replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code can start a block but cannot interrupt a paragraph .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt .replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/) // ATX heading can interrupt - .replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/) // thematic break can interrupt + .replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/); // thematic break can interrupt +const lheading = createLheading(other.listInterruptsParagraph) .replace(/\|table/g, '') // table not in commonmark .replace(/html/g, _htmlInterrupt) // block html of types (1) to (6) can interrupt .getRegex(); -const lheadingGfm = edit(lheadingCore) - .replace(/bull/g, bullet) // lists can interrupt - .replace(/blockCode/g, /(?: {4}| {0,3}\t)/) // indented code can start a block but cannot interrupt a paragraph - .replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/) // fenced code blocks can interrupt - .replace(/blockquote/g, / {0,3}>/) // blockquote can interrupt - .replace(/heading/g, / {0,3}#{1,6}(?:\s|$)/) // ATX heading can interrupt - .replace(/hr/g, / {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/) // thematic break can interrupt +const lheadingGfm = createLheading(other.listInterruptsParagraph) .replace(/table/g, / {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/) // table can interrupt .replace(/html/g, _htmlInterrupt) // block html of types (1) to (6) can interrupt .getRegex(); +const lheadingPedantic = createLheading(edit(/bull /).replace('bull', bullet).getRegex()) + .replace(/\|table/g, '') + .replace(/html/g, _htmlInterrupt) + .getRegex(); const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/; const blockText = /^[^\n]+/; const _blockLabel = /(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/; @@ -303,7 +303,7 @@ const blockPedantic: Record = { .replace('|list', '') .replace('|html', '') .replace('|tag', '') - .replace('lheading', lheading) // last, so the replacements above do not match inside it + .replace('lheading', lheadingPedantic) // last, so the replacements above do not match inside it .getRegex(), }; From 8c181ea265b1681f990c33be3b86f4e49bcc98c9 Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:14:27 +0530 Subject: [PATCH 2/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- test/specs/new/setext_noninterrupting_list.md | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/specs/new/setext_noninterrupting_list.md diff --git a/test/specs/new/setext_noninterrupting_list.md b/test/specs/new/setext_noninterrupting_list.md new file mode 100644 index 0000000000..455268c0c2 --- /dev/null +++ b/test/specs/new/setext_noninterrupting_list.md @@ -0,0 +1,52 @@ +a +2. b +=== + +a +0) b +--- + +a +123456789. b +=== + +a +2. b +=== + +a ++ +=== + +a +1. +=== + +a +1. b +=== + +2. b +=== + +a +- b +=== + +a +2. b + +=== + +a + +=== + +a +2. b +--- + +a +2. b +c +=== From 60dd69f4594fdd9934ea00d465ece58daf434dcb Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:14:48 +0530 Subject: [PATCH 3/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- .../new/setext_noninterrupting_list.html | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/specs/new/setext_noninterrupting_list.html diff --git a/test/specs/new/setext_noninterrupting_list.html b/test/specs/new/setext_noninterrupting_list.html new file mode 100644 index 0000000000..c5c88111dd --- /dev/null +++ b/test/specs/new/setext_noninterrupting_list.html @@ -0,0 +1,39 @@ +

a +2. b

+

a +0) b

+

a +123456789. b

+

a +2. b

+

a ++

+

a +1.

+

a

+
    +
  1. +

    b +===

    +
  2. +
  3. +

    b +===

    +
  4. +
+

a

+ +

a +2. b

+

===

+

a

+
+=== +

a +2. b

+

a +2. b +c

From 434ddc7cebcef2669768f14097a355eaf869b5db Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:15:11 +0530 Subject: [PATCH 4/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- .../new/setext_noninterrupting_list_normal.md | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/specs/new/setext_noninterrupting_list_normal.md diff --git a/test/specs/new/setext_noninterrupting_list_normal.md b/test/specs/new/setext_noninterrupting_list_normal.md new file mode 100644 index 0000000000..5baddefcd4 --- /dev/null +++ b/test/specs/new/setext_noninterrupting_list_normal.md @@ -0,0 +1,55 @@ +--- +gfm: false +--- +a +2. b +=== + +a +0) b +--- + +a +123456789. b +=== + +a +2. b +=== + +a ++ +=== + +a +1. +=== + +a +1. b +=== + +2. b +=== + +a +- b +=== + +a +2. b + +=== + +a +
+=== + +a +2. b +--- + +a +2. b +c +=== From 44c462f95d1ddf55f2123da81d8eb552969914cc Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:15:32 +0530 Subject: [PATCH 5/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- .../setext_noninterrupting_list_normal.html | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/specs/new/setext_noninterrupting_list_normal.html diff --git a/test/specs/new/setext_noninterrupting_list_normal.html b/test/specs/new/setext_noninterrupting_list_normal.html new file mode 100644 index 0000000000..c5c88111dd --- /dev/null +++ b/test/specs/new/setext_noninterrupting_list_normal.html @@ -0,0 +1,39 @@ +

a +2. b

+

a +0) b

+

a +123456789. b

+

a +2. b

+

a ++

+

a +1.

+

a

+
    +
  1. +

    b +===

    +
  2. +
  3. +

    b +===

    +
  4. +
+

a

+ +

a +2. b

+

===

+

a

+
+=== +

a +2. b

+

a +2. b +c

From 14a441f42d665facac17b540dfb9945a92d7106c Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:15:53 +0530 Subject: [PATCH 6/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- .../specs/new/setext_noninterrupting_list_pedantic.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/specs/new/setext_noninterrupting_list_pedantic.md diff --git a/test/specs/new/setext_noninterrupting_list_pedantic.md b/test/specs/new/setext_noninterrupting_list_pedantic.md new file mode 100644 index 0000000000..26ece5eb61 --- /dev/null +++ b/test/specs/new/setext_noninterrupting_list_pedantic.md @@ -0,0 +1,11 @@ +--- +pedantic: true +renderExact: true +--- +a +2. b +=== + +a ++ +=== From c86c96e156a554dbb8257a8bd56e8d21460d2904 Mon Sep 17 00:00:00 2001 From: generaltony007 <191973953+hakarrr@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:16:30 +0530 Subject: [PATCH 7/9] fix: preserve noninterrupting list text in setext headings Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- test/specs/new/setext_noninterrupting_list_pedantic.html | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 test/specs/new/setext_noninterrupting_list_pedantic.html diff --git a/test/specs/new/setext_noninterrupting_list_pedantic.html b/test/specs/new/setext_noninterrupting_list_pedantic.html new file mode 100644 index 0000000000..0aa604c74d --- /dev/null +++ b/test/specs/new/setext_noninterrupting_list_pedantic.html @@ -0,0 +1,8 @@ +

a +2. b +===

+

a

+ +

===

From 1a75f7d3bce772ef6659303feb4df53da972ad1d Mon Sep 17 00:00:00 2001 From: simple-minded <191973953+hakarrr@users.noreply.github.com> Date: Sat, 28 Nov 2026 17:19:44 +0530 Subject: [PATCH 8/9] test: remove redundant normal-mode fixture Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- .../setext_noninterrupting_list_normal.html | 39 ------------------- 1 file changed, 39 deletions(-) delete mode 100644 test/specs/new/setext_noninterrupting_list_normal.html diff --git a/test/specs/new/setext_noninterrupting_list_normal.html b/test/specs/new/setext_noninterrupting_list_normal.html deleted file mode 100644 index c5c88111dd..0000000000 --- a/test/specs/new/setext_noninterrupting_list_normal.html +++ /dev/null @@ -1,39 +0,0 @@ -

a -2. b

-

a -0) b

-

a -123456789. b

-

a -2. b

-

a -+

-

a -1.

-

a

-
    -
  1. -

    b -===

    -
  2. -
  3. -

    b -===

    -
  4. -
-

a

- -

a -2. b

-

===

-

a

-
-=== -

a -2. b

-

a -2. b -c

From 79efd69979364d7bc84e59a44bdc92cb853f7756 Mon Sep 17 00:00:00 2001 From: simple-minded <191973953+hakarrr@users.noreply.github.com> Date: Sat, 28 Nov 2026 17:20:03 +0530 Subject: [PATCH 9/9] test: remove redundant fixture setext_noninterrupting_list_normal.md Co-authored-by: GeneralTony007 <144252170+GeneralTony007@users.noreply.github.com> --- .../new/setext_noninterrupting_list_normal.md | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 test/specs/new/setext_noninterrupting_list_normal.md diff --git a/test/specs/new/setext_noninterrupting_list_normal.md b/test/specs/new/setext_noninterrupting_list_normal.md deleted file mode 100644 index 5baddefcd4..0000000000 --- a/test/specs/new/setext_noninterrupting_list_normal.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -gfm: false ---- -a -2. b -=== - -a -0) b ---- - -a -123456789. b -=== - -a -2. b -=== - -a -+ -=== - -a -1. -=== - -a -1. b -=== - -2. b -=== - -a -- b -=== - -a -2. b - -=== - -a -
-=== - -a -2. b ---- - -a -2. b -c -===