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

m2svg

v2.1.0

Published

make svg images for LaTex expressions

Readme

m2svg

This command-line tool processes a text file (usually html) which includes LaTex maths formulae. It converts the formulae into a representation of the math in one of three different ways: as svg images, as inline svg, or as MathML.

Installation

First, nodejs and npm must be installed on your computer. The procedure varies with the operating system:

For Linux, nodejs and npm can be installed from the distribution.

For Windows, download and run the installer from https://nodejs.org.

For Mac, ?

It is then necessary to open a command prompt:-- In windows 10 click on the windows icon and a list of programs will appear. In windows 11, click on the windows icon and in the box which then appears click "All Apps" to see the list. In the list there will be a Node.js folder and within it the Node.js command prompt; this is the one to use. In Linux the normal terminal will work.

In the command window type:

npm install -g m2svg

Use

The tool is run from a command prompt console. Make a directory where you want to work and place the file you want to convert in it. The file should also contain a line __style_holder inside the <style> section of the header. This will be replaced by css appropriate to the mode in use.

In the command window navigate to the working directory and type:

m2svg -i infile -o outfile -m mode -g margin

infile is the file to convert. Must be specified.

outfile will be the converted file. Must be specified.

mode is one of i for embedded images, s for inline svg, or m for MathML. If not specified the default is i.

margin specifies the space above and below display expressions in any css units. If not specified the default is 0.3em

In the case of mode i the image files will be placed in a subdirectory of the working directory called "images". This directory will be created if it does not already exist.

The program will normally run until the conversion is complete. It prints dots to show its progress. Pressing ctrl-c will stop the run. In the converted file the maths expressions, delimited by the tags \[ and \] for 'display' expressions or \( and \) for 'inline' expressions, are replaced in the output file by the appropriate text or links. These will contain a 'data-tex' attribute which shows the original maths expression.

If the program detects any tags that do not match up correctly it will print a message at the terminal showing the number of the line where the error occurred and continue working. If there are any errors in the math expressions then, in the i option, a message will be printed to the console describing the error and the number of the line near where it occurs. For the other options the error will be marked in the output file.

Reversion

There is a reverse option which will convert the processed file back to its original form. type:

m2svg -i infile -o outfile -r

(This does not change the css inserted in the header)

Updating

On subsequent occasions, to ensure you have the latest version of m2svg type npm update -g m2svg

Comparison of the modes

Image mode

This works with most browsers and ereaders. The names of the images will be a serial number. Results in a large file size for the images. Any duplicated expressions will link to the same image which helps to keep the size down . Some markup will not produce a usable image including: \tag{}. For tagged expressions you can use \text markup suitably spaced. The \multline markup will generate a multi-line image. But since we do not know at this stage the width of the device where the file will be displayed a width of around 1000 pixels is assumed. If this is not satisfactory \multline could be simulated using \aligned or \gather with \quad or other spacing.

Inline svg mode

This works with most browsers and ereaders. \tag{} markup will work even on old ereaders to make a label placed near the right margin. The file size will be large, even more than the image mode because duplicated expressions will result in duplicated inline svg.

MathML mode

Support for this is limited. Simple expressions will work in browsers but not old ereaders. \tag{} markup doesn't currently work in Firefox or Chromium. MathML works well in the Calibre epub viewer even with \tag{}. An advantage is small file size.