#!/bin/sh hostname="http://librb.kurwinet.pl" out="$(pwd)/www/manuals" root="$(pwd)" ftmp="/tmp/mtest-man2html" cd "${root}/man" mkdir "${out}" for m in *.[1-8] do n="${m##*.}" echo "opening ${m}" 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}" # 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}" # 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}" ## get table of content from file toc="$(sed -n '/
/,/<\/DL>/p' "${ftmp}")" toc="$(echo "${toc}" | sed 's/
/