Skip to content

fix(website): restore padding on Shiki code blocks - #924

Merged
blove merged 1 commit into
mainfrom
blove/homepage-code-examples-visual-1bd306
Sep 1, 2026
Merged

fix(website): restore padding on Shiki code blocks#924
blove merged 1 commit into
mainfrom
blove/homepage-code-examples-visual-1bd306

Conversation

@blove

@blove blove commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Cause

PR #863 ("docs polish 2/3") deleted the global .shiki rules from docs.css:

.shiki { padding: 1.5rem; background: var(--docs-code-bg) !important; overflow-x: auto; }
.shiki code { font-family: var(--font-mono), monospace; font-size: 0.75rem; line-height: 1.7; }

on the finding "zero elements matched, on docs and blog." That was true for docs and blog — rehype-pretty-code writes its background inline and never emits a .shiki class. But two TSX call sites highlight with Shiki's codeToHtml directly, which does emit <pre class="shiki tokyo-night">:

  • components/landing/HighlightedCode.tsx — the homepage Code tabs, plus /langgraph, /render, /chat
  • components/solutions/SolutionCodeBlock.tsx — every /solutions/* page

Those <pre> elements lost their padding. The dark theme background rides inline on the <pre>, while the landing override put its 16px 20px on the wrapper <div> (which carries shiki too) — outside the dark box. Measured before the fix: wrapper padding 16px 20px, <pre> padding 0px. The result was a light gutter with the code flush against the dark edges.

Fix

  • global.css — a pre.shiki base rule restoring padding and the mono font. Scoped to pre.shiki, not .shiki, precisely because both call sites also put the class on a wrapper div.
  • styles/landing.css — the landing override's padding moves off the wrapper onto > pre.shiki; it keeps the tighter 16px 20px scale.
  • SolutionCodeBlock.tsx — corrects the comment asserting Shiki emits its own padding. That wrong premise is what made the deletion look safe.

Verification (Chrome, dev server)

Surface wrapper pad <pre> pad bg wrapper↔pre gap
homepage, all 4 Code panes 0px 16px 20px rgb(26,27,38) 0
/langgraph, /render, /chat 0px 16px 20px rgb(26,27,38) 0
/solutions/compliance 0px 20px 24px rgb(26,27,38) 0

Docs pages still match 0 pre.shiki elements with their own [data-rehype-pretty-code-figure] pre rules intact — unaffected.

Guards

Two halves, since neither is sufficient alone:

nx lint website: 0 errors. Website suite: 440/440 pass.

🤖 Generated with Claude Code

@blove
blove enabled auto-merge (squash) September 1, 2026 05:26
@vercel

vercel Bot commented Sep 1, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated
threadplane Ready Ready Preview Sep 1, 2026 6:00am UTC

Request Review

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @blove's task in 0s —— View job


I'll analyze this and get back to you.

PR #863 deleted the global `.shiki` rules from docs.css on the finding that
zero elements matched. That was true of docs and blog — rehype-pretty-code
writes its background inline and never emits a `.shiki` class — but two TSX
call sites highlight with Shiki's `codeToHtml` directly, which does:

  - components/landing/HighlightedCode.tsx  (homepage Code tabs, /langgraph,
    /render, /chat)
  - components/solutions/SolutionCodeBlock.tsx  (every /solutions/* page)

Those <pre> elements lost their padding. The dark theme background rides
inline on the <pre>, while the landing override put its 16px 20px on the
wrapper <div> (which carries `shiki` too) — outside the dark box. The result
was a light gutter with the code flush against the dark edges.

Restores the padding as a `pre.shiki` base rule in global.css, and moves the
landing override's padding off the wrapper onto `> pre.shiki`. The selector is
pre-scoped deliberately: both call sites also put the class on a wrapper div,
where padding lands outside the surface. SolutionCodeBlock's comment claimed
Shiki emits its own padding — that wrong premise is what made the deletion
look safe, so it is corrected too.

Guarded in two halves, since neither is sufficient alone. The CSS half is a
style contract (#926's registry — this is precisely the "comment explaining
why a declaration must not be removed" that it asks for), mutation-tested by
deleting the declaration and by renaming the selector. The markup half lives
in HighlightedCode.spec.tsx: that Shiki still emits a `pre.shiki` carrying an
inline background and no padding of its own, so the contract keeps guarding a
rule something actually matches.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@blove
blove force-pushed the blove/homepage-code-examples-visual-1bd306 branch from ef87550 to 608b229 Compare September 1, 2026 05:57
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Claude finished @blove's task in 0s —— View job


I'll analyze this and get back to you.

@blove
blove merged commit 1bd7df3 into main Sep 1, 2026
64 checks passed
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