no more make, no more watch loops
This commit is contained in:
parent
3af586c63a
commit
3677cbb698
4 changed files with 25 additions and 14 deletions
3
Makefile
3
Makefile
|
@ -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
|
|
21
bin/toc.sh
21
bin/toc.sh
|
@ -44,16 +44,19 @@ fi
|
||||||
ts="<\!--ts-->"
|
ts="<\!--ts-->"
|
||||||
te="<\!--te-->"
|
te="<\!--te-->"
|
||||||
|
|
||||||
|
existingTOC="$(cat "$MARKDOWN" | sed -n "/${ts}/,/${te}/p" | sed '1,1d; $d')"
|
||||||
|
|
||||||
tmp="$(mktemp)"
|
if [ "$toc" != "$existingTOC" ]; then
|
||||||
function finish {
|
tmp="$(mktemp)"
|
||||||
|
function finish {
|
||||||
rm "$tmp"
|
rm "$tmp"
|
||||||
}
|
}
|
||||||
trap finish EXIT
|
trap finish EXIT
|
||||||
|
|
||||||
echo "${toc}" > "${tmp}"
|
echo "${toc}" > "${tmp}"
|
||||||
|
|
||||||
# clear old toc
|
# clear old toc
|
||||||
$sed "/${ts}/,/${te}/{//!d;}" "$MARKDOWN"
|
$sed "/${ts}/,/${te}/{//!d;}" "$MARKDOWN"
|
||||||
# insert toc
|
# insert toc
|
||||||
$sed "/${ts}/r ${tmp}" "$MARKDOWN"
|
$sed "/${ts}/r ${tmp}" "$MARKDOWN"
|
||||||
|
fi
|
6
build.sh
Executable file
6
build.sh
Executable 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"
|
7
watch.sh
7
watch.sh
|
@ -1,3 +1,8 @@
|
||||||
#!/bin/bash
|
#!/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"
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue