fix: expand a tab after the block quote marker to the next tab stop (#4110)

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
yu2971512385-ui
2026-10-25 23:54:00 -06:00
committed by GitHub
co-authored by Claude Opus 5
parent e09c40dfc7
commit 2d3899bf7c
6 changed files with 34 additions and 2 deletions
+6
View File
@@ -232,6 +232,12 @@ export class _Tokenizer<ParserOutput = string, RendererOutput = string> {
const currentRaw = currentLines.join('\n');
const currentText = currentRaw
// a tab after the block quote marker runs to the next tab stop, and
// the marker only consumes one space of it; the rest is content
.replace(
this.rules.other.blockquoteMarkerWhitespace,
(_, marker: string, whitespace: string) => marker + expandTabs(whitespace, marker.length),
)
// precede setext continuation with 4 spaces so it isn't a setext
.replace(this.rules.other.blockquoteSetextReplace, '\n $1')
.replace(this.rules.other.blockquoteSetextReplace2, '');
+1
View File
@@ -59,6 +59,7 @@ export const other = {
blockquoteStart: /^ {0,3}>/,
blockquoteSetextReplace: /\n {0,3}((?:=+|-+) *)(?=\n|$)/g,
blockquoteSetextReplace2: /^ {0,3}>[ \t]?/gm,
blockquoteMarkerWhitespace: /^( {0,3}>)([ \t]+)/gm,
listReplaceNesting: /^ {1,4}(?=( {4})*[^ ])/g,
listIsTask: /^\[[ xX]\] +\S/,
listReplaceTask: /^\[[ xX]\] +/,
@@ -0,0 +1,5 @@
<blockquote>
<pre><code> foo
</code></pre>
<p> bar</p>
</blockquote>
@@ -0,0 +1,9 @@
---
renderExact: true
# The code block matches CommonMark: two columns of indentation survive the
# block quote marker and the code block's own four. The "<p> bar</p>" below
# does not - CommonMark strips leading whitespace from paragraph lines and
# marked does not, the same difference as in tab_after_blockquote.
---
> foo
> bar
+3 -1
View File
@@ -1 +1,3 @@
<blockquote><p>test</p></blockquote>
<blockquote>
<p> test</p>
</blockquote>
+10 -1
View File
@@ -1 +1,10 @@
> test
---
renderExact: true
# The two leading spaces are the content indentation left over once the block
# quote marker has taken one column of the expanded tab. CommonMark renders
# "<p>test</p>" here because it strips leading whitespace from paragraph
# lines; marked keeps it everywhere, with or without a block quote, so this
# records marked's behaviour rather than the spec's. Fixing the paragraph
# side is a separate change.
---
> test