Fix: skip inline parsing when block tokens already parsed
Marked version: latest
Markdown flavor: GitHub Flavored Markdown
Description Improves the parsing behavior inside code blocks.
Prevents unnecessary inline parsing (such as emphasis, links, or special characters like @) inside fenced and indented code blocks.
No related GitHub issue — this is a proactive improvement based on observing markdown rendering inconsistencies.
Expectation Inside code blocks (fenced by ``` or indented by 4 spaces), content should be treated as plain text, without interpreting inline syntax such as @, _, *, etc.
Result Before fix:
In some situations, special characters inside code blocks were incorrectly parsed.
After fix:
Code blocks now properly preserve all content literally, matching markdown specs.
What was attempted Updated lexer and tokenizer logic to skip inline tokenization inside Tokens.Code nodes
This fix prevents Tokens.Code nodes from being parsed for inline formatting. Code blocks must render content literally without interpreting @, *, or _ as special syntax. This makes the parser behave according to markdown standards and avoids unexpected formatting issues.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| marked-website | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Apr 26, 2025 1:06am |
Would you be able to do the same thing by checking if token.type === 'code'?
Can you provide some markdown where marked renders something inside code blocks?
closing as stale. If you would like to continue working on this feel free to reopen it.