diff --git a/Makefile b/Makefile deleted file mode 100644 index 4653420..0000000 --- a/Makefile +++ /dev/null @@ -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 \ No newline at end of file diff --git a/bin/toc.sh b/bin/toc.sh index 667fe0c..bc51669 100755 --- a/bin/toc.sh +++ b/bin/toc.sh @@ -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" \ No newline at end of file + # clear old toc + $sed "/${ts}/,/${te}/{//!d;}" "$MARKDOWN" + # insert toc + $sed "/${ts}/r ${tmp}" "$MARKDOWN" +fi \ No newline at end of file diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..c306b92 --- /dev/null +++ b/build.sh @@ -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" \ No newline at end of file diff --git a/watch.sh b/watch.sh index 5350510..26e36a5 100755 --- a/watch.sh +++ b/watch.sh @@ -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" +)