Skip to content

fix: handle nested backticks in markdown code block rendering - #370

Open
sridhar-3009 wants to merge 1 commit into
vxcontrol:mainfrom
sridhar-3009:fix/markdown-nested-backticks-361
Open

fix: handle nested backticks in markdown code block rendering#370
sridhar-3009 wants to merge 1 commit into
vxcontrol:mainfrom
sridhar-3009:fix/markdown-nested-backticks-361

Conversation

@sridhar-3009

Copy link
Copy Markdown

Add a preprocessMarkdownFences() step in the Markdown component that auto-extends the outer fence when a code block body contains a backtick run long enough to prematurely close it, preventing the renderer from splitting a single block into two.

Closes #361

…rol#361)

Add preprocessMarkdownFences() that scans markdown line-by-line before
passing it to ReactMarkdown. When a fenced code block body contains a
backtick run long enough to prematurely close the outer fence, the outer
fence is extended by one backtick beyond the longest such inner run.
This conforms to the CommonMark spec and prevents the renderer from
splitting a single code block into two when the content includes triple
(or longer) backtick sequences on their own line.
@hiSandog

Copy link
Copy Markdown

A useful edge-case test would include nested Markdown where the inner backtick run appears inside an indented list or blockquote, since fence recognition can depend on the container prefix. It may also be worth testing a body containing several backtick runs of different lengths and confirming the preprocessor chooses exactly one longer outer fence. Finally, code spans outside fenced blocks should remain byte-for-byte unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Triple backticks inside code blocks break markdown rendering

2 participants