Khan/KaTeX — pull request #71 by jmendeth (2014-09-17 14:01:27+00:00)
Title: Simple CLI

This PR adds a simple command line interface to KaTeX. (closes #55)

It just reads TeX from standard input (until EOF is found), renders it through `katex.renderToString`, and outputs the HTML to standard output. Given that KaTeX needs no or little customization, command-line arguments are ignored for now.

The CLI ([`cli.js`](https://github.com/jmendeth/KaTeX/blob/simple-cli/cli.js)) is exported via `package.json`, so that installing KaTeX globally:

~~~ bash
$ sudo npm install -g katex
~~~

Will also install a `katex` command system-wide, that is a symlink to the CLI. Then, this:

~~~ bash
$ katex <<< "a = b \times c"
~~~

outputs

~~~
a=b×c
~~~

This allows webservers written in other languages to easily interface with KaTeX to render math server-side.