v0 32 languages

fractalpop

fast syntax highlighting for SvelteKit.

One engine behind components, markdown, and plain strings. SSR-safe and identical on both sides, so highlighted code costs nothing to hydrate — and themes are CSS variables, with no runtime to ship.

Read detailed documentation at Github.

01 /

Core logic

Fractalpop is not a semantic highlighter. It splits the code into parts, whitespaces, indentation, line-breaks and labels each part. These parts are then colored differently. Thus it can be language-agnostic - a single classifier for all languages. Regular highlighters like Prism and Shiki are included in the benchmarks, but it’s not quite fair to compare to them as they are semantic highlighters. Fractalpop is for rapid, asthetic highlighting. Not true grammar awareness.

The idea is taken from the gpu-lexer utility by Shu Ding.

Sveltekit · dark
card.sass
1// theme tokens2$brand: hsl(212, 90%, 55%)3$pad: 1rem45@mixin card($radius: 0.5rem)6  border-radius: $radius7  padding: $pad89.card10  color: $brand11  +card(0.75rem)12  &:hover13    background: darken($brand, 8%) !important
02 /

Token palettes

Light and Dark - match token palettes for your theme.

light.css
:root {  --fp-class: #5a4fea;  --fp-identifier: #38393a;  --fp-sign: #9fa0a2;  --fp-string: #00a99a;  --fp-keyword: #d6493f;  --fp-comment: #7a7878;  --fp-jsxliterals: #982c8a;  --fp-entity: #665ac7;  --fp-property: #4e8fdf;}
dark.css
:root[data-theme='dark'] {  --fp-class: #7eb5ff;  --fp-identifier: #d4d4d4;  --fp-sign: #8b949e;  --fp-string: #88bbb6;  --fp-keyword: #ffada8;  --fp-comment: #8b8b8b;  --fp-jsxliterals: #d2a8ff;  --fp-entity: #b7adff;  --fp-property: #79c0ff;}

Line Highlighting: Each line is a .fp__line, so you can target them.

lines.css
.fp__line:nth-child(5),.fp__line--highlighted {  background: #fff8c5;}
03 /

Languages

fractalpop/full registers 32 languages up front, no extra grammars or setup. The default fractalpop entry stays tiny with TypeScript and plaintext only; grow it with registerLanguage() or importDefaults(). Use lang() to resolve filenames, extensions and aliases to a canonical name.

languages.ts
import { highlight, lang } from 'fractalpop/full'highlight('const ready = true')              // TypeScript by defaulthighlight('print("hi")', { lang: 'python' }) // canonical namehighlight(styles, { lang: lang('yml') })     // yml -> yaml
All languages 32
ValueLanguage & relatives
04 /

Rules of engagement

Function over form

@fractalpop/svelte ships <Highlight>, <Code>, <Editor> and <FileTree> — every code block on this site is rendered by them. Open the component sheet →

Code.svelte
<script>  import { Highlight } from '@fractalpop/svelte'</script><Highlight code={source} lang="sass" highlightLines={[2, 3]} />

Scalable by Default

Set token colours with scoped CSS variables, use the themes you have and like, with cx for emphasis - Tailwind-friendly, no selectors needed.

theme.ts
highlight(code, {  lang: 'sass',  cx: { keyword: 'font-bold', comment: 'italic' },})

Same tokens outside components

@fractalpop/mdsvex highlights fences in .svx; @fractalpop/remark does the same for .md and .mdx. Read more on Github.

svelte.config.js
import { fractalpopHighlighter } from '@fractalpop/mdsvex'// svelte.config.js — highlights fences in .svxmdsvex({ highlight: { highlighter: fractalpopHighlighter } })
05 /

Benchmarks and WebGPU Experimental

Async, language-agnostic highlighting, with or without gpu-lexer. For fast and easy aesthetics, not real grammar awareness. Keep that in mind when looking at performance against a highlighter like Shiki.

fractalpop
Sugar High
PrismJS
highlight.js
Shiki

Minified bundle

12.35 KiB
27.29 KiB
14.57 KiB
29.49 KiB
364.20 KiB

Gzip bundle

5.28 KiB
10.09 KiB
5.57 KiB
11.28 KiB
72.79 KiB

500 KiB file

97.70 ms
101.81 ms
100.31 ms
127.61 ms
858.15 ms