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 configuration-
concurrency: 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 messages -
svg: string
<svg>
markup -
mml: string
<math>
markup -
width: string
<math>
width -
height: string
<svg>
height -
style: string
<svg>
style (vertical-align)
-
puptex.close(): void
Closes browser.