fix: keep tabs that are code content under a block quote (#4217)

* fix: keep tabs that are code content under a block quote

After ">", an optional space is part of the marker; tabs after that
space belong to the line content (e.g. fenced code) and must not be
expanded. Tabs with no leading space are still expanded so indented
code under a quote keeps working.

Fixes #4184

* test: move the block quote tab case to a renderExact spec
This commit is contained in:
kevin
2026-11-16 09:33:49 -07:00
committed by GitHub
parent 59024421a4
commit d2c6f736f3
3 changed files with 22 additions and 1 deletions
+10 -1
View File
@@ -270,7 +270,16 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
// After a space the marker consumes it whole, so later tabs stay literal.
.replace(
this.rules.other.blockquoteMarkerWhitespace,
(_, marker: string, whitespace: string) => marker + expandTabs(whitespace, marker.length),
(_: string, marker: string, whitespace: string) => {
// The optional space after ">" is marker; anything after that is
// content (e.g. a tab that opens a fenced code line) and must not
// be expanded. Tabs with no leading space are structural and are
// expanded so indented code under the quote still works.
if (whitespace.startsWith(' ')) {
return marker + ' ' + whitespace.slice(1);
}
return marker + expandTabs(whitespace, marker.length);
},
)
// precede setext continuation with 4 spaces so it isn't a setext
.replace(this.rules.other.blockquoteSetextReplace, '\n $1')
@@ -0,0 +1,5 @@
<blockquote>
<pre><code class="language-python">class P:
name: str
</code></pre>
</blockquote>
@@ -0,0 +1,7 @@
---
renderExact: true
---
> ```python
> class P:
> name: str
> ```