Many years ago, I got hooked on troff and all its companion programs. The best reference to understand and appreciate the design of these tools is UNIX Text Processing. Great book, still today.

Troff’s appeal comes mostly from its design philosophy, which is very much Unix’s: small tools that each do one job, connected by pipes.

The preprocessor ecosystem. Instead of one monolithic program, troff has a family of companions that each translate a specialized mini-language into plain troff requests:

  • tbl for tables
  • eqn for mathematics
  • pic for diagrams
  • grap for graphs and plots
  • refer (and bib tools) for bibliographies and citations

A typical pipeline looks like pic file | tbl | eqn | troff -ms | lpr. Each tool is simple and understandable, and you only pay for the ones you need. The languages are designed so that they read like what you are describing. The best example is eqn. If you are a LaTeX user, it is easy to appreciate the simplicity and readability.

I was also interested on understanding compilers at a deeper level so, long story short, I started to write transpilers in Python, so that one can generate nicely looking equations with LaTeX from eqn code, render your graphs with mermaid or graphviz, or targeting document formats other than postscript or PDF.

The first step was a transpiler for eqn. I recently dusted off the project with the intention of seeing how complex it can be to deploy a Python project using Pyodide, a Python distribution for WebAssembly (Wasm), to run the eqn2latex compiler directly within the user’s browser. The resulting LaTeX is then rendered via KaTeX.

The project is structured to be entirely self-contained. The build process generates a release/ directory containing only the essential assets (minified JavaScript, CSS, and the Python wheel). This makes the application suitable for deployment on any static hosting service, such as GitHub Pages, without the need for a dedicated application server.

You can try it online. The source code is freely available at github.

So being able to have a Python environment running in your browser with Pyodide means:

  • Deployment of python applications becomes platform agnostic and extremely easy. Users get a working Python environment by opening a URL. No Python version issues, no pip, no virtualenvs
  • Data remains in your local computer
  • The application scales automatically, since it runs on the local device
  • Interop with Javascript allows Python to share objects with Javascript, so you can combine Python’s data tooling with web UI frameworks, DOM access, and canvas/WebGL

Which opens up new interesting possibilities. But maybe it is easier to have some AI coding agent rewrite the project in Rust 😛

While the current web interface focuses on the eqn → LaTeX pipeline, the underlying package is designed for broader format transformations, including:

  • tbl to HTML
  • pic to SVG

These tools are still under development. eqn is the first to be ready for use