From cc2268a760fff6b560179b85f1484f5191eaee95 Mon Sep 17 00:00:00 2001 From: Michał Łyszczek Date: Fri, 19 Jan 2018 09:37:41 +0100 Subject: add: code to generate website for project --- man2html.sh | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100755 man2html.sh (limited to 'man2html.sh') diff --git a/man2html.sh b/man2html.sh new file mode 100755 index 0000000..46f431e --- /dev/null +++ b/man2html.sh @@ -0,0 +1,54 @@ +#!/bin/sh + +hostname="http://librb.kurwinet.pl" +out="$(pwd)/www/manuals" +root="$(pwd)" +ftmp="/tmp/mtest-man2html" + +for n in {3,7} +do + mkdir -p "${out}/man${n}" + cd "${root}/man/man${n}" + + for m in * + do + man2html -r -H "${hostname}" "${m}" > "${ftmp}" + + # get only body part of the file + body_only="$(sed -n '//,/<\/BODY>/p' "${ftmp}")" + echo "$body_only" > "${ftmp}" + + # remove leftover and

man

tags from beginning + tail -n+3 "${ftmp}" > tmp; mv tmp "${ftmp}" + + # construct own h1 tag + name="$(basename ${m})" + name="${name%.*}" + sed -i "1s/^/

${name}(${n})<\/H1>\n

/" "${ftmp}" + + # remove uneeded links to non-existing index + sed -i 's/Return to Main Contents<\/A>


//' "${ftmp}" + sed -i 's/Index<\/A>//g' "${ftmp}" + + # extract table of content and put it in the beginning of file + ## cache first two lines (h1 and info) and remove them from file + tmp="$(head -n2 ${ftmp})" + tail -n+3 "${ftmp}" > tmp; mv tmp "${ftmp}" + + ## get table of content from file + toc="$(sed -n '/
/,/<\/DL>/p' "${ftmp}")" + + ## put table of content and first two lines into file and append hr + { echo -e "${tmp}\n${toc}\n
"; cat "${ftmp}"; } > tmp; mv tmp "${ftmp}" + + ## remove table of content and some uneeded info from bottom of file + sed -i '/^
 <\/A>

Index<\/H2>$/,$d' "${ftmp}" + head -n-3 "${ftmp}" > tmp; mv tmp "${ftmp}" + + # change deprecated name in into id + sed -i 's/A NAME="/A ID="/g' "${ftmp}" + + # move generated file into output directory for further processing + cp "${ftmp}" "${out}/man${n}/${m}.html" + done +done -- cgit v1.2.3-8-gadcc