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

@flurrux/math-layout-engine

v1.1.1

Published

math-layout like katex but simpler and primarily for canvas.

Readme

description

this is a small engine for calculating the layout of math-formulae.
unlike katex it produces a fixed layout in pojo format which can then be rendered to canvas.

try it live!

installation

npm install @flurrux/math-layout-engine

or add it to the dependencies

// package.json
...
"dependencies": {
    "math-layout": "@flurrux/math-layout-engine"
}
...

documentation

https://lucid-panini-eb3886.netlify.com/

usage

layout a formula and render it

import { 
    layoutFormula, 
    centerNodeOnCanvas, renderFormulaLayout, loadKatexFontFaces
} from '@flurrux/math-layout-engine';

const formula = {
    "type": "mathlist",
    "items": [
        { "type": "ord", "value": "1" },
        { "type": "bin", "value": "+" },
        { "type": "ord", "value": "2" },
        { "type": "bin", "value": "+" },
        { "type": "ord", "value": "3" },
        { "type": "bin", "value": "+" },
        { "type": "ord", "value": "⋯" },
        { "type": "rel", "value": "=" },
        { "type": "ord", "value": "-" },
        {
            "type": "fraction",
            "numerator": { "type": "ord", "value": "1" },
            "denominator": { "type": "ord", "text": "12" }
        }
    ]
};
const layoutedFormula = layoutFormula(formula);

//render the formula
document.body.insertAdjacentHTML("beforeend", `
    <canvas id="math-canvas" width=800 height=400></canvas>
`);
const canvas = document.querySelector("#math-canvas");
const ctx = canvas.getContext("2d");
//loading the fonts is asynchronous
loadKatexFontFaces().then(
    () => renderFormulaLayout(canvas, ctx, centerNodeOnCanvas(canvas, layoutedFormula))
);

examples

{
    type: "mathlist",
    items: [
        { type: "ord", value: "f" },
        { type: "open", value: "(" },
        { type: "ord", value: "x" },
        { type: "close", value: ")" },
        { type: "rel", value: "=" },
        { type: "ord", value: "x" },
        { type: "bin", value: "*" },
        { type: "open", value: "(" },
        { type: "ord", value: "x" },
        { type: "ord", value: "+" },
        { type: "ord", value: "1" },
        { type: "close", value: ")" },
    ]
}

rendered formula

credits

i used katex as a reference for my renderings.
also the font-data and fonts are directly taken from katex.

furthermore i tried to implement the algorithms as described in the texbook (starting at page 440) where it was possible. it still differs at some places though and i'm not sure if i understand them correctly.