Skip to content

[01356] Fix code block rendering without language specifier#2898

Merged
nielsbosma merged 1 commit intomainfrom
plan-01356-Ivy-Framework
Apr 1, 2026
Merged

[01356] Fix code block rendering without language specifier#2898
nielsbosma merged 1 commit intomainfrom
plan-01356-Ivy-Framework

Conversation

@nielsbosma
Copy link
Copy Markdown
Contributor

Changes

Fixed fenced code blocks without a language specifier rendering as inline code instead of block-level code elements. The root cause was that MarkdownRenderer.tsx used !className to detect inline code, but react-markdown doesn't set a className on code elements without a language — causing fenced blocks to be misidentified as inline. Fixed by checking the AST parent node (node.parent.tagName === 'pre'). Also removed the match guard in CodeBlock.tsx so no-language blocks reach the SyntaxHighlighter with a fallback language of "text".

API Changes

None.

Files Modified

  • src/frontend/src/components/MarkdownRenderer.tsx — Fixed inline detection logic to use AST parent node check instead of className
  • src/frontend/src/components/markdown/CodeBlock.tsx — Removed match && guard and added "text" language fallback

Commits

  • 14edf97 [01356] Fix code block rendering without language specifier

Artifacts

Screenshots

edge-all-apps-final

Use node.parent.tagName to detect block-level code elements instead of
relying on className. Fenced code blocks without a language are wrapped
in <pre> by react-markdown but have no className, causing them to be
incorrectly treated as inline code.

Also remove the match guard in CodeBlock so no-language blocks reach the
SyntaxHighlighter path, with a fallback language of "text".
@nielsbosma nielsbosma merged commit cb9743c into main Apr 1, 2026
10 of 11 checks passed
@nielsbosma nielsbosma deleted the plan-01356-Ivy-Framework branch April 1, 2026 06:35
@artem-ivy-ai
Copy link
Copy Markdown
Collaborator

Deploy timed out

I'm preparing your docs & samples for this PR. I'll update the comment as Sliplane reports progress.

Logs

No terminal state received from Sliplane after 30 minutes.

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.

2 participants