############################################################# # scripter.awk ############################################################# # # Takes a marked-up script file and converts it to HTML # # Leading spaces on lines are ignored # # Each stanza should be separated by a blank line. # # Stuff in {} goes red, [] goes blue, in () goes green # # A line starting < is passed asis # # A line starting # is a act / scene / page marker # # # # # If none of the above, then the first word is bolded on the # assumption it is a speech. # # # ############################################################# # # (C) David Buckley, 2004,2005 # # # # # ############################################################# BEGIN { ready = 1 oncount = 0 print "" } END { print "" } ############################################################# # Blank line processing ############################################################# NF == 0 { ready = 1 next } ############################################################# # AsIs lines ############################################################# substr($0,1,1) == "<" { print $0 ready = 1 next } ############################################################# # Page number processing ############################################################# substr($0,1,1) == "#" { print "

Page " substr($0,2) "" ready = 1 next } ############################################################# # Most lines... ############################################################# { # If this is first or only line of a stanza, then check if # it starts with a modifier, otherwise treat first word sub(/^[ |\t]+/, "") if (ready){ firstchar = substr($1,1,1) if (firstchar != "[" && firstchar != "(" && firstchar != "{" && firstchar != "/" && oncount == 0){ $0 = "@BOLDON" $1 "@BOLDOFF" substr($0, length($1)+1) } if (firstchar == "/") $1 = substr($1,2) } gsub("\"", "\"") oncount += gsub("\[", "") oncount -= gsub("\]", "") oncount += gsub("\(", "(") oncount -= gsub("\)", ")") oncount += gsub("\{", "") oncount -= gsub("\}", "") gsub("@BOLDON", "") gsub("@BOLDOFF", "") if (ready){ print "

" $0 ready = 0 } else print $0 }