项目作者: ambar

项目描述 :
Using Puppeteer(Headless Chrome) to render math.
高级语言: JavaScript
项目地址: git://github.com/ambar/puptex.git
创建时间: 2017-09-05T09:43:16Z
项目社区:https://github.com/ambar/puptex

开源协议:

下载


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

  1. const puptex = require('puptex')
  2. ;(async () => {
  3. puptex.config({
  4. concurrency: 2,
  5. mathJax: {},
  6. })
  7. await puptex.launch()
  8. const data = await puptex.renderMath('E=mc^2')
  9. // data => {errors: [], svg: '<svg ...></svg>', mml: '', widht: '', height: '', ...}
  10. puptex.close()
  11. })()

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.