Man page with preserved text decorations, proportional text and fixed-width code

mantext formatting

How can I get contents of a man page without the text being wrapped around column 80 or so? I'd prefer the output to have proper formatting, line bolding, underscores, fixed-width font for examples etc.

However, all the command-line utilities and online man page resources provide either wrapped (http://linux.die.net) or un-formatted (man mmap | col -bx > mmap.txt), or improperly formatted (man -t mmap | ps2pdf - mmap.pdf) versions.

How can I get the properly formatted unwrapped text from a man page to be used for further booklet printing?

Best Answer

You have not specified your desired output format but from the things you've tried, it looks like you're not picky. This will produce correctly formatted, unwrapped html but it needs to be run on the actual man page file.

So, first locate the man file you're interested in:

$ man -w mmap
/usr/share/man/man2/mmap.2.gz

Them, run man2html on it:

man2html /usr/share/man/man2/mmap2.2.gz > mmap.html

Or, simply

zcat $(man -w mmap) | man2html > mmap.html

The output looks like this:

enter image description here

man2html was available in the Debian repository, I installed it with sudo apt-get install man2html.

Once you have it in HTML, you can translate to other formats easily enough: Actually, these won't work, they'll wrap the line automatically again.

man2html /usr/share/man/man1/grep.1.gz | html2ps > grep.ps
man2html /usr/share/man/man1/grep.1.gz | html2ps | ps2pdf14 - grep.man.pdf

`

Related Question