December 11th 2016

linux, shell

Convert man pages to HTML with the Ansi Html Adapter (aha)


I was having a hard time trying to find a man-to-html converter that does what I want: just properly translate what little formatting man uses. What I found (groff, troff, roffit, man2html) seemed to be either outdated (using inline- or even html-styling) or buggy or simply unable to preserve man's formatting.

Thankfully I remembered aha, the Ansi Html Adapter.

This is what did it for me:

MAN_KEEP_FORMATTING=1 COLUMNS=90 man aha | \
ul | aha -s -b -t "aha man page" \
> /var/www/stuff/aha.html

(instructions straight from aha's man page)

Then I removed the content of <style>...</style> and replaced it with this:

body {
       color: #bbc; 
       background-color: #151617;
}
pre { font-family: 'xos4 terminus', monaco, monospace; }
.underline   {color:#9a3;}
.bold        {color:#f63;}

And here you can see the result.
image