From bcc3067087b60a2913938d0bca77a71dacc06ba2 Mon Sep 17 00:00:00 2001 From: Tony Brix Date: Fri, 15 Sep 2023 13:22:12 -0600 Subject: [PATCH] fix: fix unexpected setext heading (#2986) --- src/rules.ts | 2 +- test/specs/new/setext_blankline.html | 9 +++++++++ test/specs/new/setext_blankline.md | 11 +++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/setext_blankline.html create mode 100644 test/specs/new/setext_blankline.md diff --git a/src/rules.ts b/src/rules.ts index 1c6fda259f..c49fb8328a 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -87,7 +87,7 @@ export const block: Record & Record)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/, table: noopTest, - lheading: /^((?:(?!^bull ).|\n(?!\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, + lheading: /^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/, // regex template, placeholders will be replaced according to different paragraph // interruption rules of commonmark and the original markdown spec: _paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/, diff --git a/test/specs/new/setext_blankline.html b/test/specs/new/setext_blankline.html new file mode 100644 index 0000000000..1b3ebc2c87 --- /dev/null +++ b/test/specs/new/setext_blankline.html @@ -0,0 +1,9 @@ +

a

+

b

+

=

+ +

a

+

b

+
    +
  • +
diff --git a/test/specs/new/setext_blankline.md b/test/specs/new/setext_blankline.md new file mode 100644 index 0000000000..7214ac6298 --- /dev/null +++ b/test/specs/new/setext_blankline.md @@ -0,0 +1,11 @@ +a + +b + += + +a + +b + +-