Posted by mojavelinux on Aug 26, 2016; 11:12am URL: https://discuss.asciidoctor.org/Embed-man-pages-in-a-book-tp4906p4920.html
Sgruttendio,
We're certainly glad to have you here! I think what you'll find is that this is a great community that loves to solve problems together. That's why I encourage you to stay. If you run into challenges, you'll find a lot of shoulders to lean on around here.
I have good news for you regarding the solution I discovered...which builds on what @eskwayrd initially proposed. If, ahead of time, you use the script I made to generate the HTML versions of the man page, it's possible to use that output in PDF. Asciidoctor PDF supports an "HTML-lite" for inline formatting.
COMMAND=$1
MANWIDTH=80 man $COMMAND | \
col -b | \
vim -c 'set ft=man nomod' \
-c ':TOhtml' \
-c ":w! `pwd`/$COMMAND.html" \
-c ':qa!' - && \
sed -i -n -e '/^<pre /,/^<\/pre>$/{ /^<pre /d; /^<\/pre>$/d; s/<span[^>]\+>\(.*\)<\/span>/<strong>\1<\/strong>/; p }' $COMMAND.html
unset COMMAND
Then embed the result in AsciiDoc:
[subs=none]
----
include::ls.html[]
----
Just to prove it's possible, I attached an example of the ls man page included in a PDF generated by Asciidoctor PDF.
In the end, it just requires some transformation magic. After all, it's just text ;)
> Which is in your opinion the best reading to start with writing extensions?