Hello Branden, G. Branden Robinson wrote on Tue, Sep 08, 2026 at 09:24:55PM -0500:
> I think every implementation of deroff breaks itself on the shoals of > the fact that the *roff language can't be statically, deterministically > processed. As I understand it there are multiple reasons for this, but > some of the simplest are the following facts. > > 1. Macros can test properties of the rendered document, like the page > number, and change their behavior accordingly. > > 2. Macros can overwrite, append to, and delete their own definitions, > and those of other macros. > > Further, *roff is a Turing-complete language, which might be a corollary > of, or equivalent in some way to, point (2). > > I refer the reader, as I often do, to: > > https://www.cs.dartmouth.edu/doug/barem4.txt > > Consequently, the only truly reliable way to strip a *roff document of > all formatting is, funnily enough...to format it with *roff. I fully concur. That's precisely the reason why the following two are essentially unmaintained: - demandoc(1) in the mandoc package - deroff(1) in OpenBSD I almost never hear anyone talking about these programs, presumably because they are almost never needed for anything. Almost never as in: i hear about them from users at most once every several years. For manual pages, i routinely recommend using mandoc input_file | col -b instead, which should be better for any potential use case. For general purpose typeset documents, where people more frequently employ non-trivial escape, request, and macro programming, the argument to use groff -a only becomes stronger. The only use case i'm aware of where deroff(7) is still occasionally used is for spell checking roff(7), man(7), and mdoc(7) documents with the traditional spell(1) program. Some people argue that for spell checking, what you want to check is natural-language words appearing in the source document, not the formatted document because that may include results from text production macros. But that is a very weak argument at best, if it has any merit at all. The harm in using "mandoc input_file | col -b" or "groff -a" for spell checking is really hard to see. Spell checking is a very inexact exercise anyway. > This is a point I have struggled to make to Alex Colomar.[1] I guess > I'll have to come up with a convincing demonstration. Of roff(7) being capable of iteration and recursion? Is https://mandoc.bsd.lv/mdoc/details/recursion.html good enough? Or my deliberately vicious Fibonacci generator that employs recursive self-expanding, self-consuming, and tail-recursive macros? https://mandoc.bsd.lv/mdoc/details/redefine_self.mdoc Funnily, using redefine_self.mdoc as an input file, output from "deroff" and "groff -a" has absolutely nothing in common with each other, and demandoc is closer to groff -a than it is to deroff. The only reason for not having deleted demandoc(1) and deroff(1) yet is that it's not particularly pressing because both don't eat much hay and consume almost no maintenance effort. But i really see no reason for keeping them. Yours, Ingo
