Skip to content

Commit

Permalink
add code to convert downloaded manpage to html
Browse files Browse the repository at this point in the history
  • Loading branch information
TCY16 committed Dec 10, 2021
1 parent a71b51b commit 32f5586
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build/
.DS_Store
.vscode
source/_build
source/unbound-*
source/unbound-*
source/manpages/example.conf*
3 changes: 3 additions & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
# Execute custom script to download the latest version of Unbound
exec(open("get_unbound_latest.py").read())

import subprocess

rc = subprocess.call("./man2pre.sh unbound-1.14.0/doc/unbound.conf.5.in manpages/example.conf.html", shell=True)

# -- Options for Texinfo output ----------------------------------------------

Expand Down
26 changes: 26 additions & 0 deletions source/man2pre.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Unbound Website Sitetools man2pre.sh
# makes nicely formatted manual page in a <pre> block.
# first argument: manual page source.
# second argument: destination file.

if test "$#" -ne 2; then
echo "usage: man2pre <manpage.8> <destfile.html>"
echo "for unbound website tools"
exit 1
fi
echo "man2pre from $1 to $2"

sed s!\<title\>\</title\>!\<title\>$(basename $1)\</title\>! man_header.html > $2
echo '<pre class="man">' >> $2
# exclude the ul and sed statements for plain ascii.
# col -b removes backspaces. expand removes tabs.
# the ul fails on Fedora now, we can parse the groff output right away.
if groff -man -Tascii $1 | ul -txterm >/dev/null 2>&1; then
groff -man -Tascii $1 | ul -txterm | sed -e "s?<?\&lt;?g" -e "s?>?\&gt;?g" | sed -e 's?\[1m?<b>?g' -e 's?(B\[m?</b>?g' | sed -e 's?\[4m\[22m?</b><i>?g' -e 's?\[m?</b>?g' -e 's?\[m\000?</b>?g' -e 's?\[4m?<i>?g' -e 's?\[24m?</i>?g' -e 's?<\([bi]\)>\([^<]*\)\[0m?<\1>\2</\1>?g' -e 's?\[22m?</b>?g' | col -b | expand >> $2
else
groff -man -Tascii $1 | sed -e "s?<?\&lt;?g" -e "s?>?\&gt;?g" | sed -e 's?\[1m?<b>?g' -e 's?(B\[m?</b>?g' | sed -e 's?\[4m\[22m?</b><i>?g' -e 's?\[m?</b>?g' -e 's?\[m\000?</b>?g' -e 's?\[4m?<i>?g' -e 's?\[24m?</i>?g' -e 's?<\([bi]\)>\([^<]*\)\[0m?<\1>\2</\1>?g' -e 's?\[22m?</b>?g' | col -b | expand >> $2
fi
echo '</pre>' >> $2
#echo '<div id="writings"><div class="footer" style="border:0; font-size: 60%;">Generated from manual pages of version ' >> $2
#cat version.txt >> $2
cat man_footer.html >> $2
7 changes: 7 additions & 0 deletions source/man_footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<head>
<title></title>
<meta name="template" content="documentation/unbound_main" />
<meta name="is_man_subpage" content="True" />
</head>
<body>
1 change: 1 addition & 0 deletions source/man_header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
</body></html>

0 comments on commit 32f5586

Please sign in to comment.