fix: keep trailing text on HTML block close line for PI, declarations, and CDATA (#3991)

This commit is contained in:
Sarath Francis
2026-06-29 22:22:43 -06:00
committed by GitHub
parent d2af54e661
commit bbb84c88cf
3 changed files with 20 additions and 3 deletions
+3 -3
View File
@@ -151,9 +151,9 @@ const html = edit(
'^ {0,3}(?:' // optional indentation
+ '<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
+ '|comment[^\\n]*(\\n+|$)' // (2)
+ '|<\\?[\\s\\S]*?(?:\\?>\\n*|$)' // (3)
+ '|<![A-Z][\\s\\S]*?(?:>\\n*|$)' // (4)
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)' // (5)
+ '|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n+|$)' // (3)
+ '|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n+|$)' // (4)
+ '|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n+|$)' // (5)
+ '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (6)
+ '|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) open tag
+ '|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)' // (7) closing tag
@@ -0,0 +1,6 @@
<?php echo '>'; ?>*not emphasis*
<p><em>emphasis</em></p>
<!DOCTYPE html>*not emphasis*
<p><em>emphasis</em></p>
<![CDATA[ raw ]]>*not emphasis*
<p><em>emphasis</em></p>
@@ -0,0 +1,11 @@
---
gfm: false
---
<?php echo '>'; ?>*not emphasis*
*emphasis*
<!DOCTYPE html>*not emphasis*
*emphasis*
<![CDATA[ raw ]]>*not emphasis*
*emphasis*