BEGIN {
# some initialization variables
asciiart="no";
wasset="no";
lineset=0;
sample="no";
while ( getline ti <"tags.ref" > 0 ) {
nf=split(ti,tag," ");
tagkey[tag[1]]="yes";tagref[tag[1]]=tag[2];
}
skip_word["and"]="yes";
skip_word["backspace"]="yes";
skip_word["beep"]="yes";
skip_word["bugs"]="yes";
skip_word["da"]="yes";
skip_word["end"]="yes";
skip_word["ftp"]="yes";
skip_word["go"]="yes";
skip_word["help"]="yes";
skip_word["home"]="yes";
skip_word["news"]="yes";
skip_word["index"]="yes";
skip_word["insert"]="yes";
skip_word["into"]="yes";
skip_word["put"]="yes";
skip_word["reference"]="yes";
skip_word["section"]="yes";
skip_word["space"]="yes";
skip_word["starting"]="yes";
skip_word["toggle"]="yes";
skip_word["various"]="yes";
skip_word["version"]="yes";
skip_word["is"]="yes";
}
#
# protect special chars
#
/[><&�]/ {gsub(/&/,"\\&");gsub(/>/,"\\>");gsub(/</,"\\<");gsub("�","\\á");}
#
# end of sample lines by non-blank in first column
#
sample == "yes" && substr($0,1,4) == "<" { sample = "no"; gsub(/^</, " "); }
sample == "yes" && substr($0,1,1) != " " && substr($0,1,1) != " " && length($0) > 0 { sample = "no" }
#
# sample lines printed bold unless empty...
#
sample == "yes" && $0 =="" { print ""; next; }
sample == "yes" && $0 !="" { print "<B>" $0 "</B>"; next; }
#
# start of sample lines in next line
#
$0 == ">" { sample = "yes"; print ""; next; }
substr($0,length($0)-4,5) == " >" { sample = "yes"; gsub(/ >$/, ""); }
#
# header lines printed bold, colored
#
substr($0,length($0),1) == "~" { print "<B><FONT COLOR=\"PURPLE\">" substr($0,1,length($0)-1) "</FONT></B>"; next; }
#
#ad hoc code
#
/^"\|\& / {gsub(/\|/,"\\|"); }
/ = b / {gsub(/ b /," \\b "); }
#
# one letter tag
#
/[ ]\*.\*[ ]/ {gsub(/\*/,"ZWWZ"); }
#
# isolated "*"
#
/[ ]\*[ ]/ {gsub(/ \* /," \\* ");
gsub(/ \* /," \\* ");
gsub(/ \* /," \\* ");
gsub(/ \* /," \\* "); }
#
# tag start
#
/[ ]\*[^ ]/ {gsub(/ \*/," ZWWZ");gsub(/ \*/," ZWWZ");}
/^\*[^ ]/ {gsub(/^\*/,"ZWWZ");}
#
# tag end
#
/[^ ]\*$/ {gsub(/\*$/,"ZWWZ");}
/[^ \/ ]\*[ ]/ {gsub(/\*/,"ZWWZ");}
#
# isolated "|"
#
/[ ]\|[ ]/ {gsub(/ \| /," \\| ");
gsub(/ \| /," \\| ");
gsub(/ \| /," \\| ");
gsub(/ \| /," \\| "); }
/'\|'/ { gsub(/'\|'/,"'\\|'"); }
/\^V\|/ {gsub(/\^V\|/,"^V\\|");}
/ \\\| / {gsub(/\|/,"\\|");}
#
# one letter pipes and "||" false pipe (digraphs)
#
/[ ]\|.\|[ ]/ && asciiart == "no" {gsub(/\|/,"YXXY"); }
/^\|.\|[ ]/ {gsub(/\|/,"YXXY"); }
/\|\|/ {gsub(/\|\|/,"\\|\\|"); }
/^shellpipe/ {gsub(/\|/,"\\|"); }
#
# pipe start
#
/[ ]\|[^ ]/ && asciiart == "no" {gsub(/ \|/," YXXY");
gsub(/ \|/," YXXY");}
/^\|[^ ]/ {gsub(/^\|/,"YXXY");}
#
# pipe end
#
/[^ ]\|$/ && asciiart == "no" {gsub(/\|$/,"YXXY");}
/[^ ]\|[s ,.); ]/ && asciiart == "no" {gsub(/\|/,"YXXY");}
/[^ ]\|]/ && asciiart == "no" {gsub(/\|/,"YXXY");}
#
# various
#
/'"/ {gsub(/'"/,"\\'\\"'");}
/"/ {gsub(/"/,"\\"");}
/%/ {gsub(/%/,"\\%");}
NR == 1 { nf=split(FILENAME,f,".")
print "<HTML>";
print "<HEAD>"
if ( FILENAME == "mbyte.txt" ) {
# needs utf-8 as uses many languages
print "<META HTTP-EQUIV=\"Content-type\" content=\"text/html; charset=UTF-8\">";
} else {
# common case - Latin1
print "<META HTTP-EQUIV=\"Content-type\" content=\"text/html; charset=ISO-8859-1\">";
}
print "<TITLE>Vim documentation: " f[1] "</TITLE>";
print "</HEAD>";
print "<BODY BGCOLOR=\"#ffffff\">";
print "<H1>Vim documentation: " f[1] "</H1>";
print "<A NAME=\"top\"></A>";
if ( FILENAME != "help.txt" ) {
print "<A HREF=\"index.html\">main help file</A>\n";
}
print "<HR>";
print "<PRE>";
filename=f[1]".html";
}
# set to a low value to test for few lines of text
# NR == 99999 { exit; }
# ignore underlines and tags
substr($0,1,5) == " vim:" { next; }
substr($0,1,4) == "vim:" { next; }
# keep just whole lines of "-", "="
substr($0,1,3) == "===" && substr($0,75,1) != "=" { next; }
substr($0,1,3) == "---" && substr($0,75,1) != "-" { next; }
{
nstar = split($0,s,"ZWWZ");
for ( i=2 ; i <= nstar ; i=i+2 ) {
nbla=split(s[i],blata,"[ ]");
if ( nbla > 1 ) {
gsub("ZWWZ","*");
nstar = split($0,s,"ZWWZ");
}
}
npipe = split($0,p,"YXXY");
for ( i=2 ; i <= npipe ; i