texsvg
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.1 • Public • Published

    texsvg

    NPM

    NPM version build Coverage Status Dependency status

    Converts TeX to SVG using MathJax and SVGO:

    texsvg(string)
    

    Examples

    Module:

    const texsvg = require('texsvg');
    
    texsvg('\\frac{a}{b}').then((svg) => console.log(svg));

    CLI:

    $ texsvg '\frac{a}{b}' fraction.svg

    Other:

    Installation

    Module

    NPM:

    $ npm install texsvg --save

    Yarn:

    $ yarn add texsvg

    CLI

    NPM:

    $ npm install texsvg --global

    Yarn:

    $ yarn global add texsvg

    NPX:

    $ npx texsvg

    Usage

    Module

    Import module:

    // CommonJS
    const texsvg = require('texsvg');
    
    // ES Modules
    import * as texsvg from 'texsvg';

    Convert TeX to SVG using Promise:

    const quadraticFormula = 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}';
    
    texsvg(quadraticFormula)
      .then((svg) => console.log(svg))
      .catch((err) => console.error(err));

    Convert TeX to SVG using async-await:

    const quadraticFormula = 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}';
    
    (async function () {
      try {
        const svg = await texsvg(quadraticFormula);
        console.log(svg);
      } catch (err) {
        console.error(err);
      }
    })();

    CLI

    Usage:

    $ texsvg <tex> <file>

    Convert TeX to SVG and log result to console:

    $ texsvg '\frac{a}{b}'

    Convert TeX to SVG and save result to file:

    $ texsvg '\frac{a}{b}' fraction.svg

    Testing

    Run tests with coverage:

    $ npm test

    Run tests in watch mode:

    $ npm run test:watch

    Run integration tests:

    $ npm run test:integration

    Lint files:

    $ npm run lint
    $ npm run lint:tsc

    Fix lint errors:

    $ npm run lint:fix

    Release

    Only collaborators with credentials can release and publish:

    $ npm run release
    $ git push --follow-tags && npm publish

    License

    MIT

    Install

    npm i texsvg

    DownloadsWeekly Downloads

    13

    Version

    1.3.1

    License

    MIT

    Unpacked Size

    15.1 kB

    Total Files

    10

    Last publish

    Collaborators

    • remarkablemark