fix: stop an unclosed inline raw tag from unescaping later blocks (#4130)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Brian Gao
2026-10-25 23:31:44 -06:00
committed by GitHub
co-authored by Claude Opus 5.5
parent f0fd3e0e22
commit 4562b6f979
3 changed files with 33 additions and 0 deletions
+4
View File
@@ -103,6 +103,10 @@ export class _Lexer<ParserOutput = string, RendererOutput = string> {
for (let i = 0; i < this.inlineQueue.length; i++) {
const next = this.inlineQueue[i];
// an inline <pre>, <code>, <kbd> or <script> left open ends with the block
// holding it; carried over, it would stop every later block's text from
// being escaped
this.state.inRawBlock = false;
this.inlineTokens(next.src, next.tokens);
}
this.inlineQueue = [];
@@ -0,0 +1,11 @@
<p>an unclosed <code> tag</p>
<p>does not leak into the next paragraph: 1 &lt; 2 &amp; 3 &gt; 2</p>
<p>an unclosed <pre> tag</p>
<h1>does not leak into a heading: 1 &lt; 2 &amp; 3 &gt; 2</h1>
<p>an unclosed <kbd> tag</p>
<ul>
<li>does not leak into a list item: 1 &lt; 2 &amp; 3 &gt; 2</li>
</ul>
<p>within a paragraph <code>a & b</code> is still raw, as is
<code>a & b
across a line</code> but not after it: 1 &lt; 2</p>
+18
View File
@@ -0,0 +1,18 @@
---
renderExact: true
---
an unclosed <code> tag
does not leak into the next paragraph: 1 < 2 & 3 > 2
an unclosed <pre> tag
# does not leak into a heading: 1 < 2 & 3 > 2
an unclosed <kbd> tag
- does not leak into a list item: 1 < 2 & 3 > 2
within a paragraph <code>a & b</code> is still raw, as is
<code>a & b
across a line</code> but not after it: 1 < 2