X-Git-Url: https://plomlompom.com/repos/?p=redo-blog;a=blobdiff_plain;f=processor%2Fmetadata%2Fdefault.intermediate.do;h=4645223248b00fcebf14ef551c9b8a934c4caf64;hp=e6addeae5d18512aee7bed156b7feea0aeda5888;hb=389680bdb6e6f3d87225bd7c433740e76d25bb79;hpb=b86576c5f61cff36c80c9e0efd9d77f50dac745b diff --git a/processor/metadata/default.intermediate.do b/processor/metadata/default.intermediate.do index e6addea..4645223 100644 --- a/processor/metadata/default.intermediate.do +++ b/processor/metadata/default.intermediate.do @@ -1,15 +1,28 @@ #!/bin/sh -template=intermediate.tmpl -uuidfile="${1%.intermediate}.uuid" -redo-ifchange "$uuidfile" +# Pull in dependencies. +template=intermediate.pandoc_tmpl +meta_file="${1%.intermediate}.automatic_metadata" +redo-ifchange "$meta_file" redo-ifchange "$template" mdfile="../${1%.intermediate}.md" rstfile="../${1%.intermediate}.rst" + +# Build intermediate file. if [ -f "$rstfile" ]; then redo-ifchange "$rstfile" - pandoc -f rst --template="$template" --mathml -t html5 "$rstfile" > "$3" + pandoc -f rst --template="$template" --mathml -t html5 "$rstfile" --base-header-level=2 --email-obfuscation=references > "$3" elif [ -f "$mdfile" ]; then redo-ifchange "$mdfile" - pandoc -f markdown --template="$template" --mathml -t html5 "$mdfile" > "$3" + pandoc -f markdown --template="$template" --mathml -t html5 "$mdfile" --base-header-level=2 --email-obfuscation=references > "$3" +fi + +# Update meta file if appropriate. +md5_new=$(md5sum "$3" | cut -d ' ' -f 1) +md5_old=$(cat "$meta_file" | sed -n '3p') +if [ ! "$md5_new" = "$md5_old" ]; then + new_date=$(date -u "+%s") + sed -i '1,2!d' "$meta_file" + echo "$md5_new" >> "$meta_file" + echo "$new_date" >> "$meta_file" fi