3 # Pull in dependencies.
4 template=intermediate.pandoc_tmpl
5 meta_file="${1%.intermediate}.automatic_metadata"
6 redo-ifchange "$meta_file"
7 redo-ifchange "$template"
8 mdfile="../${1%.intermediate}.md"
9 rstfile="../${1%.intermediate}.rst"
11 # Build intermediate file.
12 if [ -f "$rstfile" ]; then
13 redo-ifchange "$rstfile"
14 pandoc -f rst --template="$template" --mathml -t html5 "$rstfile" --base-header-level=2 --email-obfuscation=references > "$3"
15 elif [ -f "$mdfile" ]; then
16 redo-ifchange "$mdfile"
17 pandoc -f markdown --template="$template" --mathml -t html5 "$mdfile" --base-header-level=2 --email-obfuscation=references > "$3"
20 # Update meta file if appropriate.
21 md5_new=$(md5sum "$3" | cut -d ' ' -f 1)
22 md5_old=$(cat "$meta_file" | sed -n '3p')
23 if [ ! "$md5_new" = "$md5_old" ]; then
24 new_date=$(date -u "+%s")
25 sed -i '1,2!d' "$meta_file"
26 echo "$md5_new" >> "$meta_file"
27 echo "$new_date" >> "$meta_file"