I can't tell if you want some "special" formatting that's different from standard formatting that's done using ANSI escape codes:
I'd prefer the output to have proper formatting, line bolding,
underscores, fixed-width font for examples etc.
(does "proper just mean "the normal way that man does it"?)
But... I will answer with regards to this part of your question:
How can I get contents of a man page without the text being wrapped
around column 80 or so?
Just use:
MANWIDTH=9999 man mmap > mmap.txt
or:
COLUMNS=9999 man mmap > mmap.txt
If you need to do something fancier, you can use groff directly, but it doesn't seem to respect the COLUMNS variable. This awesome answer provided a solution: use the arguments -rLL <number> and -rLT <number> to groff (apparently undocumented, but man itself uses them).
For example, I use the following function to dump man pages to plain-text (intentionally disabling the formatting that you want to preserve, but just as an example):
man2txt() {
groff -t -e -mandoc -Tascii -a -rLL=9999 -rLT=9999 "$(man -w "${1}")"
}
You could remove the -Tascii -a and add in whatever groff options you want, if you do in fact want to do anything special in that regard.
` and `
– Mikel Feb 02 '14 at 20:23` cause actual line breaks.