From c4b410c49650288aa3879ba13dd70526cdf692d3 Mon Sep 17 00:00:00 2001 From: Alvie Rahman Date: Sat, 1 May 2021 11:29:48 +0100 Subject: [PATCH] clean up code --- notes2web | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/notes2web b/notes2web index a4c462c..0b02de1 100755 --- a/notes2web +++ b/notes2web @@ -2,7 +2,7 @@ [[ "$1" == "--help" ]] && echo "USAGE: $0 [NOTES_DIRECTORY_1 [NOTES_DIRECTORY_2 [...]]]" && exit 0 -function _render { +function _renderarticle { echo "rendering $1" pandoc\ --toc\ @@ -14,15 +14,6 @@ function _render { --mathjax } -function _renderindex { - echo "rendering $1" - pandoc\ - -t html\ - --template /opt/notes2web/templates/index.html\ - -o index.html\ - "$1" -} - function _adddirtoindex { dir="$(dirname "$1")" echo "

$(basename "$dir") notes

" >> index.md @@ -39,14 +30,14 @@ function _addarticletoindex { >> index.md } -export -f _render +export -f _renderarticle export -f _adddirtoindex export -f _addarticletoindex #render each markdown file for file in "$@" do - find "$file" -name '*.md' -exec bash -c "_render '{}'" \; + find "$file" -name '*.md' -exec bash -c "_renderarticle '{}'" \; done # create an intermediate markdown file of links to each article @@ -59,9 +50,15 @@ do [[ ! -f "$file" ]] && echo "the presence of this files tells notes2web that it should be added to the notes2web index" > "$file/.2web" done +# add articles to index find -name '.2web' -exec bash -c "_adddirtoindex '{}'" \; -_renderindex index.md +echo "rendering index.md" +pandoc\ + -t html\ + --template /opt/notes2web/templates/index.html\ + -o index.html\ + "index.md" echo "copying styles.css to current directory" cp /opt/notes2web/styles.css .