Translation rules for new output formats and troff macro packages can be added easily by providing a corresponding set of Scheme procedures (a ``back-end''). Version 1.0 of unroff includes back-ends for translating documents using the ``man'' and ``ms'' macros into the Hypertext Markup Language (HTML) version 2.0. Additional requests facilitate use of arbitrary hypertext links in troff documents.
In contrast to conventional troff ``converters'' (usually Perl scripts some of which process nroff output) unroff includes a full troff parser and closely mimics the troff processing engine. This enables unroff to handle user-defined macros, strings, and number registers, nested if-else requests, arbitrary fonts and font positions, low-level formatting requests such as \l, \c, and \h, and idiosyncrasies such as troff copy mode and the subtle differences between request and macro invocations. Unroff has adopted a number of groff extensions, among them long names for macros, strings, number registers, and special characters, and the escape sequences \$@ and \$*.
A new troff request and an extension to the `.ig' request allow for Scheme code to be embedded in troff documents; the code is then evaluated on the fly as the documents are processed by unroff.
Unroff may be viewed as a prototype for hybrid applications that use Scheme (in particular Elk) as their extension language. Approximately half of its source consists of portable ANSI C code, and the other half is written in Scheme and can be configured and tailored easily without the need to recompile unroff. Authors of Elk-based applications are encouraged to look into the source code or reuse parts of it for their own projects.
As the time-critical Scheme primitives provided of unroff have been coded in (efficient) C, its performance comes close to that of nroff processing the same troff input.
As unroff closely simulates ordinary troff, even large or complex documents (like technical reports or theses with many user-defined macros) can be translated to HTML automatically without having to add any structural cues to the documents.
The ``-man'' support has been tested with several hundred vendor- and user-supplied manual pages and has produced good results in all but less than a dozen cases (a few manual pages were found to make excessive use of low-level troff constructs or to include tbl output verbatim).
Rather than writing hypertext documents directly in HTML (which is cumbersome for long or complex texts), authors can continue using ordinary troff together with the usual preprocessors and macro packages. Unroff is then employed to produce the WWW form, while troff is used in the normal way to typeset the same text, producing the printed version (or, using nroff, an ASCII version if desired).
In this way authors of hypertext documents can take full advantage of the usual troff facilities such as user-defined macros, conditional text, tables, equations, and drawings, automatic table of contents generation, footnotes/endnotes, indexes, etc., none of which are available when composing documents directly in plain HTML.
Two new troff requests for embedding hypertext links in troff documents are provided by the unroff HTML back-end. Arbitrary forward and backward references using symbolic labels (rather than actual file names) among groups of troff source files are supported (see Figure 3). Another new request and another extension to `.ig' allow for HTML code to be embedded directly in troff documents. The hypertext capabilities are demonstrated by the troff source of the Programmer's Manual that is part of the unroff distribution.
If you do not have Elk at your site and do not want to install it, or if you just wish to have a quick look at unroff, download the binary distribution for your system. Otherwise, use of the source distribution is recommended.
The unroff executable is linked dynamically in the binary distributions for systems with shared libraries. Please send a message to email@example.com if you need a statically linked version, or if you think that statically linked executables should be offered in addition to or in place of the dynamically linked ones (or if you need an entirely different format).
January 28, 1996: Unofficial Patch with -me support
me-misc-patch (39 kbytes) · me-misc-patch.gz (11 kbytes)
February 13, 1997: Another Unofficial Patch
misc-patch-2 (79 kbytes) · misc-patch-2.gz (20 kbytes)