\n/}}; 1{/^$/{s/^/
/}};' |\
sed -e '${/./{s/$/\n<\/p>/}}; ${/^$/{s/$/<\/p>/}};' |\
sed 's/\\mbox[{]\([^}]\+\)[}]/\1/g' |\
# sed 's/\\glsdisp[{]\([^}]\+\)[}][{]\([^}]\+\)[}]/\2<\/a>/g' |\
sed 's/\\glsdisp[{]\([^}]\+\)[}][{]\([^}]\+\)[}]/\2/g' |\
# sed 's/\\glslink[{]\([^}]\+\)[}][{]\([^}]\+\)[}]/\2<\/a>/g' |\
sed 's/\\glslink[{]\([^}]\+\)[}][{]\([^}]\+\)[}]/\2/g' |\
sed 's/\\qaitem[{]\([^}]\+\)[}]/\1<\/i>/g' |\
sed -e 's/\\dropcaps[{]\([^}]\+\)[}][{]\([^}]\+\)[}]/\1\2/; s/\\pali[{]\([^}]\+\)[}]/\1<\/i>/g; s/\\textit[{]\([^}]\+\)[}]/\1<\/i>/g;' |\
# sed 's/\\footnote[{]\([^}]\+\)[}]/\1<\/span>/g' |\
sed -e 's/\\begin[{]verse[}]/ /' > "$i.tmp"
# process footnotes
FN=1
remains=-1
prev_rem=-2
echo -n "" > "$i.tmp.footnotes"
while [ ! $remains -eq 0 ]
do
if [ $remains -eq $prev_rem ]; then
echo -e "\n* WARNING! Remainin footnotes? $remains lines\n"
grep -nE '\\footnote[{][^}]+[}]' "$i.tmp" | sed -e 's/^/ /; s/$/\n/'
echo ""
break
fi
# for now, dealing with one-liner footnotes only
converted_lines=""
line=$(grep -noE '\\footnote[{][^}]+[}]' "$i.tmp" | sed -e '1!d; s/^\([0-9]\+\):.*/\1/')
while [ "$line" != "" ]
do
converted_lines="$converted_lines $line"
cat "$i.tmp" | sed -e ''$line'!d; s/^.*\\footnote[{]\([^}]\+\)[}].*$/ '$FN'<\/span>:<\/a> \1<\/p>/; ' >> "$i.tmp.footnotes"
sed -i -e "$line"'{ s/\\footnote[{]\([^}]\+\)[}]/'$FN'<\/span><\/a>/ }' "$i.tmp"
((FN++))
line=$(grep -noE '\\footnote[{][^}]+[}]' "$i.tmp" | sed -e '1!d; s/^\([0-9]\+\):.*/\1/')
done
prev_rem="$remains"
remains=$(grep -cE '\\footnote[{][^}]+[}]' "$i.tmp")
done
if [ "$converted_lines" != "" ]; then
echo "Converted footnotes on lines: $converted_lines"
fi
echo ""
echo -e -n "\n\n" >> "$i.tmp"
cat "$i.tmp.footnotes" >> "$i.tmp"
rm "$i.tmp.footnotes"
# check for remaining commands, braces, and other chars
c=$(grep -cE '\\[a-zA-Z]' "$i.tmp")
if [ ! $c -eq 0 ]; then
echo -e "* WARNING! Remaining commands? $c lines\n"
grep -nE '\\[a-zA-Z]' "$i.tmp" | sed -e 's/^/ /; s/$/\n/'
echo ""
fi
c=$(grep -cE '[{}]' "$i.tmp")
if [ ! $c -eq 0 ]; then
echo -e "* WARNING! Remaining braces? $c lines\n"
grep -nE '[{}]' "$i.tmp" | sed -e 's/^/ /; s/$/\n/'
echo ""
fi
chars="~%"
c=$(grep -cE '['$chars']' "$i.tmp")
if [ ! $c -eq 0 ]; then
echo -e "* WARNING! Remaining $chars ? $c lines\n"
grep -nE '['$chars']' "$i.tmp" | sed -e 's/^/ /; s/$/\n/'
echo ""
fi
mv "$i.tmp" "$i.html"
done
/g; s/\\end[{]verse[}]/<\/blockquote>/g;' |\
sed 's/^$/<\/p>