Troff to xml tools

There’s a lot of ways to convert troff document to xml, but, unfortunately, no standart way to do it. Thanks to the ux macro, utmac uses nroff itself for that task. That solution 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 −Tutf8 −mux | postxml > f.xml

The xml file produced this way follows a custom xml format, and some stylesheets convert this custom format to and from html and fodt.

xsltproc utohtml.xsl f.xml > f.html
xsltproc utofodt.xsl f.xml > f.fodt


Documentation and download

See the following files: troffxml, license.

Browse the git repository.