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 🙏

© 2024 – Pkg Stats / Ryan Hefner

asciimath2tex

v1.5.0

Published

Library to convert AsciiMath to TeX

Downloads

1,040

Readme

asciimath2tex

JavaScript library to convert AsciiMath to TeX.

I wrote this so I could use KaTeX to render AsciiMath.

Usage

The library is written as an ECMAScript module but is also distributed as CommonJS and UMD modules.

The file asciimath2tex.js is an ES6 module which can be used in browsers that support it.

In a browser

If you can use ES6 modules, use asciimath2tex.js as-is:

import AsciiMathParser from 'asciimath2tex';

const parser = new AsciiMathParser();
const tex = parser.parse("int_(i=1)^10 x^2/2 dx");

parser.parse returns a string of TeX.

If you can't use ES6 modules, there is a UMD version. You can load it from unpkg.com, or create it yourself.

To load from unpkg

<script src="https://unpkg.com/[email protected]/dist/asciimath2tex.umd.js"></script>

To create the file locally

Clone this repository, and run:

npm install
npm run-script build

Copy the file dist/asciimath2tex.umd.js into your project.

Node.js / CommonJS

Install the package using npm:

npm install asciimath2tex

You can then load the package in your script:

const AsciiMathParser = require('asciimath2tex');

const parser = new AsciiMathParser();
const tex = parser.parse("int_(i=1)^10 x^2/2 dx");

Tests

There are some unit tests in test.html, copied from the asciimath repository.

All of the tests are rendered correctly by KaTeX, apart from \twoheadrightarrowtail, which it apparently doesn't support.