mmmm (pronounced with rising inflection, as if pausing before critisism) is a typesetting and layout methodology using POSIX tooling. my working copy would take a few more rounds of implementation to be worth presenting complete: here I'll lay out the basic techniques that you might use as a base for a system fit for similar purposes. if you have a terminal available you may be surprised to see it already installed:
$ which m4
this will include downsides of m4 features and recourse possible by composition of other POSIX tools. in fact, no implementation is provided: only an outline. working backwards from output formats

brief implementation language

basic techniques

C preprocessor