home · contact · privacy
Fix pandoc email obfuscation default.
[redo-blog] / processor / metadata / default.intermediate.do
index e6addeae5d18512aee7bed156b7feea0aeda5888..4645223248b00fcebf14ef551c9b8a934c4caf64 100644 (file)
@@ -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