#!/bin/bash # qkt2htm (was webber) -- run seds/web.sed # needs gnu sed and gnu awk (gawk) # param is input .qkt file # sister program qtk2ltx # if there is no parameter display help and exit. if [ -e $1 ] then echo "" echo " Syntax: $ qkt2htm source (.qkt req, not given)" echo "" echo "Source has extension: .qkt. Outfile: .html" echo "Runs sed on web.sed. Features auto paragraph tags and:" echo ".[1-7] Headings, .ol, .ul., etc. Gawk counts the notes." echo "" exit 0 fi infile="$1.qkt" outfile="$1.html" # qkt2htm gets variables from lines in the source beginning with "::", # which will be deleted. If running web.sed by hand, such lines are # merely comments and totally optional. # Get the (one) author's name. It may be omitted if you like. auth=`cat "$infile" | sed -e 's/.*Author:: \(.*\)/\1/ p d'` # Get the file name for the end notes in the same way, by command # substitution. You can only have one file name, but it can be # the same source file or a different one. notes=`cat "$infile" | sed -e 's/.*End Notes:: \(.*\)/\1/ p d'` # Copyright copyr=`cat "$infile" | sed -e 's/.*Copyright:: \(.*\)/\1/ p d'` # Get the html title. Basically free advertising, it doesn't show. htitle=`cat "$infile" | sed -e 's/.*HTML Title:: \(.*\)/\1/ p d'` # Add the extension to the notes file name. Your Original edit would # be "name.qkt" notesfile="$notes.html" # the lines in question are deleted by web.sed, first thing. In # win-dos, the following could be one batch file or several or entered # at a command line. 'Type' could be substituted for 'cat'. # The first line runs web.sed on the file. # Then the result is piped to sed again and the author's name and the # name of the notes file, etc., are substituted for web.sed's # placeholders. # Then the result of that is piped to gawk, which inserts numbers for # the end notes into the file in place of web.sed's placeholders. cat $infile | sed -f /home/dra/data/bin/seds/web.sed | sed -e" s/@author/$auth/ s/@endnotesfile/$notesfile/ s/@copyright/$copyr/ s/@htmltitle/$htitle/ " | gawk 'BEGIN { e = 1; t = 1 } {if (gsub("@enumber", e)) e++ if (gsub("@tnumber", t)) t++; print}' > $outfile