puptex
v0.0.4
Published
Using Puppeteer to render math.
Downloads
13
Maintainers
Readme
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: Object
PupTex global configurationconcurrency: nubmer
: Max Puppeteer page count, defaults to4
mathJax: Object
: MathJax configuration
puptex.launch(): Promise<void>
Launches browser.
puptex.renderMath(math: string, options: Object): Promise<data>
options: Object
format: string
:Tex
|AsciiMath
|MathML
, defaults toTex
mml: boolean
: Whether to render<math>
, defaults tofalse
fontSize: string
:<svg>
root font size, defaults to15px
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.