July 20–24, 2015
Portland, OR

A brief history of rendering math (and its future online)

Garen Torikian (GitHub)
11:30am–12:10pm Thursday, 07/23/2015
Solve E147/148
Average rating: ****.
(4.00, 3 ratings)

Prerequisite Knowledge

An interest in TeX is helpful, though not necessary. A basic understanding of parsing/tokenization might be helpful.


Almost 40 years ago, Donald Knuth released the first version of TeX, a typesetting system intended to simplify book publishing. A nice offshot of his goal was the creation of a new syntax that expressed mathematical equations in text. Through the evolution into LaTeX, Knuth’s language for representing math has become the standard and is used in academic papers across a variety of disciplines.

The rise of the internet produced new ways of expressing math in a browser. Instead of writing out TeX equations, MathML was conceived as a markup language to render math equations. The syntax of MathML was based in XML, much like regular HTML. Yet, after two decades, MathML didn’t catch on in the same way TeX did. A combination of poor browser support for MathML and the proliferation of simpler markup languages such as Markdown allowed for much easier exporting to HTML.

For people writing math on the web, the same TeX syntaxes devised by Knuth are still in use, because they’re simpler than embedding MathML. And the most popular tools for rendering these TeX equations for readers have been handled by client-side JavaScript, due to a variety of security issues with server-side TeX rendering. However, client-side techniques are extremely slow, provide varying output quality, and have the disadvantage of shifting the page layout as a reader views a website.

This talk explores newer sever-side techniques that are fast, secure, and accurate in their transformation of TeX for the web. This talk will cover:

  • The development of a Bison grammar to create a whitelist of safe math tokens for users to input
  • A C library to parse TeX equations out of the documents, and transform them into MathML, or more practically, SVGs and PNGs
  • A way to take advantage of the evolution of web techniques, such as HTTP caching, to store and show rendered math equations immediately to users
  • Introduction of several higher-level libraries that wrap these techniques, so that humans can write simpler markup interspersed with TeX equations, and easily convert it to HTML (or PDF).
Photo of Garen Torikian

Garen Torikian


Garen Torikian wants to help make the world a better place for humans and other sentient beings on Earth. He’s been programming ever since he learned how to make GIFs for his GeoCities website in the late ’90s. Garen writes, writes documentation, and writes tooling to help people who write documentation. He was a reader of books long before he was a writer of code. You can find him almost anywhere on the Internet by the handle @gjtorikian.