From 381297c95c7446182e90e459cd0257a8fc86b4cf Mon Sep 17 00:00:00 2001 From: Volpeon Date: Tue, 29 Dec 2020 12:24:04 +0100 Subject: Improved CSS classes for page content, added proper ref list macro, build scripts load and watch Pandoc filters automatically --- scripts/build_content.sh | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'scripts/build_content.sh') diff --git a/scripts/build_content.sh b/scripts/build_content.sh index 719b7c9..b258449 100755 --- a/scripts/build_content.sh +++ b/scripts/build_content.sh @@ -1,14 +1,31 @@ #!/bin/bash CONTENT_DIR="content/" +FILTERS_DIR="filters/" METADATA_DIR="metadata/" TEMPLATES_DIR="templates/" OUTPUT_DIR="output/" -CATEGORY_SHORT_LEN=3 CATEGORY_MAP=$(cat "$METADATA_DIR/categories.json") -target_filename () { +get_filters() { + filters_args="" + + mapfile -d $'\0' filters < <(find $FILTERS_DIR \ + -type f \ + -name "*.lua" ! -name ".*" \ + -print0) + + for file in "${filters[@]}"; do + filters_args="$filters_args --lua-filter $file" + done + + echo $filters_args +} + +FILTERS=$(get_filters) + +target_filename() { filename=$1 filename=${filename#"$CONTENT_DIR"} if [ "${filename##*.}" = "md" ]; then @@ -17,7 +34,7 @@ target_filename () { echo "$OUTPUT_DIR$filename" } -target_url_rel () { +target_url_rel() { basedir=$1 filename=$2 filename=$(realpath --relative-to="$basedir" "$filename") @@ -28,7 +45,7 @@ target_url_rel () { echo "$filename" } -target_url_abs () { +target_url_abs() { echo "/$(target_url_rel "$CONTENT_DIR" "$1")" } @@ -148,6 +165,10 @@ handle () { # echo "$(get_metadata "$1")" echo "$(get_metadata "$1")" > "$subpages_meta_file" + # echo $(pandoc "$1" \ + # -f markdown \ + # -t json) + pandoc "$1" \ -f markdown \ -t html5 \ @@ -157,7 +178,8 @@ handle () { --metadata section=$section \ --metadata "is$section" \ --metadata-file metadata/metadata.yaml \ - --metadata-file "$subpages_meta_file" + --metadata-file "$subpages_meta_file" \ + $FILTERS # --lua-filter "filters/add_refs.lua" rm "$subpages_meta_file" -- cgit v1.2.3-70-g09d2