man doesn’t, but it’s based on troff which is a fully-featured typesetting language, with a similar amount of power as TeX or PostScript.
The modern mdoc macros are rich enough that I don’t remember needing to drop down to low-level troff directives in my man pages, but the old man macros are comparatively feeble. Sadly the mandoc renderer needs to implement large amounts of troff for compatibility with the weird tricks that man pages use to fill gaps in the man macros.
does the macro expansion really need to run on every invocation? can’t you just ship pre expanded man pages that just need minor reformatting (for alignment or whatever) and printing out?
The macros would be used to adapt to different widths and scenarios, so preformatting them does kinda of miss the point. That’s a trade-off individual systems can make.
Groff is fairly slow because every invocation is a macro for the raw troff(7) requests. Mandoc is faster because it already knows the man(7) and mdoc(7) languages and doesn’t lower everything to troff. For example, on the 31,000 line gcc manual page, mandoc requires 87ms and groff 261 ms, on my machine.
Not really a reason to preformat, unless you have a 1980s VAX.
The mandoc roff reference contains support for comparisons, arithmetic, loops, and recursion. Although this is not a formal proof for Turing completeness, these features are strongly suggesting it.
why does man need the ability to compute things at all
to fly to the moon
A question asked by many a schoolboy faced with a difficult arithmetic problem.
man doesn’t, but it’s based on troff which is a fully-featured typesetting language, with a similar amount of power as TeX or PostScript.
The modern mdoc macros are rich enough that I don’t remember needing to drop down to low-level troff directives in my man pages, but the old man macros are comparatively feeble. Sadly the mandoc renderer needs to implement large amounts of troff for compatibility with the weird tricks that man pages use to fill gaps in the man macros.
does the macro expansion really need to run on every invocation? can’t you just ship pre expanded man pages that just need minor reformatting (for alignment or whatever) and printing out?
Yeah, most systems have catman directories of preformatted man pages.
The macros would be used to adapt to different widths and scenarios, so preformatting them does kinda of miss the point. That’s a trade-off individual systems can make.
Groff is fairly slow because every invocation is a macro for the raw troff(7) requests. Mandoc is faster because it already knows the man(7) and mdoc(7) languages and doesn’t lower everything to troff. For example, on the 31,000 line gcc manual page, mandoc requires 87ms and groff 261 ms, on my machine.
Not really a reason to preformat, unless you have a 1980s VAX.
I don’t think that’ll work.mandocisn’t Turing complete I’m pretty sure.I stand corrected, see below. My bad.
The mandoc roff reference contains support for comparisons, arithmetic, loops, and recursion. Although this is not a formal proof for Turing completeness, these features are strongly suggesting it.
Huh, I’ll be damned. If you had asked me I would’ve been 99% sure OpenBSD mandoc didn’t support loops and such. TIL.
Actually had me googling OpenBSS :<
It’s already done in the repo! You can try it: