From d97a3ce3604b838b3a04ae5ebf3c962f8a18a2b4 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Wed, 7 Oct 2026 20:14:16 +0200 Subject: [PATCH] fix: allow a tab or end of input after a type 6 html block tag name the type 6 html block start only accepted spaces, a newline, > or /> after the tag name. commonmark 0.31.2 also allows a tab and the end of the line, which includes the end of the input. --- src/rules.ts | 2 +- .../specs/new/html_block_tab_after_tag_name.html | 15 +++++++++++++++ test/specs/new/html_block_tab_after_tag_name.md | 16 ++++++++++++++++ .../new/html_block_tag_at_end_of_input.html | 2 ++ test/specs/new/html_block_tag_at_end_of_input.md | 3 +++ 5 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/html_block_tab_after_tag_name.html create mode 100644 test/specs/new/html_block_tab_after_tag_name.md create mode 100644 test/specs/new/html_block_tag_at_end_of_input.html create mode 100644 test/specs/new/html_block_tag_at_end_of_input.md diff --git a/src/rules.ts b/src/rules.ts index 81da76a..2ae1b68 100644 --- a/src/rules.ts +++ b/src/rules.ts @@ -162,7 +162,7 @@ const html = edit( + '|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)' // (3) + '|[^\\n]*\\n*|$)' // (4) + '|[^\\n]*\\n*|$)' // (5) -+ '|)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6) ++ '||$)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6) + '|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag + '|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag + ')', 'i') diff --git a/test/specs/new/html_block_tab_after_tag_name.html b/test/specs/new/html_block_tab_after_tag_name.html new file mode 100644 index 0000000..536dd7f --- /dev/null +++ b/test/specs/new/html_block_tab_after_tag_name.html @@ -0,0 +1,15 @@ +
+*stays raw* +
+
+*stays raw* +
+
+*stays raw* +
+
+
+*stays raw* +
+
diff --git a/test/specs/new/html_block_tab_after_tag_name.md b/test/specs/new/html_block_tab_after_tag_name.md new file mode 100644 index 0000000..85d6aae --- /dev/null +++ b/test/specs/new/html_block_tab_after_tag_name.md @@ -0,0 +1,16 @@ +
+*stays raw* +
+ +
+*stays raw* +
+ +
+*stays raw* +
+ +>
+> *stays raw* +>
diff --git a/test/specs/new/html_block_tag_at_end_of_input.html b/test/specs/new/html_block_tag_at_end_of_input.html new file mode 100644 index 0000000..3f54666 --- /dev/null +++ b/test/specs/new/html_block_tag_at_end_of_input.html @@ -0,0 +1,2 @@ +

Paragraph

+