Blog posts about free software, usage, configuration and my involvement in free software projects.

Posted by Sebastian Humenda at 10.11.2015, 20:53

GladTeX 0.6 has been released. This article introduces the new features of GladTeX and will give practical examples on how to use GladTeX, i.e. to edit MarkDown files.

GladTeX is a preprocessor for HTML files to enable math formulas by embedding images and generating an alternative text for blind people. Everything surrounded by <eq>...</eq> will be taken as a LaTeX formula and converted.
With the new version it can be also used for MarkDown editing and for formula image creation (see later).

## Where To Get It

GladTeX has been rewritten in Python. Before it has been a Perl/C mixture which was hard to port and not working on Windows. Python in contrast is a nowadays wide-spread scripting language with the ability to write platform-independent code very easily. From this version on, there's a Windows executable available. On Debian-derived systems (like Ubuntu) you can also install GladTeX using

The latest version can be easily build from source. It boils down to execute sudo python3 setup.py install on the command line.

To run GladTeX you will need a LaTeX distribution like MikTeX (for Windows) containing preview.sty and dvipng. Both are included in MikTeX and Texlive.

## Embedding GladTeX Into Other Applications

I've decided to split the program into two parts: a library and a command line frontend. This way it's easily possible to embed the library gleetex into another application. This application can choose to either also parse HTML files and produce HTML with formula images or just use gleetex as a simple way to convert LaTeX formulas to images. There's no separate library documentation yet, but I've payed attention to document all the classes extensively, so feel free to just browse the source.

Shell-piping support has been added as well, so that images can be produced like this:

echo '<eq>\gamma\alpha</eq>' | gladtex -d images -o /dev/null

or on Windows

echo "<eq>\gamma\alpha</eq>" | gladtex -d images -o nul

Additionally there's a cache containing formula → image mappings which is now a gzipped json file and can be hence post-processed by scripts as well.

It is possible to embed formulas into MarkDown files when using Pandoc as a converter. It is as easy as surrounding formulas by a $sign (or double $$for display math), like this: This is an inline formula: \frac{1}{m^2} This is displaymath$$\frac{\frac{1}{m}}{\big(\tau\cdot (\pi + \gamma)\big)}$\$

Pandoc brings the --gladtex option and with the new GladTeX version, converting a file called input.md is as easy as:

pandoc --smart -t html --gladtex input.md | gladtex -d images -o output.html

Which will create a file called output.html with images containing the desired formulas and all images located in a separate images directory.

## High Test Coverage

Something which is not immediately visible from outside is that the new GladTeX is now fully tested with unit tests. I hope to make GladTeX as bug free as possible. It actually saved a considerable amount of time when developing GladTeX, because I discovered a lot of problems very early.