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

pi-better-math

v0.1.0

Published

Typeset LaTeX math in Pi's TUI as multi-line Unicode art

Readme


Pi's built-in renderer flattens LaTeX to a single line. pi-better-math intercepts Markdown and typesets display math as real 2D Unicode art — stacked fractions, extended brackets, centered sum/integral limits, matrices — using libtexprintf (utftex, WASM).

Rendering is display-only. Session and model context stay unchanged. Any failure falls back to Pi's built-in LaTeX handling.

        ⎡             |xᵢ|² - 2ρ Re(xᵢ x̅ⱼ) ⎤
ℒ =  ∑  ⎢ log(1-ρ²) + ──────────────────── ⎥
    i<j ⎣                     1-ρ²         ⎦

Installation

Requires Pi 0.84.0 or newer (pi.registerMarkdownTransformer).

npm

pi install npm:pi-better-math

GitHub

pi install git:github.com/ZhenHuangLab/pi-better-math

Local checkout

git clone https://github.com/ZhenHuangLab/pi-better-math.git
pi install /absolute/path/to/pi-better-math

Restart Pi or run /reload after installing.

Usage

The extension is on by default once the render worker is ready.

| Command | Effect | | --- | --- | | /better-math | Show status | | /better-math on | Enable typesetting | | /better-math off | Disable typesetting | | /better-math toggle | Flip the current state |

Status looks like better-math ON calls=12 hits=4. calls is how many Markdown transforms ran; hits is how many actually changed. stalls=N appears if a render blew the 250ms deadline and the worker was replaced.

What gets typeset

  • Display math: $$...$$ and math-looking \[...\] become a fenced code block of multi-line Unicode art.
  • Inline math: $...$ that Pi cannot handle well (\frac, \sin, \left/\right, \rm, \!, …) is replaced with a single-line Unicode substitution so table cells stay intact.
  • Left alone: fenced code blocks, inline code, escaped prose \[optional\], and anything that fails to render.

How it works

  1. A Markdown transformer walks non-code segments and hands TeX to libtexprintf.
  2. Rendering happens on a worker thread, on a fresh WebAssembly instance every call. libtexprintf keeps global state in WASM memory; reusing an instance eventually returns garbage, and some inputs never terminate.
  3. The TUI thread drives the worker through SharedArrayBuffer + Atomics.wait with a 250ms deadline. A missed deadline kills and respawns the worker, then falls back to Pi's built-in LaTeX — so a bad formula cannot freeze the session.
  4. Output wider than the terminal, unknown TeX, or a worker error also falls back.

License

GPL-3.0-or-later. The runtime renderer is libtexprintf, which is GPL-3.0-or-later.