From 32f558605c7c954dedd14aebde311d6004dc14d5 Mon Sep 17 00:00:00 2001 From: TCY16 Date: Fri, 10 Dec 2021 14:52:00 +0100 Subject: [PATCH] add code to convert downloaded manpage to html --- .gitignore | 3 ++- source/conf.py | 3 +++ source/man2pre.sh | 26 ++++++++++++++++++++++++++ source/man_footer.html | 7 +++++++ source/man_header.html | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 source/man2pre.sh create mode 100644 source/man_footer.html create mode 100644 source/man_header.html diff --git a/.gitignore b/.gitignore index b357323..587fac4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ build/ .DS_Store .vscode source/_build -source/unbound-* \ No newline at end of file +source/unbound-* +source/manpages/example.conf* \ No newline at end of file diff --git a/source/conf.py b/source/conf.py index 229931c..5e3939d 100644 --- a/source/conf.py +++ b/source/conf.py @@ -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 ---------------------------------------------- diff --git a/source/man2pre.sh b/source/man2pre.sh new file mode 100755 index 0000000..5d956ee --- /dev/null +++ b/source/man2pre.sh @@ -0,0 +1,26 @@ +# Unbound Website Sitetools man2pre.sh +# makes nicely formatted manual page in a
 block.
+# first argument: manual page source.
+# second argument: destination file.
+
+if test "$#" -ne 2; then
+	echo "usage: man2pre  "
+	echo "for unbound website tools"
+	exit 1
+fi
+echo "man2pre from $1 to $2"
+
+sed s!\\!\$(basename $1)\! man_header.html > $2
+echo '
' >> $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??\>?g" | sed -e 's?\[1m??g' -e 's?(B\[m??g' | sed -e 's?\[4m\[22m??g' -e 's?\[m??g' -e 's?\[m\000??g' -e 's?\[4m??g' -e 's?\[24m??g' -e 's?<\([bi]\)>\([^<]*\)\[0m?<\1>\2?g' -e 's?\[22m??g' | col -b | expand >> $2
+else
+groff -man -Tascii $1 | sed -e "s??\>?g" | sed -e 's?\[1m??g' -e 's?(B\[m??g' | sed -e 's?\[4m\[22m??g' -e 's?\[m??g' -e 's?\[m\000??g' -e 's?\[4m??g' -e 's?\[24m??g' -e 's?<\([bi]\)>\([^<]*\)\[0m?<\1>\2?g' -e 's?\[22m??g' | col -b | expand >> $2
+fi
+echo '
' >> $2 +#echo '