From 492e7580aa482b754713f258b82474f22b2e63a1 Mon Sep 17 00:00:00 2001 From: Michał Łyszczek Date: Tue, 23 Jan 2018 13:38:13 +0100 Subject: change: move manuals into single directory --- man2html.sh | 100 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 45 deletions(-) (limited to 'man2html.sh') diff --git a/man2html.sh b/man2html.sh index 97806e9..955f031 100755 --- a/man2html.sh +++ b/man2html.sh @@ -5,66 +5,76 @@ out="$(pwd)/www/manuals" root="$(pwd)" ftmp="/tmp/mtest-man2html" -for n in {3,7} +cd "${root}/man" +mkdir "${out}" + +for m in *.[1-8] do - mkdir -p "${out}/man${n}" - cd "${root}/man/man${n}" + n="${m##*.}" + echo "opening ${m}" - for m in * - do + if grep "\.so man${n}" "${m}" + then + sed -i "s/man${n}/man/" "${m}" + man2html -r -H "${hostname}" "${m}" > "${ftmp}" + sed -i "s/man\//man${n}\//g" "${m}" + else man2html -r -H "${hostname}" "${m}" > "${ftmp}" + fi + + # get only body part of the file + body_only="$(sed -n '//,/<\/BODY>/p' "${ftmp}")" + echo "$body_only" > "${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}" - # remove leftover and

man

tags from beginning - tail -n+3 "${ftmp}" > tmp; mv tmp "${ftmp}" + # construct top page heading with page info, remove superflous info + name="$(basename ${m})" + name="${name%.*}" + version_info="$(head -n1 ${ftmp} | cut -f3 -d: | cut -f1 -d\<)" + tail -n+2 "${ftmp}" > tmp; mv tmp "${ftmp}" + sed -i "1s/^/

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

kurwinet manual pages<\/p>

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

/" "${ftmp}" - # construct top page heading with page info, remove superflous info - name="$(basename ${m})" - name="${name%.*}" - version_info="$(head -n1 ${ftmp} | cut -f3 -d: | cut -f1 -d\<)" - tail -n+2 "${ftmp}" > tmp; mv tmp "${ftmp}" - sed -i "1s/^/

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

kurwinet manual pages<\/p>

${name}(${n})<\/p>\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}" - # 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 (page info) and remove them from file + tmp="$(head -n2 ${ftmp})" + tail -n+3 "${ftmp}" > tmp; mv tmp "${ftmp}" - # extract table of content and put it in the beginning of file - ## cache first two lines (page 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}")" - ## get table of content from file - toc="$(sed -n '/
/,/<\/DL>/p' "${ftmp}")" + toc="$(echo "${toc}" | sed 's/
/