#! /usr/bin/gawk -f # Last edited on 2004-01-27 06:50:44 by stolfi BEGIN{ state = "base"; } /^ *[\#@]/ { print; next; } /./ { gsub(/[&][\#]8207[;]/, "", $0); } /^ *$/ { next; } # Decide state of next non-tag text: /
/ { print "@="; next; } /<[\/]P>/ { print "@="; next; } /^[<]/ { next; } (state == "header") { print gensub(/^ *([0-9]+)[.] *(.*)$/, "@chapter{\\1}{sura}{\\2}", "g", $0); state = "base"; next; } (state == "vnum") { print gensub(/^ *0*([0-9]+)[:]0*([0-9]+)$/, " @verse{\\1}{\\2}", "g", $0); state = "verse"; next; } (state == "verse") { printf " %s\n", $0; next; } (state == "base") { printf "ignored: %s\n", $0 > "/dev/stderr"; next; }