Roff, Groff, and the Roots of Computer Typesetting

Today we take it for granted that computers can set type, but from the 60s to the 80s, most computers used either teletypes or character-based screens. The Xerox Star and Apple Lisa and Apple Macs, and PostScript changed this, but before them, typesetting was done using weird command languages that would send pages to special typesetters. The most well known setup was troff, which lives on in groff and in Solaris. The troff system used a computer typesetter called a CAT, and it wasn't a bitmap laser printer. It has these fonts that were spools of film that were photographs of letters. The font sizes were created by projecting the image of the letter onto the page at different sizes. I believe the rest of the process was like a photocopier - the toner goes on, and then is transferred to the paper, and fused.

Anyway, groff lives. There's a man page roff(7) that explains it all. It's also at this web page.

What's fascinating is that two popular, similar typesetting apps exist: groff, and TeX. Despite years of desktop GUI software, both are still in use today. This is probably partly due to their add-on software, and their ease-of-input. Neither are easy to use, but once you know the commands, it's pretty quick to type documents in either system.

The most important add-on software are the programs that handle notes and references; this is refer in troff, and bibtex for TeX. These are simple databases of citations, but having these integrated into the document formatting system is a time-saver. I used to write papers with troff, and it was nice using a bibliography package.

I've forgotten how to write papers with troff, but here's an article explaining how to write them in groff, and it's pretty simple if you're into this kind of formatting.

There are a couple of errors in the text, regarding previewing. There are two preview methods: xditview and gv (Ghostview).
If the file is named temp.tr, the two commands are:

troff -mms temp.tr -TX75 | xditview -

and

troff -mms temp.tr | grops | gv -

The gv style is better, because it's more accurate. You can also use evince, the document viewer in Ubuntu, but that would require sending grops output to a file, then opening the file with evince.

HTML

The main way to convert from troff to HTML is with the "html" output device. The command is:

groff -mms temp.tr -Thtml > temp.html

There's also a fancier xhtml device, but it's not in my install yet (in 2012).

There are some other tools to convert from troff to HTML, but they aren't translating pure troff. Most do a conversion from troff with a specific macro package. That's probably the optimal design decision, because the macros and HTML operate at roughly the same level of semantic markup. The troff language deals with things like point sizes, exact positioning, and word wrapping; the macro packages are designed to allow the author to ignore those details and focus on document structure, with a little additional tweaking of the layout.

The problem is, there are a few popular macro packages.

The most popular macro package is man: man2html
troff2page does man and ms.
For the ms macro package: troff2html, troff_to_html
For the mm macro package: Converting Troff

The man2html converter is the most popular, but it doesn't parse the man file - it parses the output of nroff.