You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tab inside a fenced code block in a block quote is expanded to spaces (regression in 18.1.2) #4184
This issue was posted by Claude Code using claude-opus-5-5 on behalf of David.
Marked version: 18.1.2. The code is unchanged at v18.1.3 and on master. 18.1.1 is not affected.
Describe the bug
A tab inside a fenced code block in a block quote is turned into spaces. CommonMark keeps it as a tab, because it is code content, not block structure.
#4110 added blockquoteMarkerWhitespace (/^( {0,3}>)([ \t]+)/gm). The blockquote tokenizer passes the whole whitespace run after > to expandTabs. That is right for example 6 (>\t\tfoo), where the tabs open an indented code block. In > \tname, though, the marker takes > and its optional space, and the tab is the first character of a fenced code line. Spec section 2.2 expands tabs only "in contexts where whitespace helps to define block structure", so this tab should stay a tab.
As #4110 notes, @markedjs/html-differ treats whitespace inside <pre> as equal, so the spec suite does not catch this.
To Reproduce
import{marked}from'marked';marked.parse('> ```python\n> class P:\n> \tname: str\n> ```\n');
Expected behavior
The tab stays a tab, as in 18.1.1 and the CommonMark reference implementation. Only whitespace that the block quote marker or an indented code block consumes should be expanded.
Activity