Converts TeX to SVG.
npm install texsvg



Convert TeX to SVG using MathJax and SVGO:
```
texsvg(string)
CLI:
`sh`
npx texsvg '\frac{a}{b}' fraction.svg
Script:
`js
const texsvg = require('texsvg');
texsvg('\\frac{a}{b}').then((svg) => console.log(svg));
`
NPM:
`sh`
npm install texsvg
Yarn:
`sh`
yarn add texsvg
NPM:
`sh`
npm install --global texsvg
Yarn:
`sh`
yarn global add texsvg
NPX:
`sh`
npx texsvg
Import with ES Modules:
`js`
import texsvg from 'texsvg';
Or require with CommonJS:
`js`
const texsvg = require('texsvg');
Convert TeX to SVG using async-await:
`js
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:
`js
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 without optimization:
`js`
texsvg('8', { optimize: false });
Usage:
`sh`
texsvg
Convert TeX to SVG and log result to console:
`sh`
texsvg '\frac{a}{b}'
Convert TeX to SVG without optimization:
`sh`
texsvg '\frac{a}{b}' --optimize=false
Convert TeX to SVG and save result to file:
`sh`
texsvg '\frac{a}{b}' fraction.svg
Run tests with coverage:
`sh`
npm test
Run tests in watch mode:
`sh`
npm run test:watch
Run integration tests:
`sh`
npm run test:integration
Lint files:
`sh`
npm run lint
npm run lint:tsc
Fix lint errors:
`sh``
npm run lint:fix
- StackBlitz (Script)
- StackBlitz (Server)
- texsvg-server
- JSFiddle
Release is automated with Release Please.