her.esy.fun/engine/optim-html.sh

27 lines
608 B
Bash
Raw Normal View History

2020-05-25 20:28:06 +00:00
#!/usr/bin/env zsh
2019-11-27 18:06:42 +00:00
2020-02-10 08:42:17 +00:00
cd "$(git rev-parse --show-toplevel)" || exit 1
2020-02-16 15:56:19 +00:00
webdir="_optim"
2019-11-27 18:06:42 +00:00
debug () {
print -- $* >/dev/null
}
type -a filelist
setopt extendedglob
if (($#>0)); then
filelist=( $* )
else
filelist=( $webdir/**/*.html(.) )
fi
tmp=$(mktemp)
for fic in $filelist; do
print -n -- "$fic "
2019-12-05 13:55:51 +00:00
cp $fic $tmp
2020-02-29 17:19:00 +00:00
perl -pi -e 's#<div id="outline-container-[^"]*"([^>]*)>#<div$1>#g;s# id="org[a-f0-9]{7}"##g;s# class="src src-# class="src-#g;s#<label class="org-src-name">#<label>#g;s#<div class="org-src-container">#<div>#g' $tmp
2019-12-05 13:55:51 +00:00
minify --mime text/html $tmp > $fic
2019-11-27 18:06:42 +00:00
print "[OK]"
done