0.0.4 • Published 3 years ago

puptex v0.0.4

Weekly downloads
4
License
MIT
Repository
-
Last release
3 years ago

PupTex

build status npm version

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

examples/puptex-koa

API

puptex.config(options: Object): void

  • options: Object PupTex global configuration

puptex.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 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.