no more make, no more watch loops

This commit is contained in:
Alex Grintsvayg 2018-11-02 15:17:53 -04:00
parent 3af586c63a
commit 3677cbb698
4 changed files with 25 additions and 14 deletions

View file

@ -1,3 +0,0 @@
index.html: index.md head.html
./bin/mmark-linux-amd64 -head head.html -html index.md > index.html
./bin/toc.sh index.html index.md

View file

@ -44,16 +44,19 @@ fi
ts="<\!--ts-->"
te="<\!--te-->"
existingTOC="$(cat "$MARKDOWN" | sed -n "/${ts}/,/${te}/p" | sed '1,1d; $d')"
tmp="$(mktemp)"
function finish {
rm "$tmp"
}
trap finish EXIT
if [ "$toc" != "$existingTOC" ]; then
tmp="$(mktemp)"
function finish {
rm "$tmp"
}
trap finish EXIT
echo "${toc}" > "${tmp}"
echo "${toc}" > "${tmp}"
# clear old toc
$sed "/${ts}/,/${te}/{//!d;}" "$MARKDOWN"
# insert toc
$sed "/${ts}/r ${tmp}" "$MARKDOWN"
# clear old toc
$sed "/${ts}/,/${te}/{//!d;}" "$MARKDOWN"
# insert toc
$sed "/${ts}/r ${tmp}" "$MARKDOWN"
fi

6
build.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
$DIR/bin/mmark-linux-amd64 -head "$DIR/head.html" -html "$DIR/index.md" > "$DIR/index.html"
$DIR/bin/toc.sh "$DIR/index.html" "$DIR/index.md"

View file

@ -1,3 +1,8 @@
#!/bin/bash
./bin/reflex --decoration=none --start-service=true --glob='*' --inverse-regex='index\.html' -- sh -c "make"
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
(
cd "$DIR"
./bin/reflex --decoration=none --start-service=true --glob='*' --inverse-regex='index\.html' -- sh -c "./build.sh"
)