(Beta version : user interface may change)

Troff to xml tools

There’s a lot of ways to convert troff document to xml, but, unfortunately, no standart way to do this. utmac use nroff itself to this task, and a special macro (ux). This has the advantage to be easy to implement, and to be troff compliant, since one can use all the troff commands he wants in his document. But to do that well, a pre-processor (prexml) and a post-processor (postxml) are needed, so that the command line is as follow :

prexml f.tr | nroff -Tlocale -mux | \
postxml > f.xml

The xml file produced this way follow a custom xml format, — most often, the tags of the xml file are equivalent to the troff utmac macro, ie .H1 becomes <H1>. The following xml stylesheets convert the custom xml format to and from famous xml files, such as html and fodt.

To use these stylesheets, a simple shell script (trxtr) call the xsltproc processor. So, the complete command line, to translate an utmac file to html should be :

prexml f.tr | nroff -Tlocale -mux | \
postxml | trxtr html > f.html



See the following files : readme, postxml, trxtr, bsd2, log, or download utroff-troffxml.pdf.