npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@fuzdev/fuz_code

v0.49.1

Published

syntax styler for TypeScript, Svelte, Markdown, and more

Readme

@fuzdev/fuz_code

syntax styler for TypeScript, Svelte, Markdown, and more 🎨

code.fuz.dev

fuz_code is a syntax styler: it turns source code into HTML with token CSS classes, or ranges for the CSS Custom Highlight API. It originated as a fork of Prism by Lea Verou and has since been rewritten: each language has a lexer that scans without regular expressions and emits tokens as a flat stream in a typed array. The flat token stream is an idea borrowed from pngwn, the author of Twinkleplop.

Twinkleplop is the broader project: it compiles declarative grammars, covers more languages, and ships themes, annotations, and markdown integrations. fuz_code is narrower, with a lexer written as ordinary code for each of a small set of languages, and a few Svelte components.

Features:

  • a minimal, explicit API to generate stylized HTML — stylize(code, lang)
  • written in TypeScript; the lexers and styler import nothing outside the package
  • built-in languages listed below, extensible by writing a lexer

Two optional integrations:

Compared to Shiki, fuz_code is about two orders of magnitude faster for runtime usage: it runs one single-pass lexer per language rather than the Oniguruma regexp engine that TextMate grammars require. Shiki targets build-time use and supports far more languages and themes.

Usage

npm i -D @fuzdev/fuz_code
<script lang="ts">
	import Code from '@fuzdev/fuz_code/Code.svelte';
</script>

<!-- defaults to Svelte -->
<Code content={svelte_code} />
<!-- select a lang -->
<Code content={ts_code} lang="ts" />
import { syntax_styler_global } from '@fuzdev/fuz_code/syntax_styler_global.ts';

// Generate HTML with syntax styling
const html = syntax_styler_global.stylize(code, 'ts');

// Get the flat event stream for custom processing
const lexed = syntax_styler_global.lex(code, 'ts');

Themes are CSS files and work with any framework.

With SvelteKit:

// +layout.svelte
import '@fuzdev/fuz_code/theme.css';

The default theme depends on fuz_css for color-scheme awareness. See the fuz_css docs for its usage.

If you're not using fuz_css, import theme_variables.css alongside theme.css:

// Without fuz_css:
import '@fuzdev/fuz_code/theme.css';
import '@fuzdev/fuz_code/theme_variables.css';

Modules

See src/lib for the full set of modules.

Languages

Registered by default in syntax_styler_global:

  • markup (html, mathml, svg)
  • xml (ssml, atom, rss)
  • svelte
  • md (markdown)
  • ts (typescript, js, javascript — JS is a syntactic subset)
  • css
  • json — accepts comments (JSONC)
  • sh (bash, shell — the POSIX/bash family)
  • rust (rs)

Add a language by writing a SyntaxLang lexer and registering it with add_lang — see the existing lexer_*.ts modules.

Docs

Issues and questions are welcome.

Experimental highlight support

For browsers that support the CSS Custom Highlight API, fuz_code provides an experimental component that can use native browser highlighting as an alternative to HTML generation.

Browser support is limited, and the API can't apply layout-affecting styles — bold, italics, font sizes — so themes that use them render differently. The standard Code.svelte component using HTML generation is recommended for most use cases.

<script lang="ts">
	import CodeHighlight from '@fuzdev/fuz_code/CodeHighlight.svelte';
</script>

<!-- auto-detect and use CSS Highlight API when available -->
<CodeHighlight content={code} mode="auto" />
<!-- force HTML mode -->
<CodeHighlight content={code} mode="html" />
<!-- force ranges mode (requires browser support) -->
<CodeHighlight content={code} mode="ranges" />

When using the experimental highlight component, import the corresponding theme:

// instead of theme.css, import theme_highlight.css in +layout.svelte:
import '@fuzdev/fuz_code/theme_highlight.css';

Experimental modules:

Contributing

fuz.dev/contributing

License 🐦

Originally forked from Prism (prismjs.com) by Lea Verou — with the Svelte support originally based on prism-svelte by @pngwn.

MIT