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

typst-utils

v0.2.0

Published

Zero-dependency helpers for working with Typst markup

Readme

typst-utils

Zero-dependency helpers for working with Typst markup.

Works in browser and Node.

npm install typst-utils

API

| Function | Use | |---|---| | escape_typst(s) | Escape a string for embedding as markup/content text (includes =, the line-start heading marker). | | escape_typst_str(s) | Escape a string for embedding inside a double-quoted string literal. | | escape_typst_postfix(s) | Escape a leading ( / . in text emitted directly after an inline code expression. Run after escape_typst. | | typst_inline(expr, text) | Join an inline code expression to following markup text, escaping the seam. |

// escape_typst — markup text; here * would otherwise start strong emphasis
escape_typst('Or *the anointed one*')      // → Or \*the anointed one\*

// escape_typst_str — contents of a "quoted string", e.g. raw("...")
escape_typst_str('print("hi")')            // → print(\"hi\")

// escape_typst_postfix — leading ( or . after a code expr (run after escape_typst)
escape_typst_postfix('(Selah) Praise him') // → \(Selah) Praise him
escape_typst_postfix('Praise the Lord')    // → Praise the Lord (no leading trigger)

// typst_inline — a verse expression joined to verse text starting with "("
typst_inline('#v(8)', '(Selah)')           // → #v(8)\(Selah)

Emitting code expressions next to text

Typst keeps reading code after an expression like #v(8) if the next character starts a postfix operator — ( (call), [ (content arg), or . (field access). escape_typst already neutralises [, but a leading ( or . in literal text would still be consumed. When you emit a code expression immediately followed by text, pass that text through escape_typst_postfix (after escape_typst), or use typst_inline to do both:

// ❌ "#v(8)(an aside)"  — Typst error: tries to call v(8)
output += '#v(8)' + escape_typst('(an aside)')

// ✅ "#v(8)\(an aside)" — literal parenthesis
output += typst_inline('#v(8)', '(an aside)')

You do not need escape_typst_postfix for text that follows plain markup, a space, or the start of a paragraph, nor for text inside a content block (#strong[…]) — there the text is in markup context and ( / . are already literal.