#! /usr/bin/gawk -f # Last edited on 2003-06-17 22:54:05 by stolfi BEGIN { abort = -1; usage = ( ARGV[0] " [-v title='TITLE'] INFILE.bib... > OUTFILE.html" ); # Trivially turns a .bib file into an .html file, # in
...format, with a anchor # for each entry, where TAG is the entry's bibtex tag. if (title == "") { title = "BibTeX entries"; } printf "\n" ; printf "\n"; printf "
\n"; curfile = FILENAME; } /./ { gsub(/[&]/, "&", $0); gsub(/[<]/, "<", $0); gsub(/[>]/, ">", $0); } /^[ \011]*[%]/ { printf "%s\n", $0; next; } /^[ \011]*[@][a-zA-Z0-9]*[ \011]*[{][ \011]*[-a-zA-Z0-9]+[ \011]*[,][ \011]*$/ { gsub(/[ \011,@]*/, "", $0); gsub(/[{]/, " ", $0); if (NF != 2) { error(("prog error")); } kind = $1; tag = $2; printf "\n", tag; printf "@%s{%s,\n", kind, tag; next } /^[ \011]*[@]/ { error(("bad tag format")); } // { print; next; } END { if (abort >= 0) { exit abort; } if (curfile != "") { printf "\n"; } printf "\n"; printf "\n"; } function error(msg) { printf "file %s, line %s: %s\n", FILENAME, FNR, msg > "/dev/stderr"; abort = 1; exit abort; }