Skip to content

fix(website): restore syntax highlighting for nested code blocks - #1660

Open
unrevised6419 wants to merge 1 commit into
hayes:mainfrom
unrevised6419:fix/docs-nested-code-highlighting
Open

fix(website): restore syntax highlighting for nested code blocks#1660
unrevised6419 wants to merge 1 commit into
hayes:mainfrom
unrevised6419:fix/docs-nested-code-highlighting

Conversation

@unrevised6419

Copy link
Copy Markdown
Contributor

Problem

Fenced code blocks nested inside a list item render as unhighlighted raw text on the docs site, while top-level fences highlight fine. Example: the two typescript blocks under writing-plugins.mdxglobal-types.ts.

The rendered HTML for a nested block is <code class="language-typescript">declare global {…}</code> — no shiki token spans.

Cause

fumadocs-core@16.7.15 (the pinned version), in rehypeShikiFromHighlighter:

visit(tree, "element", (node, index, parent) => {
  let parsed;
  if (node.tagName === "pre") parsed = PreParser(tree, node);
  else if (node.tagName === "code" && inline) parsed = InlineCodeParsers[inline](tree, node);
  if (!parsed) return "skip";   // <-- unmatched elements are not descended into
  
});

"skip" on a non-matching element stops unist-util-visit from descending into its children, so the first <ol>, <ul>, <li>, <blockquote> or <td> hides its <pre> from the highlighter.

Upstream fixed this in 9cf33e9b1 by returning undefined for unmatched elements, first released in fumadocs-core@16.7.16. 16.7.15 is the last broken release.

Changes

  • Bump fumadocs-core and fumadocs-ui 16.7.1516.7.16.
  • Re-indent the code blocks in website/content/docs/guide/enums.mdx back under their list items. They were dedented in 3b2a8da to work around this bug; the explicit 1.4. numbering from that commit is kept.

No source or plugin changes — website only.

Verification

Dev server on a clean .next, rendered HTML inspected for <code class="language-*"> (unhighlighted) versus class="line" (shiki output):

page unhighlighted blocks shiki lines
guide/enums 0 78
guide/writing-plugins 0 172
plugins/errors 0 369

Before the bump, writing-plugins and errors each had 2 raw blocks. A full scan of website/content found only those 4 indented fences, so nothing else was affected.

Upstream follow-up

Nothing guarded this behaviour in fumadocs after the fix landed, so a regression test is proposed upstream in fuma-nama/fumadocs#3525 (test-only).

🤖 Generated with Claude Code

https://claude.ai/code/session_019ZmyJ26NCkhQgaa1xQbCEq

Fenced code blocks nested inside a list item rendered as unhighlighted
raw text. fumadocs-core 16.7.15 returned 'skip' from the rehypeCode
visitor for every unmatched element, so unist-util-visit never descended
into wrapper elements such as <ol>, <li> or <blockquote>, and the <pre>
inside them was never passed to shiki. Only top-level fences were
highlighted.

Upstream fixed this in fumadocs-core 16.7.16, so bump fumadocs-core and
fumadocs-ui to that version.

The enums guide had been dedented in 3b2a8da to work around the bug.
Restore the code blocks to their list items now that nesting renders
correctly, keeping the explicit 1-4 numbering from that commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZmyJ26NCkhQgaa1xQbCEq
@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ff2b58e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

@unrevised6419 is attempting to deploy a commit to the Michael Hayes' projects Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new

pkg-pr-new Bot commented Sep 1, 2026

Copy link
Copy Markdown

Open in StackBlitz

@pothos/core

npm i https://pkg.pr.new/@pothos/core@1660

@pothos/plugin-add-graphql

npm i https://pkg.pr.new/@pothos/plugin-add-graphql@1660

@pothos/plugin-complexity

npm i https://pkg.pr.new/@pothos/plugin-complexity@1660

@pothos/plugin-dataloader

npm i https://pkg.pr.new/@pothos/plugin-dataloader@1660

@pothos/plugin-directives

npm i https://pkg.pr.new/@pothos/plugin-directives@1660

@pothos/plugin-drizzle

npm i https://pkg.pr.new/@pothos/plugin-drizzle@1660

@pothos/plugin-errors

npm i https://pkg.pr.new/@pothos/plugin-errors@1660

@pothos/plugin-example

npm i https://pkg.pr.new/@pothos/plugin-example@1660

@pothos/plugin-federation

npm i https://pkg.pr.new/@pothos/plugin-federation@1660

@pothos/plugin-grafast

npm i https://pkg.pr.new/@pothos/plugin-grafast@1660

@pothos/plugin-mocks

npm i https://pkg.pr.new/@pothos/plugin-mocks@1660

@pothos/plugin-prisma

npm i https://pkg.pr.new/@pothos/plugin-prisma@1660

@pothos/plugin-prisma-utils

npm i https://pkg.pr.new/@pothos/plugin-prisma-utils@1660

@pothos/plugin-relay

npm i https://pkg.pr.new/@pothos/plugin-relay@1660

@pothos/plugin-scope-auth

npm i https://pkg.pr.new/@pothos/plugin-scope-auth@1660

@pothos/plugin-simple-objects

npm i https://pkg.pr.new/@pothos/plugin-simple-objects@1660

@pothos/plugin-smart-subscriptions

npm i https://pkg.pr.new/@pothos/plugin-smart-subscriptions@1660

@pothos/plugin-sub-graph

npm i https://pkg.pr.new/@pothos/plugin-sub-graph@1660

@pothos/plugin-tracing

npm i https://pkg.pr.new/@pothos/plugin-tracing@1660

@pothos/plugin-validation

npm i https://pkg.pr.new/@pothos/plugin-validation@1660

@pothos/plugin-with-input

npm i https://pkg.pr.new/@pothos/plugin-with-input@1660

@pothos/plugin-zod

npm i https://pkg.pr.new/@pothos/plugin-zod@1660

@pothos/tracing-newrelic

npm i https://pkg.pr.new/@pothos/tracing-newrelic@1660

@pothos/tracing-opentelemetry

npm i https://pkg.pr.new/@pothos/tracing-opentelemetry@1660

@pothos/tracing-sentry

npm i https://pkg.pr.new/@pothos/tracing-sentry@1660

@pothos/tracing-xray

npm i https://pkg.pr.new/@pothos/tracing-xray@1660

commit: ff2b58e

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.

1 participant