#!/bin/bash
# Regenerate html files.
# If given a single argument, try to regenerate just that file. Not supported everywhere.
set -e
( cd tools; c++ -g linkify.cc -o linkify; )
# generate html/$1.html using /tmp/tags
process() {
mkdir -p html/$(dirname $1)
rm -f html/$1.html
convert_html $1
tools/linkify /tmp/tags $1.html
mv $1.html.out html/$1.html
rm $1.html
}
URL_BASE='https://github.com/akkartik/mu/blob/main'
convert_html() {
vim -u $MYVIM/vimrc.vim -c "set number" -c TOhtml -c write -c qall $1
sed -i 's,
.*/mu/,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
}
ctags -x boot.subx [0-9]*.subx [0-9]*.mu > /tmp/tags
for f in boot.subx [0-9]*.subx [0-9]*.mu
do
test $# -gt 0 && test $1 != $f && continue
process $f
done
for f in [^0-9]*.subx [^0-9]*.mu
do
test $# -gt 0 && test $1 != $f && continue
test $f = "boot.subx" && continue
ctags -x boot.subx [0-9]*.subx [0-9]*.mu $f > /tmp/tags
process $f
done
for f in apps/*.mu
do
test $# -gt 0 && test $1 != $f && continue
( cd $(dirname $f)
ctags -x ../[0-9]*.subx ../[0-9]*.mu $(basename $f) > /tmp/tags
)
process $f
done
( cd shell
ctags -x ../boot.subx ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
)
for f in shell/*.mu
do
test $# -gt 0 && test $1 != $f && continue
process $f
done
( cd browse-slack
ctags -x ../boot.subx ../[0-9]*.subx ../[0-9]*.mu *.mu > /tmp/tags
)
for f in browse-slack/*.mu
do
test $# -gt 0 && test $1 != $f && continue
process $f
done
rm /tmp/tags