mirror of
https://github.com/markedjs/marked.git
synced 2026-11-30 16:48:05 +01:00
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:
co-authored by
Claude Opus 5
parent
e09c40dfc7
commit
2d3899bf7c
@@ -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, '');
|
||||
|
||||
@@ -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
|
||||
@@ -1 +1,3 @@
|
||||
<blockquote><p>test</p></blockquote>
|
||||
<blockquote>
|
||||
<p> test</p>
|
||||
</blockquote>
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user