#!/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${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> ${version_info} ${name}(${n})
//' "${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/
/
/')"
toc="$(echo "${toc}" | sed 's/<\/DL>/<\/UL>/')"
toc="$(echo "${toc}" | sed 's/
"; 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}"
# generate page info at bottom of page
echo "