23 Oct 2007

Real Men Don't Use Word

Ever wondered how those guys at the IETF get the plaintext versions of the RFCs looking so darn good? Sure you have. (If you haven’t, well, you might as well skip this, because it’s all downhill from here.) As it turns out, it’s not really that hard. With a little work, you too can create great looking fixed-width plaintext – or at least fake your own RFC.

The backbone of ‘RFC Standard Format’ is ASCII text, 58 lines per page with each page terminated by a form feed, and 72 characters per line with each line terminated by a CR/LF. On top of that basic format, there are headers, footers, and a consistent title page, all of which can be seen on any RFC.

The traditional method of producing RFCs was with the Unix ‘nroff’ program, combined with a few handy addons. This process is documented in RFC 1543, “Instructions to RFC Authors.” Although still usable, this method, which requires a fair bit of manual formatting and doesn’t really separate content from presentation, has since been superceded by XML.

The current best practice is taken from RFC 2629 and its unofficial update. The RFC 2629 DTD is available here.

Basically, RFCs are written in a text editor using some simple, semantically-relevant (i.e. not style-based) elements. The entire document sits inside the <rfc> element, analogous to the <html> element in (X)HTML. There are other elements for the title, author’s name, section and subsection headers – even ASCII art. A template is available to get you started.

When complete, the XML document is fed into a processor and transformed into any number of output formats, including plaintext, HTML, or PDF. This is the beauty of XML: you write what you mean, the processor does the formatting. If you’re interested in looking at how the processor works, it’s all open source.

Since most everything in the RFC process is both well-documented and publicly available, it’s an excellent way to start learning about how to incorporate XML into a flexible workflow. And if you’re feeling up to it, you can pretty easily tweak the RFC DTDs and postprocessing utilities for your own needs.

This entry was converted from an older version of the site; if desired, it can be viewed in its original format.