0.0.4 • Published 5 years ago
puptex v0.0.4
PupTex
Using Puppeteer(Headless Chrome) to render math:
- 2x faster than mathjax-node
- Configurable concurrent limit
- Renders CJK characters correctly
Usage
Node
const puptex = require('puptex')
;(async () => {
puptex.config({
concurrency: 2,
mathJax: {},
})
await puptex.launch()
const data = await puptex.renderMath('E=mc^2')
// data => {errors: [], svg: '<svg .../>', mml: '', widht: '', height: '', ...}
puptex.close()
})()Koa
API
puptex.config(options: Object): void
options: ObjectPupTex global configurationconcurrency: nubmer: Max Puppeteer page count, defaults to4mathJax: Object: MathJax configuration
puptex.launch(): Promise<void>
Launches browser.
puptex.renderMath(math: string, options: Object): Promise<data>
options: Objectformat: string:Tex|AsciiMath|MathML, defaults toTexmml: boolean: Whether to render<math>, defaults tofalsefontSize: string:<svg>root font size, defaults to15px
data: Objecterrors: ArrayMathJax error messagessvg: string<svg>markupmml: string<math>markupwidth: string<math>widthheight: string<svg>heightstyle: string<svg>style (vertical-align)
puptex.close(): void
Closes browser.