#448·toaruos

Rewrite `roff(1)` as an AST-generating parser in a library

Author: klangeCreated Apr 11, 2026Updated Apr 11, 2026

roff(1) was hacked together in an ADHD hyperfocus session and then iterated on for a couple weeks to support more functionality.

The current implementation tries to do everything in one pass and with little context, which has gotten us pretty far for displaying manual pages in a terminal, but I would like to get help-browser(1) ported over to viewing manual pages instead of the reduced TRT (Toaru Rich Text) subset it currently supports, and to do that I think roff(1) should 1) be a library we can reuse (libtoaru_roff(3)), and 2) produce an AST that can then be walked to render it.

An AST approach should also help to work around some edge cases and bugs in the current parser, and maybe even give us an opportunity to support tables correctly.

The main roff(1) application would consume this AST and lay out text for a terminal, as it does now, and help-browser(1) would consume the AST to produce a DOM-esque structure that can be laid out like we do in text_layout.krk(3) (but I do want this new text layout engine to remain in C so we can replace the various consumers of libtoaru_markup_text(3) with it).