From 9e45cae061fd345d3270f236769bd94966a42eb2 Mon Sep 17 00:00:00 2001 From: Kartik Agaram Date: Sat, 7 Dec 2019 16:19:38 -0800 Subject: 5799 - move html-generation to `tools/` directory --- tools/update_html | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100755 tools/update_html (limited to 'tools/update_html') diff --git a/tools/update_html b/tools/update_html new file mode 100755 index 00000000..478d5d6c --- /dev/null +++ b/tools/update_html @@ -0,0 +1,73 @@ +#!/bin/bash +# Regenerate html files. +# If given a single argument, regenerate just that file. + +set -e + +( cd tools; c++ -g linkify.cc -o linkify; ) + +# generate html/$1.html using /tmp/tags +process() { + rm -f html/$1.html + convert_html $1 + tools/linkify /tmp/tags html/$1.html + mv html/$1.html.out html/$1.html +} + +URL_BASE='https://github.com/akkartik/mu/blob/master' + +convert_html() { + vim -c "set number" -c TOhtml -c write -c qall $1 + + sed -i 's,.*/mu/,<title>Mu - ,' $1.html + sed -i 's,\.html,,' $1.html + + sed -i "/^$URL_BASE/$1" $1.html + + sed -i 's/^\* { \(.*\) }/* { font-size:12pt; \1 }/g' $1.html + sed -i 's/^body { \(.*\) }/body { font-size:12pt; \1 }/g' $1.html + + sed -i '/^body {/a a { color:inherit; }' $1.html + + # switch unicode characters around in the rendered html + # the ones we have in the source files render double-wide in html + # the ones we want in the html cause iTerm2 to slow down in alt-tabbing for some reason + # the following commands give us the best of both worlds + sed -i -e 's/┈/╌/g' -e 's/┊/╎/g' $1.html + + mv -i $1.html html/`dirname $1` +} + +ctags -x *.cc |grep -v '^. ' > /tmp/tags # don't hyperlink every 'i' to the integer register variant +for f in *.cc +do + test $# -gt 0 && test $1 != $f && continue + process $f +done + +for f in examples/*.subx +do + test $# -gt 0 && test $1 != $f && continue + ( cd examples + ctags -x `basename $f` > /tmp/tags + ) + process $f +done + +ctags -x *.subx > /tmp/tags +for f in *.subx +do + test $# -gt 0 && test $1 != $f && continue + process $f +done + +for f in apps/*.subx +do + test $# -gt 0 && test $1 != $f && continue + ( cd apps + ctags -x ../*.subx `basename $f` > /tmp/tags + ) + process $f +done + +rm /tmp/tags -- cgit 1.4.1-2-gfad0