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

asciimath

v0.0.1

Published

Convert ASCII math notation (and some LaTeX) to Presentation MathML in the browser.

Readme

asciimath

A modern ESM/TypeScript build of the classic ASCIIMathML library. Converts simple, calculator-style math expressions on a web page into Presentation MathML (and, optionally, into LaTeX-rendered images or MathJax input).

Install

npm install asciimath

Entry points

| Import | Source | Description | | ----------------------- | ---------------------------- | ----------------------------------------------------------------- | | asciimath | src/index.ts | Main ASCIIMathML → MathML translator. | | asciimath/latex | src/latex.ts | LaTeXMathML translator (subset of LaTeX → MathML). | | asciimath/tex-img | src/tex-img.ts | ASCIIMath → TeX, suitable for image-based rendering pipelines. | | asciimath/mathjax | src/mathjax.ts | MathJax InputJax.AsciiMath plugin registration. |

Every entry point publishes types alongside the JavaScript, so TypeScript projects get autocomplete and signatures out of the box.

Usage

ASCIIMathML (auto-translate on load)

Importing the main entry point in a browser automatically translates the <body> of the document on DOMContentLoaded, mirroring the behavior of the original <script src="ASCIIMathML.js"> drop-in:

import "asciimath";

Programmatic API

import {
  parseMath,
  translate,
  AMprocessNode,
  newcommand,
  newsymbol,
} from "asciimath";

// Convert a string to a MathML <math> Node.
const mathNode = parseMath("sum_(i=1)^n i = n(n+1)/2");
document.body.appendChild(mathNode);

// Re-run translation on a specific subtree.
AMprocessNode(document.getElementById("content"), false);

// Define a custom macro.
newcommand("RR", "\\mathbb{R}");

// Or register a brand-new symbol with its own MathML mapping.
newsymbol({ input: "lub", tag: "mo", output: "⊔", ttype: 0 });

See asciimath.org/#syntax for the input language reference.

LaTeXMathML

import { LatexToMathML, LMprocessNode } from "asciimath/latex";

// Convert a LaTeX string to a MathML string.
const html = LatexToMathML("\\frac{a}{b}");

// Translate every LaTeX expression inside a subtree in place.
LMprocessNode(document.getElementById("content"), false);

ASCIIMath → TeX (image rendering)

asciimath/tex-img produces TeX source from ASCIIMath, intended for pipelines that render math as images (e.g. via a CGI LaTeX renderer):

import { AMTparseAMtoTeX, AMTconfig } from "asciimath/tex-img";

// Point at your TeX-to-image endpoint (the original `AMTcgiloc` global).
globalThis.AMTcgiloc = "https://example.com/cgi-bin/mathtex.cgi";

const tex = AMTparseAMtoTeX("int_0^1 x^2 dx");
// → "{\\int_{{0}}^{{1}}}{x}^{{2}}{\\left.{d}{x}\\right.}"

MathJax plugin

import { register } from "asciimath/mathjax";

// Call after MathJax has loaded; `MathJax.InputJax.AsciiMath` must exist.
register();

Configuration

Defaults match the original ASCIIMathML distribution. To change settings that the original library exposed via top-level vars (e.g. decimalsign, listseparator), use the corresponding setters:

import { setdecimal, setlistseparator } from "asciimath";

setdecimal(",");
setlistseparator(";");

Development

npm install      # install dev dependencies (TypeScript, jsdom)
npm run build    # compile src/*.ts to dist/
npm run check    # type-check without emitting
npm test         # build, then run the Node test suite
npm run serve    # build and serve test/index.html via miniserve

The browser test pages in test/ (issue*test.html, livetest.html, etc.) are smoke-tested headlessly by test/smoke.test.mjs: every backtick-delimited ASCIIMath expression must parse to a non-empty <math> node. They are not part of the published package.