1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#!/bin/sh
# $Id: htmlp2html,v 6.1 2010-09-15 16:00:19 deraugla Exp $
FILE=$1
VERSION="$(grep "value version =" ../../main/pcaml.ml | sed -e 's/^[^"]*"\([^"]*\).*$/\1/')"
(
echo '<div id="tableofcontents">'
echo ' <ol>'
grep '<h[23]>' $FILE |
sed -e 's|^<h2>\(.*\)</h2>|b2<a href="#a:\1">\1</a>e2|' |
sed -e 's|^<h3>\(.*\)</h3>|b3<a href="#b:\1">\1</a>e3|' |
sed -e '{:b N; s/\n//; tb}' |
sed -e 's/e2b3/\n <ul>\n <li>/g' |
sed -e 's|e3b2|</li>\n </ul>\n </li>\n <li>|g' |
sed -e 's|e2b2|</li>\n <li>|g' |
sed -e 's|e2|</li>|g' |
sed -e 's/b2/ <li>/g' |
sed -e 's|e3b3|</li>\n <li>|g' |
sed -e 's|e3|</li>\n </ul>\n </li>|g'
echo ' </ol>'
echo '</div>'
) > toc.tmp
cat $FILE |
sed \
-e '/title="Normal"/a \
<link rel="alternate" type="application/rss+xml" href="rss/camlp5.rss" \
title="Camlp5"/>' |
sed \
-e '/<div id="menu">/i\aaa' \
-e '/<div id="menu">/,/^<\/div>/d' |
sed -e '/aaa/r menu.html' -e '/aaa/d' |
sed \
-e '/<div id="tableofcontents">/i\aaa' \
-e '/<div id="tableofcontents">/,/^<\/div>/d' |
sed -e '/aaa/r toc.tmp' -e '/aaa/d' |
sed \
-e '/<div class="trailer">/i\aaa' \
-e '/<div class="trailer">/,/^<\/div>/d' |
sed -e "/aaa/i\<a class=\"toplink\" href=\"$FILE\">↑</a>" |
sed -e '/aaa/r trailer.html' -e '/aaa/d' |
sed -e '/<h2>/s|<h2>\(.*\)</h2>|<h2 id="a:\1">\1</h2>|' |
sed -e '/<h3>/s|<h3>\(.*\)</h3>|<h3 id="b:\1">\1</h3>|' |
sed -e '{:b s/\(href="#[ab][^>]*\)[ .,#?"]\([^>]\)/\1-\2/; tb}' |
sed -e '{:b s/\(id="[ab][^>]*\)[ .,#?"]\([^>]\)/\1-\2/; tb}' |
sed -e "s|<version/>|$VERSION|" |
sed -e '/<licence\/>/r ../../LICENSE' -e '/<licence\/>/d'
rm toc.tmp
|