Skip to content

perf(md): make Markdown compilation 15× faster - #847

Open
kotarotaniguchi0523 wants to merge 1 commit into
voidzero-dev:mainfrom
kotarotaniguchi0523:claude/funny-davinci-nymx83
Open

kotarotaniguchi0523 wants to merge 1 commit into
voidzero-dev:mainfrom
kotarotaniguchi0523:claude/funny-davinci-nymx83

Conversation

@kotarotaniguchi0523

@kotarotaniguchi0523 kotarotaniguchi0523 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Replace Shiki with @pierre/highlights for Markdown syntax highlighting. Highlighting accounted for 91% of @void/md compile time.

On the Void docs and playground pages, Markdown compilation is approximately 15× faster:

Markdown compilation Before After
First pass over 123 pages 4.05–4.18 s 266–285 ms
Warm pass over all pages 2.06–2.18 s 140–170 ms

Measured on Node 22 with 4 vCPU. These numbers cover Markdown compilation, not the whole build.

Appearance and compatibility

The default github-light and github-dark themes stay the same, but some code colors change because the new lexer classifies tokens differently.

Left: Shiki on main. Right: @pierre/highlights on this branch.

Light theme comparison Dark theme comparison
  • Configure themes with themes; shiki.themes remains supported but is deprecated.
  • Unsupported languages render as plain text. Custom TextMate grammars are not supported.
  • [!code ...] notations are read from comments only. An INI comment after a value is an exception and is not recognized.
  • Existing code block classes, line numbers, the copy button, and CSS variables are preserved.

This also fixes focus dimming, code block and line-number backgrounds, and dark-theme bold and italic styles.

Validation

  • Markdown unit and integration tests: 21 files, 155 tests passed.
  • vp run build:all, vp run check, vp lint, and vp fmt --check passed.
  • Compared light and dark screenshots in Chromium.
  • The full suite was run before the final notation-comment fix: 17,049 tests passed. The 31 failures were outside Markdown and also failed on main in the same environment.

🤖 Generated with Claude Code

@kotarotaniguchi0523
kotarotaniguchi0523 requested a review from a team as a code owner November 16, 2026 04:24
@kotarotaniguchi0523
kotarotaniguchi0523 force-pushed the claude/funny-davinci-nymx83 branch from 4e04f2d to 1ebee1a Compare November 16, 2026 04:26
@socket-security

socket-security Bot commented Nov 16, 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

@kotarotaniguchi0523
kotarotaniguchi0523 force-pushed the claude/funny-davinci-nymx83 branch from 1ebee1a to 37cc43a Compare November 16, 2026 04:28
@kotarotaniguchi0523 kotarotaniguchi0523 changed the title perf(md): replace Shiki with @pierre/highlights perf(md): make Markdown compilation 15× faster Nov 16, 2026
Highlighting was 91% of the time spent compiling Markdown. Code blocks are
now highlighted by @pierre/highlights, a WebAssembly lexer, which makes the
Markdown compile step about 15 times faster. The parser, the plugins, the
rendered markup and the default themes stay as they are.

- `src/highlight.ts` builds the lines from per-line tokens and applies the
  `{1,3-5}` line range and the `[!code ...]` comment notations with the same
  classes as before.
- Token boundaries and classification differ from Shiki, so some colors
  change within the same themes.
- `themes` replaces `shiki.themes`, which still works and is deprecated.
- Focus dimming now applies: the CSS selected `has-focus`, but the class on
  the block is `has-focused`.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011f44HGUmdFJgasJzEr7dQk
@kotarotaniguchi0523
kotarotaniguchi0523 force-pushed the claude/funny-davinci-nymx83 branch from 37cc43a to f026a9d Compare November 16, 2026 04:39

This branch has not been deployed

No deployments
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