Using Puppeteer(Headless Chrome) to render math.
Using Puppeteer(Headless Chrome) to render math:
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 ...></svg>', mml: '', widht: '', height: '', ...}
puptex.close()
})()
Koa
puptex.config(options: Object): void
options: Object
PupTex global configurationconcurrency: nubmer
: Max Puppeteer page count, defaults to 4
mathJax: Object
: MathJax configurationpuptex.launch(): Promise<void>
Launches browser.
puptex.renderMath(math: string, options: Object): Promise<data>
options: Object
format: string
: Tex
| AsciiMath
| MathML
, defaults to Tex
mml: boolean
: Whether to render <math>
, defaults to false
fontSize: string
: <svg>
root font size, defaults to 15px
data: Object
errors: Array
MathJax error messagessvg: string
<svg>
markupmml: string
<math>
markupwidth: string
<math>
widthheight: string
<svg>
heightstyle: string
<svg>
style (vertical-align)puptex.close(): void
Closes browser.