Skip to content

Use @pierre/highlights for syntax - #1125

Merged
stipsan merged 4 commits into
mainfrom
tembo/update-syntax-highlight-pierre-highlights-mwcc5c1l
Nov 11, 2026
Merged

stipsan merged 4 commits into
mainfrom
tembo/update-syntax-highlight-pierre-highlights-mwcc5c1l

Conversation

@stipsan

@stipsan stipsan commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Summary

Switch the website's syntax highlighting from refractor / react-refractor to @pierre/highlights, and format and highlight the code snippets at build time.

  • Code.astro formats every variant of an example's snippet with oxfmt (through vite-plus/fmt) and highlights it with Pierre's Dracula theme. All of this happens at build time. The variants are slotted into each React island as static HTML.
  • Example.CodeBody shows the variant whose data-snippet matches the selected options. React no longer formats or highlights anything.
  • src/components/snippets.ts holds each example's snippet template, its initial options, and every option combination (32 variants in total).
  • Formatting: no semicolons, single quotes, es5 trailing commas, 40 columns so snippets fit on phones. The code font also scales down slightly (between 11px and 14px) on narrow screens so 40 columns fit without scrolling.
  • Removed: refractor, react-refractor, the Prettier snippet formatting (utils.ts) and the Prism token styles in global.css.

Notes

  • Bundle size: the largest client JS file drops from ~231 KB gzipped on main to 43 KB (the React client runtime). Prettier, oxfmt and Pierre's WASM no longer ship to the browser. The full page, including all 32 pre-rendered snippet variants, is ~18 KB gzipped.
  • Release-age exception: @pierre/highlights@0.5.1 is newer than the repo's minimumReleaseAge, so it's listed in minimumReleaseAgeExclude in pnpm-workspace.yaml. Remove that line if you'd rather wait.
  • Long import lines: the import … from '…-scroll-into-view-if-needed' lines are longer than 40 columns, because module paths can't be wrapped. Those lines scroll horizontally on phones.

Testing

  • vp check, pnpm typecheck and pnpm build pass.
  • Checked in a browser at 1400px, 390px and 360px wide: every example starts on the right snippet, changing options switches to the matching one, and the console shows no errors or hydration warnings.

Want tembo to make any changes? Add a comment with @tembo and i'll get back to work!

View on Tembo  Review in Tembo  View Agent Settings

…lighting

Co-authored-by: tembo[bot] <208362400+tembo-io[bot]@users.noreply.github.com>
@tembo tembo Bot added the tembo Pull request created by Tembo label Nov 11, 2026
@vercel

vercel Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
scroll-into-view-dev Ready Ready Preview Nov 11, 2026 5:22pm UTC

Request Review

…ighlight-pierre-highlights-mwcc5c1l

Co-authored-by: Cody <81981+stipsan@users.noreply.github.com>
@socket-security

socket-security Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​pierre/​highlights@​0.5.11001008998100

View full report

Every snippet variant is formatted with oxfmt (via vite-plus/fmt) when
the page is built, at 40 columns with no semicolons, and passed to the
islands as props. Prettier is no longer shipped to the browser.

The code font scales down on narrow screens so 40 columns fit on phones.

Co-authored-by: tembo[bot] <208362400+tembo-io[bot]@users.noreply.github.com>
Code.astro formats and highlights every variant of an example's snippet
at build time and slots them into the React island as static HTML.
Example.CodeBody only toggles which variant is visible, so neither
oxfmt nor the Pierre highlighter (and its WASM) ship to the browser.

Co-authored-by: tembo[bot] <208362400+tembo-io[bot]@users.noreply.github.com>
@stipsan
stipsan merged commit 232094c into main Nov 11, 2026
5 checks passed
@stipsan
stipsan deleted the tembo/update-syntax-highlight-pierre-highlights-mwcc5c1l branch November 11, 2026 17:47

This branch was successfully deployed

1 active deployment
Preview — 03a8bb5b Deployed Nov 11, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tembo Pull request created by Tembo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant