Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/gromnitsky/mathjax-embed

Embed MathJax into HTML files using PhantomJS
https://github.com/gromnitsky/mathjax-embed

Last synced: about 6 hours ago
JSON representation

Embed MathJax into HTML files using PhantomJS

Awesome Lists containing this project

README

        

# mathjax-embed

A quick hack to "embed" mathjax into a html file. Actually it doesn't
embed anything, but renders the page in phantomjs & prints the result
to stdout. For mathjax configs w/o menu it means that the resulting
file to be displayed correctly **doesn't require JavaScript** at all.

See
[example01.mathjax.html](http://gromnitsky.users.sourceforge.net/articles/mathjax-embed/example01.mathjax.html),
for example.

Why don't use jsdom instead of phantomjs? jsdom is very slow for this
task.

## Requirements

* phantomjs 2.1.1
* nodejs 5.6.0

mathjax-embed doesn't use nodejs, we just need it to pull several pkgs
from npm.

## Installation

1. clone the repo in `$dir`
2. chdir `$dir`
3. run `npm install`
4. **symlink** `$dir/mathjax-embed-wrapper.sh` to a dir in PATH as `mathjax-embed`

## Usage

~~~
$ mathjax-embed
Usage: mathjax-embed [options] [file.html]

Available options:
-h, --help This text
-V, --version Print version number
-c, --conf FILE Use a custom .js mathjax config
-d, --dir DIR Mathjax source directory. Default: /home/alex/lib/\
software/alex/phantomjs/mathjax-embed/node_modules/mathjax
-f, --filters LIST A comma-separated list of filters that is applied \
after mathjax rendering. Use empty string "" to disable all. Default:\
pandoc-rm-br,script-rm-config,mathjax-rm-message
-v, --verbose (debug) Increase verbosity level
-x, --noexit (debug) Do not exit after rendering
~~~

The default mathjax config (use `-c` CLO to provide your own):

~~~
window.MathJax = {
showMathMenu: false,
extensions: ["tex2jax.js"],
tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]] },
jax: ["input/TeX", "output/SVG"]
}
~~~

By default mathjax-embed removes the surrounding `
` nodes round
`` that pandoc inserts. If you don't like this, run
mathjax-embed w/ `-f script-rm-config,mathjax-rm-message` option.

## Bugs

* Doesn't work under Windows

## License

MIT.