X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;f=processor%2Fmetadata%2Fdefault.intermediate.do;h=4645223248b00fcebf14ef551c9b8a934c4caf64;hb=57b9f8ec5eebf7fed09da3007c0571bab7d982fa;hp=adcd2eb93b065d70db7ad7250aa4198ea2627958;hpb=f88948caf952c4fd913ea7466c2f1ab3455af506;p=redo-blog
diff --git a/processor/metadata/default.intermediate.do b/processor/metadata/default.intermediate.do
index adcd2eb..4645223 100644
--- a/processor/metadata/default.intermediate.do
+++ b/processor/metadata/default.intermediate.do
@@ -1,15 +1,28 @@
#!/bin/sh
+# Pull in dependencies.
template=intermediate.pandoc_tmpl
-uuidfile="${1%.intermediate}.uuid"
-redo-ifchange "$uuidfile"
+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