Converts TeX to SVG using MathJax and SVGO:
texsvg(string)
Module:
const texsvg = require('texsvg');
texsvg('\\frac{a}{b}').then((svg) => console.log(svg));
CLI:
texsvg '\frac{a}{b}' fraction.svg
Other:
NPM:
npm install texsvg
Yarn:
yarn add texsvg
NPM:
npm install --global texsvg
Yarn:
yarn global add texsvg
NPX:
npx texsvg
Import with ES Modules:
import * as texsvg from 'texsvg';
Or require with CommonJS:
const texsvg = require('texsvg');
Convert TeX to SVG using async-await:
const quadraticFormula = 'x=\\frac{-b\\pm\\sqrt{b^2-4ac}}{2a}';
(async () => {
try {
const svg = await texsvg(quadraticFormula);
console.log(svg);
} catch (err) {
console.error(err);
}
})();
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));
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
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 is automated with Release Please.