Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ambar/puptex
Using Puppeteer(Headless Chrome) to render math.
https://github.com/ambar/puptex
math mathjax puppeteer
Last synced: about 2 months ago
JSON representation
Using Puppeteer(Headless Chrome) to render math.
- Host: GitHub
- URL: https://github.com/ambar/puptex
- Owner: ambar
- Created: 2017-09-05T09:43:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-04T04:04:01.000Z (almost 2 years ago)
- Last Synced: 2024-04-08T16:13:24.433Z (9 months ago)
- Topics: math, mathjax, puppeteer
- Language: JavaScript
- Homepage:
- Size: 1.1 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# PupTex
[![build status](https://img.shields.io/travis/ambar/puptex/master.svg?style=flat-square)](https://travis-ci.org/ambar/puptex)
[![npm version](https://img.shields.io/npm/v/puptex.svg?style=flat-square)](https://www.npmjs.com/package/puptex)Using [Puppeteer](https://github.com/GoogleChrome/puppeteer)(Headless Chrome) to render math:
- 2x faster than [mathjax-node](https://github.com/mathjax/MathJax-node)
- Configurable concurrent limit
- Renders CJK characters correctly## Usage
**Node**
```js
const puptex = require('puptex');(async () => {
puptex.config({
concurrency: 2,
mathJax: {},
})
await puptex.launch()
const data = await puptex.renderMath('E=mc^2')
// data => {errors: [], svg: '', mml: '', widht: '', height: '', ...}
puptex.close()
})()
```**Koa**
[examples/puptex-koa](./examples/puptex-koa)
## API
### `puptex.config(options: Object): void`
- `options: Object` PupTex global configuration
- `concurrency: nubmer`: Max Puppeteer page count, defaults to `4`
- `mathJax: Object`: [MathJax configuration](http://docs.mathjax.org/en/latest/options/index.html)### `puptex.launch(): Promise`
Launches browser.
### `puptex.renderMath(math: string, options: Object): Promise`
- `options: Object`
- `format: string`: `Tex` | `AsciiMath` | `MathML`, defaults to `Tex`
- `mml: boolean`: Whether to render ``, defaults to `false`
- `fontSize: string`: `` root font size, defaults to `15px`
- `data: Object`
- `errors: Array` MathJax error messages
- `svg: string` `` markup
- `mml: string` `` markup
- `width: string` `` width
- `height: string` `` height
- `style: string` `` style (vertical-align)### `puptex.close(): void`
Closes browser.