From d2c6f736f339b4739a16426c681528ca210a6e87 Mon Sep 17 00:00:00 2001 From: kevin <5299031+kevin9327@users.noreply.github.com> Date: Tue, 17 Nov 2026 01:33:49 +0900 Subject: [PATCH] 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 --- src/Tokenizer.ts | 11 ++++++++++- test/specs/new/blockquote_fenced_code_tab.html | 5 +++++ test/specs/new/blockquote_fenced_code_tab.md | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/specs/new/blockquote_fenced_code_tab.html create mode 100644 test/specs/new/blockquote_fenced_code_tab.md diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index a214bac4..f2707de6 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -270,7 +270,16 @@ export class _Tokenizer { // 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') diff --git a/test/specs/new/blockquote_fenced_code_tab.html b/test/specs/new/blockquote_fenced_code_tab.html new file mode 100644 index 00000000..aab76e90 --- /dev/null +++ b/test/specs/new/blockquote_fenced_code_tab.html @@ -0,0 +1,5 @@ +
+
class P:
+	name: str
+
+
diff --git a/test/specs/new/blockquote_fenced_code_tab.md b/test/specs/new/blockquote_fenced_code_tab.md new file mode 100644 index 00000000..ee96cd80 --- /dev/null +++ b/test/specs/new/blockquote_fenced_code_tab.md @@ -0,0 +1,7 @@ +--- +renderExact: true +--- +> ```python +> class P: +> name: str +> ```