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

cellml-text-editor

v0.2.1

Published

A CellML text editor library for parsing and generating CellML text representations.

Readme

CellML Text Editor

A robust, zero-dependency TypeScript library for parsing, validating, and manipulating CellML Text format.

This library provides a bi-directional bridge between the human-readable CellML Text format and standard CellML 2.0 XML. It includes a recursive descent parser, a MathML-to-LaTeX converter, and a pretty-printing code generator.

Features

  • Robust Parsing: Handles complex nested logic, comments, and operator precedence.
  • Bi-directional: Convert CellML Text → XML and XML → CellML Text.
  • LaTeX Generation: Instantly convert MathML logic into display-ready LaTeX strings.
  • Error Reporting: Precise syntax error tracking with line numbers.
  • Source Tracking: Maps output XML/MathML back to original source lines (great for debuggers/editors).
  • Lightweight: Zero runtime dependencies.

Installation

npm install cellml-text-editor
# or
yarn add cellml-text-editor

Quick Start

1. Parse Text to XML

import { CellMLTextParser } from 'cellml-text-editor';

const code = `
def model my_model
    def comp my_component
        var a: dimension_less {init: 10};
    enddef;
enddef;
`;

const parser = new CellMLTextParser();
const result = parser.parse(code);

if (result.errors.length > 0) {
    console.error("Parse failed:", result.errors);
} else {
    console.log("Generated XML:", result.xml);
}

2. Convert XML to Text

import { CellMLTextGenerator } from 'cellml-text-editor';

const generator = new CellMLTextGenerator();
// Assume 'doc' is a CellML XMLDocument
const textOutput = generator.generate(doc);

console.log(textOutput);

3. Generate LaTeX for Equations

Useful for rendering mathematical previews of your CellML models.

import { CellMLLatexGenerator } from 'cellml-text-editor';

// Assume 'mathNode' is a MathML Element from your parsed document
const latexGen = new CellMLLatexGenerator();
const latexString = latexGen.convert(mathNode);

console.log(latexString); // e.g. "\frac{dV}{dt} = -I_{ion}"

Configuration

You can configure the parser to tag the output XML with source line numbers. This is enabled by default to help build editor integrations (like highlighting the source line when clicking a diagram).

import { CellMLTextParser } from 'cellml-text-editor';

// Default behavior: Adds 'data-source-location' attributes to XML
const parser = new CellMLTextParser();

// Custom behavior: Change the attribute name
const debugParser = new CellMLTextParser({
    sourceLineAttribute: 'data-debug-location'
});

// Production behavior: Disable source tracking entirely (clean XML)
const cleanParser = new CellMLTextParser({
    sourceLineAttribute: null
});

Development

If you want to contribute to this library or run the test harness:

  1. Clone the repo
  2. Install dependencies:
yarn
  1. Run the test playground: This launches a Vue 3 app that lets you type CellML Text and see real-time XML and LaTeX previews.
yarn dev
  1. Build the library: Produces the dist/ folder ready for publishing.
yarn build

License

Apache 2.0