Skip to content

Conversation

@coltondotio
Copy link
Contributor

Fixes code blocks collapsing into a single line on desktop during page load.

Short description of the changes made

Replaced <code> elements with <div> elements in FernSyntaxHighlighterTokens.tsx and FernSyntaxHighlighterTokensVirtualized.tsx. The <code> element was wrapping <div> and <table> elements, which is invalid HTML.

What was the motivation & context behind this PR?

Users were seeing code blocks collapse into a single line on desktop during page load, with line numbers appearing inline with code content (e.g., 1{2 "message": {3 "type"...).

The root cause is invalid HTML nesting: <code> is phrasing content and can only contain other phrasing content, but it was wrapping <div> and <table> (flow content). Browsers auto-close the <code> element during HTML parsing to "fix" this, creating a DOM structure different from what React expects. This hydration mismatch caused table elements to briefly lose their display styles.

The <pre> element already provides the semantic meaning of preformatted text, so removing the <code> wrapper is acceptable.

How has this PR been tested?

  • Lint checks pass
  • Manual code review to verify CSS selectors use .code-block class (not code.code-block element selector)

Human review checklist

  • Verify the fix resolves the code block collapse issue on a live preview
  • Check if any customer CSS might target code.code-block specifically
  • Verify accessibility is not impacted by removing the <code> element

Link to Devin run: https://app.devin.ai/sessions/8458f6ca712f47788f7e038841776689
Requested by: Colton Berry (@coltondotio)

The code element was wrapping div and table elements, which is invalid HTML
since code is phrasing content and can only contain other phrasing content.
This caused browsers to auto-close the code element during HTML parsing,
leading to a DOM structure different from what React expected. During
hydration, this mismatch caused the table elements to briefly lose their
display styles, collapsing code blocks into a single line on desktop.

Co-Authored-By: Colton Berry <coltonsberry@gmail.com>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Contributor

vercel bot commented Dec 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
dev.ferndocs.com Ready Ready Preview Jan 9, 2026 3:04am
fern-dashboard Ready Ready Preview Jan 9, 2026 3:04am
fern-dashboard-dev Ready Ready Preview Jan 9, 2026 3:04am
prod-assets.ferndocs.com Ready Ready Preview Jan 9, 2026 3:04am
prod.ferndocs.com Ready Ready Preview Jan 9, 2026 3:04am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
fern-platform Ignored Ignored Jan 9, 2026 3:04am

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

🌱 Smoke Test Preview

Run at: 2026-01-09 03:01:53 UTC

Testing branch changes with smoke test content:

🕷️ Smoke Test Crawler Results

Pages crawled: 56
Successful: 54
With errors: 2 ❌

❌ Pages with Errors

📊 Full error breakdown
  • Console errors: 0
  • Network errors: 0
  • Page errors: 0

See full details in the workflow logs.

@coltondotio coltondotio merged commit cbbdc4f into app Jan 9, 2026
22 of 23 checks passed
@coltondotio coltondotio deleted the devin/1767048450-fix-codeblock-html-nesting branch January 9, 2026 13:42
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.

3 participants