home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / unix / vim-6.2.tar.bz2 / vim-6.2.tar / vim62 / runtime / doc / makehtml.awk < prev    next >
Encoding:
AWK Script  |  2001-09-02  |  16.9 KB  |  770 lines

  1. BEGIN   {
  2.     # some initialization variables
  3.     asciiart="no";
  4.     wasset="no";
  5.     lineset=0;
  6.     sample="no";
  7.     while ( getline ti <"tags.ref" > 0 ) {
  8.         nf=split(ti,tag,"    ");
  9.         tagkey[tag[1]]="yes";tagref[tag[1]]=tag[2];
  10.     }
  11.     skip_word["and"]="yes";
  12.     skip_word["backspace"]="yes";
  13.     skip_word["beep"]="yes";
  14.     skip_word["bugs"]="yes";
  15.     skip_word["da"]="yes";
  16.     skip_word["end"]="yes";
  17.     skip_word["ftp"]="yes";
  18.     skip_word["go"]="yes";
  19.     skip_word["help"]="yes";
  20.     skip_word["home"]="yes";
  21.     skip_word["news"]="yes";
  22.     skip_word["index"]="yes";
  23.     skip_word["insert"]="yes";
  24.     skip_word["into"]="yes";
  25.     skip_word["put"]="yes";
  26.     skip_word["reference"]="yes";
  27.     skip_word["section"]="yes";
  28.     skip_word["space"]="yes";
  29.     skip_word["starting"]="yes";
  30.     skip_word["toggle"]="yes";
  31.     skip_word["various"]="yes";
  32.     skip_word["version"]="yes";
  33.     skip_word["is"]="yes";
  34. }
  35. #
  36. # protect special chars
  37. #
  38. /[><&ß]/ {gsub(/&/,"\\&");gsub(/>/,"\\>");gsub(/</,"\\<");gsub("ß","\\á");}
  39. #
  40. # end of sample lines by non-blank in first column
  41. #
  42. sample == "yes" && substr($0,1,4) == "<" { sample = "no"; gsub(/^</, " "); }
  43. sample == "yes" && substr($0,1,1) != " " && substr($0,1,1) != "    " && length($0) > 0 { sample = "no" }
  44. #
  45. # sample lines printed bold unless empty...
  46. #
  47. sample == "yes" && $0 =="" { print ""; next; }
  48. sample == "yes" && $0 !="" { print "<B>" $0 "</B>"; next; }
  49. #
  50. # start of sample lines in next line
  51. #
  52. $0 == ">" { sample = "yes"; print ""; next; }
  53. substr($0,length($0)-4,5) == " >" { sample = "yes"; gsub(/ >$/, ""); }
  54. #
  55. # header lines printed bold, colored
  56. #
  57. substr($0,length($0),1) == "~" { print "<B><FONT COLOR=\"PURPLE\">" substr($0,1,length($0)-1) "</FONT></B>"; next; }
  58. #
  59. #ad hoc code
  60. #
  61. /^"\|\& / {gsub(/\|/,"\\|"); }
  62. / = b / {gsub(/ b /," \\b "); }
  63. #
  64. # one letter tag
  65. #
  66. /[     ]\*.\*[     ]/ {gsub(/\*/,"ZWWZ"); }
  67. #
  68. # isolated "*"
  69. #
  70. /[     ]\*[     ]/ {gsub(/ \* /," \\* ");
  71.             gsub(/ \*    /," \\*    ");
  72.             gsub(/    \* /,"    \\* ");
  73.             gsub(/    \*    /,"    \\*    "); }
  74. #
  75. # tag start
  76. #
  77. /[     ]\*[^     ]/    {gsub(/ \*/," ZWWZ");gsub(/    \*/,"    ZWWZ");}
  78. /^\*[^     ]/      {gsub(/^\*/,"ZWWZ");}
  79. #
  80. # tag end
  81. #
  82. /[^     ]\*$/      {gsub(/\*$/,"ZWWZ");}
  83. /[^ \/    ]\*[     ]/  {gsub(/\*/,"ZWWZ");}
  84. #
  85. # isolated "|"
  86. #
  87. /[     ]\|[     ]/ {gsub(/ \| /," \\| ");
  88.             gsub(/ \|    /," \\|    ");
  89.             gsub(/    \| /,"    \\| ");
  90.             gsub(/    \|    /,"    \\|    "); }
  91. /'\|'/ { gsub(/'\|'/,"'\\|'"); }
  92. /\^V\|/ {gsub(/\^V\|/,"^V\\|");}
  93. / \\\|    / {gsub(/\|/,"\\|");}
  94. #
  95. # one letter pipes and "||" false pipe (digraphs)
  96. #
  97. /[     ]\|.\|[     ]/ && asciiart == "no" {gsub(/\|/,"YXXY"); }
  98. /^\|.\|[     ]/ {gsub(/\|/,"YXXY"); }
  99. /\|\|/ {gsub(/\|\|/,"\\|\\|"); }
  100. /^shellpipe/ {gsub(/\|/,"\\|"); }
  101. #
  102. # pipe start
  103. #
  104. /[     ]\|[^     ]/ && asciiart == "no"    {gsub(/ \|/," YXXY");
  105.             gsub(/    \|/,"    YXXY");}
  106. /^\|[^     ]/      {gsub(/^\|/,"YXXY");}
  107. #
  108. # pipe end
  109. #
  110. /[^     ]\|$/ && asciiart == "no" {gsub(/\|$/,"YXXY");}
  111. /[^     ]\|[s ,.);    ]/ && asciiart == "no" {gsub(/\|/,"YXXY");}
  112. /[^     ]\|]/ && asciiart == "no" {gsub(/\|/,"YXXY");}
  113. #
  114. # various
  115. #
  116. /'"/     {gsub(/'"/,"\\'\\"'");}
  117. /"/    {gsub(/"/,"\\"");}
  118. /%/    {gsub(/%/,"\\%");}
  119.  
  120. NR == 1 { nf=split(FILENAME,f,".")
  121.     print "<HTML>";
  122.     print "<HEAD><TITLE>Vim documentation: " f[1] "</TITLE></HEAD>";
  123.     print "<BODY BGCOLOR=\"#ffffff\">";
  124.     print "<H1>Vim documentation: " f[1] "</H1>";
  125.     print "<A NAME=\"top\"></A>";
  126.     if ( FILENAME != "help.txt" ) {
  127.       print "<A HREF=\"help.html\">main help file</A>\n";
  128.     }
  129.     print "<HR>";
  130.     print "<PRE>";
  131.     filename=f[1]".html";
  132. }
  133.  
  134. # set to a low value to test for few lines of text
  135. # NR == 99999 { exit; }
  136.  
  137. # ignore underlines and tags
  138. substr($0,1,5) == " vim:" { next; }
  139. substr($0,1,4) == "vim:" { next; }
  140. # keep just whole lines of "-", "="
  141. substr($0,1,3) == "===" && substr($0,75,1) != "=" { next; }
  142. substr($0,1,3) == "---" && substr($0,75,1) != "-" { next; }
  143.  
  144. {
  145.     nstar = split($0,s,"ZWWZ");
  146.     for ( i=2 ; i <= nstar ; i=i+2 ) {
  147.         nbla=split(s[i],blata,"[     ]");
  148.         if ( nbla > 1 ) {
  149.             gsub("ZWWZ","*");
  150.             nstar = split($0,s,"ZWWZ");
  151.         }
  152.     }
  153.     npipe = split($0,p,"YXXY");
  154.     for ( i=2 ; i <= npipe ; i=i+2 ) {
  155.         nbla=split(p[i],blata,"[     ]");
  156.         if ( nbla > 1 ) {
  157.             gsub("YXXY","|");
  158.             ntabs = split($0,p,"YXXY");
  159.         }
  160.     }
  161. }
  162.  
  163.  
  164. FILENAME == "gui.txt" && asciiart == "no"  \
  165.       && $0 ~ /\+----/ && $0 ~ /----\+/ {
  166.     asciiart= "yes";
  167.     asciicnt=0;
  168.     }
  169.  
  170. FILENAME == "quotes.txt" && asciiart == "no" \
  171.       && $0 ~ /In summary:/ {
  172.     asciiart= "yes";
  173.     asciicnt=0;
  174.     }
  175.  
  176. FILENAME == "usr_20.txt" && asciiart == "no" \
  177.       && $0 ~ /an empty line at the end:/ {
  178.     asciiart= "yes";
  179.     asciicnt=0;
  180.     }
  181.  
  182. asciiart == "yes" && $0=="" { asciicnt++; }
  183.  
  184. asciiart == "yes" && asciicnt == 2 { asciiart = "no"; }
  185.  
  186. asciiart == "yes" { npipe = 1; }
  187. #    { print NR " <=> " asciiart; }
  188.  
  189. #
  190. # line contains  "*"
  191. #
  192. nstar > 2 && npipe < 3 {
  193.     printf("\n");
  194.     for ( i=1; i <= nstar ; i=i+2 ) {
  195.         this=s[i];
  196.         put_this();
  197.         ii=i+1;
  198.         nbla = split(s[ii],blata," ");
  199.         if ( ii <= nstar ) {
  200.             if ( nbla == 1 && substr(s[ii],length(s[ii]),1) != " " ) {
  201.             printf("*<A NAME=\"%s\"></A>",s[ii]);
  202.                 printf("<B>%s</B>*",s[ii]);
  203.             } else {
  204.             printf("*%s*",s[ii]);
  205.             }
  206.         }
  207.     }
  208.     printf("\n");
  209.     next;
  210.     }
  211. #
  212. # line contains "|"
  213. #
  214. npipe > 2 && nstar < 3 {
  215.     if  ( npipe%2 == 0 ) {
  216.         for ( i=1; i < npipe ; i++ ) {
  217.             gsub("ZWWZ","*",p[i]);
  218.             printf("%s|",p[i]);
  219.         }
  220.         printf("%s\n",p[npipe]);
  221.         next;
  222.         }
  223.     for ( i=1; i <= npipe ; i++ )
  224.         {
  225.         if ( i % 2 == 1 ) {
  226.             gsub("ZWWZ","*",p[i]);
  227.             this=p[i];
  228.             put_this();
  229.             }
  230.             else {
  231.             nfn=split(p[i],f,".");
  232.             if ( nfn == 1 || f[2] == "" || f[1] == "" || length(f[2]) < 3 ) {
  233.                 find_tag1();
  234.                 }
  235.                 else {
  236.         printf "|<A HREF=\"" f[1] ".html\">" p[i] "</A>|";
  237.                 }
  238.             }
  239.         }
  240.         printf("\n");
  241.         next;
  242.     }
  243. #
  244. # line contains both "|" and "*"
  245. #
  246. npipe > 2 && nstar > 2 {
  247.     printf("\n");
  248.     for ( j=1; j <= nstar ; j=j+2 ) {
  249.         npipe = split(s[j],p,"YXXY");
  250.         if ( npipe > 1 ) {
  251.             for ( np=1; np<=npipe; np=np+2 ) {
  252.                 this=p[np];
  253.                 put_this();
  254.                 i=np+1;find_tag1();
  255.             }
  256.         } else {
  257.             this=s[j];
  258.             put_this();
  259.         }
  260.         jj=j+1;
  261.         nbla = split(s[jj],blata," ");
  262.         if ( jj <= nstar && nbla == 1 && s[jj] != "" ) {
  263.         printf("*<A NAME=\"%s\"></A>",s[jj]);
  264.             printf("<B>%s</B>*",s[jj]);
  265.         } else {
  266.             if ( s[jj] != "" ) {
  267.             printf("*%s*",s[jj]);
  268.             }
  269.         }
  270.     }
  271.     printf("\n");
  272.     next;
  273.     }
  274. #
  275. # line contains e-mail address john.doe@some.place.edu
  276. #
  277. $0 ~ /@/ && $0 ~ /[a-zA-Z0-9]@[a-z]/ \
  278.     {
  279.     nemail=split($0,em," ");
  280.     if ( substr($0,1,1) == "    " ) { printf("    "); }
  281.     for ( i=1; i <= nemail; i++ ) {
  282.         if ( em[i] ~ /@/ ) {
  283.             if ( substr(em[i],2,3) == "lt;" && substr(em[i],length(em[i])-2,3) == "gt;" ) {
  284.                 mailaddr=substr(em[i],5,length(em[i])-8);
  285.                 printf("<A HREF=\"mailto:%s\"><%s></A> ",mailaddr,mailaddr);
  286.             } else {
  287.                 if ( substr(em[i],2,3) == "lt;" && substr(em[i],length(em[i])-3,3) == "gt;" ) {
  288.                     mailaddr=substr(em[i],5,length(em[i])-9);
  289.                     printf("<A HREF=\"mailto:%s\"><%s></A>%s ",mailaddr,mailaddr,substr(em[i],length(em[i]),1));
  290.                 } else {
  291.                     printf("<A HREF=\"mailto:%s\">%s</A> ",em[i],em[i]);
  292.                 }
  293.             }
  294.         } else {
  295.                 printf("%s ",em[i]);
  296.         }
  297.     }
  298.     #print "*** " NR " " FILENAME " - possible mail ref";
  299.     printf("\n");
  300.     next;
  301.     }
  302. #
  303. # line contains http / ftp reference
  304. #
  305. $0 ~ /http:\/\// || $0 ~ /ftp:\/\// {
  306.     gsub("URL:","");
  307.     gsub("<","");
  308.     gsub(">","");
  309.     gsub("\\(","");
  310.     gsub("\\)","");
  311.     nemail=split($0,em," ");
  312.     for ( i=1; i <= nemail; i++ ) {
  313.         if ( substr(em[i],1,5) == "http:" ||
  314.              substr(em[i],1,4) == "ftp:" ) {
  315.             if ( substr(em[i],length(em[i]),1) != "." ) {
  316.                 printf("    <A HREF=\"%s\">%s</A>",em[i],em[i]);
  317.             } else {
  318.                 em[i]=substr(em[i],1,length(em[i])-1);
  319.                 printf("    <A HREF=\"%s\">%s</A>.",em[i],em[i]);
  320.             }
  321.         } else {
  322.         printf(" %s",em[i]);
  323.         }
  324.     }
  325.     #print "*** " NR " " FILENAME " - possible http ref";
  326.     printf("\n");
  327.     next;
  328.     }
  329. #
  330. # some lines contains just one "almost regular" "*"...
  331. #
  332. nstar == 2  {
  333.     this=s[1];
  334.     put_this();
  335.     printf("*");
  336.     this=s[2];
  337.     put_this();
  338.     printf("\n");
  339.     next;
  340.     }
  341. #
  342. # regular line
  343. #
  344.     { ntabs = split($0,tb,"    ");
  345.     for ( i=1; i < ntabs ; i++) {
  346.         this=tb[i];
  347.         put_this();
  348.         printf("    ");
  349.         }
  350.     this=tb[ntabs];
  351.     put_this();
  352.     printf("\n");
  353.     }
  354.  
  355.  
  356. asciiart == "yes"  && $0 ~ /\+-\+--/  \
  357.     && $0 ~ "scrollbar" { asciiart = "no"; }
  358.  
  359. END {
  360.     topback();
  361.     print "</PRE>\n</BODY>\n\n\n</HTML>"; }
  362.  
  363. #
  364. # as main we keep index.txt (by default)
  365. # other candidate, help.txt
  366. #
  367. function topback () {
  368.     if ( FILENAME != "tags" ) {
  369.     if ( FILENAME != "help.txt" ) {
  370.     printf("<A HREF=\"#top\">top</A> - ");
  371.     printf("<A HREF=\"help.html\">main help file</A>\n");
  372.     } else {
  373.     printf("<A HREF=\"#top\">top</A>\n");
  374.     }
  375.     }
  376. }
  377.  
  378. function find_tag1() {
  379.     if ( p[i] == "" ) { return; }
  380.     if ( tagkey[p[i]] == "yes" ) {
  381.         which=tagref[p[i]];
  382.         put_href();
  383.         return;
  384.     }
  385.     # if not found, then we have a problem
  386.     print "============================================"  >>"errors.log";
  387.     print FILENAME ", line " NR ", pointer: >>" p[i] "<<" >>"errors.log";
  388.     print $0 >>"errors.log";
  389.     which="intro.html";
  390.     put_href();
  391. }
  392.  
  393. function see_tag() {
  394. # ad-hoc code:
  395. if ( atag == "\"--" || atag == "--\"" ) { return; }
  396. if_already();
  397. if ( already == "yes" ) {
  398.     printf("%s",aword);
  399.     return;
  400.     }
  401. allow_one_char="no";
  402. find_tag2();
  403. if ( done == "yes" ) { return; }
  404. rightchar=substr(atag,length(atag),1);
  405. if (    rightchar == "." \
  406.      || rightchar == "," \
  407.      || rightchar == ":" \
  408.      || rightchar == ";" \
  409.      || rightchar == "!" \
  410.      || rightchar == "?" \
  411.      || rightchar == ")" ) {
  412.     atag=substr(atag,1,length(atag)-1);
  413.     if_already();
  414.     if ( already == "yes" ) {
  415.         printf("%s",aword);
  416.         return;
  417.     }
  418.     find_tag2();
  419.     if ( done == "yes" ) { printf("%s",rightchar);return; }
  420.     leftchar=substr(atag,1,1);
  421.     lastbut1=substr(atag,length(atag),1);
  422.     if (    leftchar == "'" && lastbut1 == "'"  ) {
  423.         allow_one_char="yes";
  424.         atag=substr(atag,2,length(atag)-2);
  425.         if_already();
  426.         if ( already == "yes" ) {
  427.             printf("%s",aword);
  428.             return;
  429.         }
  430.         printf("%s",leftchar);
  431.         aword=substr(atag,1,length(atag))""lastbut1""rightchar;
  432.         find_tag2();
  433.         if ( done == "yes" ) { printf("%s%s",lastbut1,rightchar);return; }
  434.         }
  435.     }
  436. atag=aword;
  437. leftchar=substr(atag,1,1);
  438. if (    leftchar == "'" && rightchar == "'"  ) {
  439.     allow_one_char="yes";
  440.     atag=substr(atag,2,length(atag)-2);
  441.     if  ( atag == "<" ) { printf(" |%s|%s| ",atag,p[2]); }
  442.     if_already();
  443.     if ( already == "yes" ) {
  444.         printf("%s",aword);
  445.         return;
  446.         }
  447.     printf("%s",leftchar);
  448.     find_tag2();
  449.     if ( done == "yes" ) { printf("%s",rightchar);return; }
  450.     printf("%s%s",atag,rightchar);
  451.     return;
  452.     }
  453. last2=substr(atag,length(atag)-1,2);
  454. first2=substr(atag,1,2);
  455. if (    first2 == "('" && last2 == "')"  ) {
  456.     allow_one_char="yes";
  457.     atag=substr(atag,3,length(atag)-4);
  458.     if_already();
  459.     if ( already == "yes" ) {
  460.         printf("%s",aword);
  461.         return;
  462.         }
  463.     printf("%s",first2);
  464.     find_tag2();
  465.     if ( done == "yes" ) { printf("%s",last2);return; }
  466.     printf("%s%s",atag,last2);
  467.     return;
  468.     }
  469. if ( last2 == ".)" ) {
  470.     atag=substr(atag,1,length(atag)-2);
  471.     if_already();
  472.     if ( already == "yes" ) {
  473.         printf("%s",aword);
  474.         return;
  475.         }
  476.     find_tag2();
  477.     if ( done == "yes" ) { printf("%s",last2);return; }
  478.     printf("%s%s",atag,last2);
  479.     return;
  480.     }
  481. if ( last2 == ")." ) {
  482.     atag=substr(atag,1,length(atag)-2);
  483.     find_tag2();
  484.     if_already();
  485.     if ( already == "yes" ) {
  486.         printf("%s",aword);
  487.         return;
  488.         }
  489.     if ( done == "yes" ) { printf("%s",last2);return; }
  490.     printf("%s%s",atag,last2);
  491.     return;
  492.     }
  493. first6=substr(atag,1,6);
  494. last6=substr(atag,length(atag)-5,6);
  495. if ( last6 == atag ) {
  496.     printf("%s",aword);
  497.     return;
  498.     }
  499. last6of7=substr(atag,length(atag)-6,6);
  500. if ( first6 == """ && last6of7 == """ && length(atag) > 12 ) {
  501.     allow_one_char="yes";
  502.     atag=substr(atag,7,length(atag)-13);
  503.     if_already();
  504.     if ( already == "yes" ) {
  505.         printf("%s",aword);
  506.         return;
  507.         }
  508.     printf("%s",first6);
  509.     find_tag2();
  510.     if ( done == "yes" ) { printf(""%s",rightchar); return; }
  511.     printf("%s"%s",atag,rightchar);
  512.     return;
  513.     }
  514. if ( first6 == """ && last6 != """ ) {
  515.     allow_one_char="yes";
  516.     atag=substr(atag,7,length(atag)-6);
  517.     if ( atag == "[" ) { printf(""%s",atag); return; }
  518.     if ( atag == "." ) { printf(""%s",atag); return; }
  519.     if ( atag == ":" ) { printf(""%s",atag); return; }
  520.     if ( atag == "a" ) { printf(""%s",atag); return; }
  521.     if ( atag == "A" ) { printf(""%s",atag); return; }
  522.     if ( atag == "g" ) { printf(""%s",atag); return; }
  523.     if_already();
  524.     if ( already == "yes" ) {
  525.         printf(""%s",atag);
  526.         return;
  527.         }
  528.     printf("%s",first6);
  529.     find_tag2();
  530.     if ( done == "yes" ) { return; }
  531.     printf("%s",atag);
  532.     return;
  533.     }
  534. if ( last6 == """ && first6 == """ ) {
  535.     allow_one_char="yes";
  536.     atag=substr(atag,7,length(atag)-12);
  537.     if_already();
  538.     if ( already == "yes" ) {
  539.         printf("%s",aword);
  540.         return;
  541.         }
  542.     printf("%s",first6);
  543.     find_tag2();
  544.     if ( done == "yes" ) { printf("%s",last6);return; }
  545.     printf("%s%s",atag,last6);
  546.     return;
  547.     }
  548. last6of7=substr(atag,length(atag)-6,6);
  549. if ( last6of7 == """ && first6 == """ ) {
  550.     allow_one_char="yes";
  551.     atag=substr(atag,7,length(atag)-13);
  552.     #printf("\natag=%s,aword=%s\n",atag,aword);
  553.     if_already();
  554.     if ( already == "yes" ) {
  555.         printf("%s",aword);
  556.         return;
  557.         }
  558.     printf("%s",first6);
  559.     find_tag2();
  560.     if ( done == "yes" ) { printf("%s%s",last6of7,rightchar);return; }
  561.     printf("%s%s%s",atag,last6of7,rightchar);
  562.     return;
  563.     }
  564. printf("%s",aword);
  565. }
  566.  
  567. function find_tag2() {
  568.     done="no";
  569.     # no blanks present in a tag...
  570.     ntags=split(atag,blata,"[     ]");
  571.     if ( ntags > 1 ) { return; }
  572.     if     ( ( allow_one_char == "no" ) && \
  573.           ( index("!#$%\&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",atag) !=0 ) ) {
  574.         return;
  575.     }
  576.     if ( skip_word[atag] == "yes" ) { return; }
  577.     if ( wasset == "yes" && lineset == NR ) {
  578.     wasset="no";
  579.     see_opt();
  580.     if ( done_opt == "yes" ) {return;}
  581.     }
  582.     if ( wasset == "yes" && lineset != NR ) {
  583.     wasset="no";
  584.     }
  585.     if ( atag == ":set" ) {
  586.     wasset="yes";
  587.     lineset=NR;
  588.     }
  589.     if ( tagkey[atag] == "yes" ) {
  590.         which=tagref[atag];
  591.         put_href2();
  592.         done="yes";
  593.     }
  594. }
  595.  
  596. function find_tag3() {
  597.     done="no";
  598.     # no blanks present in a tag...
  599.     ntags=split(btag,blata,"[     ]");
  600.     if ( ntags > 1 ) { return; }
  601.     if     ( ( allow_one_char == "no" ) && \
  602.           ( index("!#$%\&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",btag) !=0 ) ) {
  603.           return;
  604.     }
  605.     if ( skip_word[btag] == "yes" ) { return; }
  606.     if ( tagkey[btag] == "yes" ) {
  607.         which=tagref[btag];
  608.         put_href3();
  609.         done="yes";
  610.     }
  611. }
  612.  
  613. function put_href() {
  614.     if ( p[i] == "" ) { return; }
  615.     if ( which == FILENAME ) {
  616.         printf("|<A HREF=\"#%s\">%s</A>|",p[i],p[i]);
  617.         }
  618.         else {
  619.         nz=split(which,zz,".");
  620.         if ( zz[2] == "txt" || zz[1] == "tags" ) {
  621.         printf("|<A HREF=\"%s.html#%s\">%s</A>|",zz[1],p[i],p[i]);
  622.         }
  623.         else {
  624.         printf("|<A HREF=\"intro.html#%s\">%s</A>|",p[i],p[i]);
  625.         }
  626.     }
  627. }
  628.  
  629. function put_href2() {
  630.     if ( atag == "" ) { return; }
  631.     if ( which == FILENAME ) {
  632.         printf("<A HREF=\"#%s\">%s</A>",atag,atag);
  633.         }
  634.         else {
  635.         nz=split(which,zz,".");
  636.         if ( zz[2] == "txt" || zz[1] == "tags" ) {
  637.         printf("<A HREF=\"%s.html#%s\">%s</A>",zz[1],atag,atag);
  638.         }
  639.         else {
  640.         printf("<A HREF=\"intro.html#%s\">%s</A>",atag,atag);
  641.         }
  642.     }
  643. }
  644.  
  645. function put_href3() {
  646.     if ( btag == "" ) { return; }
  647.     if ( which == FILENAME ) {
  648.         printf("<A HREF=\"#%s\">%s</A>",btag,btag2);
  649.         }
  650.         else {
  651.         nz=split(which,zz,".");
  652.         if ( zz[2] == "txt" || zz[1] == "tags" ) {
  653.         printf("<A HREF=\"%s.html#%s\">%s</A>",zz[1],btag,btag2);
  654.         }
  655.         else {
  656.         printf("<A HREF=\"intro.html#%s\">%s</A>",btag,btag2);
  657.         }
  658.     }
  659. }
  660.  
  661. function put_this() {
  662.     ntab=split(this,ta,"    ");
  663.     for ( nta=1 ; nta <= ntab ; nta++ ) {
  664.         ata=ta[nta];
  665.         lata=length(ata);
  666.         aword="";
  667.         for ( iata=1 ; iata <=lata ; iata++ ) {
  668.             achar=substr(ata,iata,1);
  669.             if ( achar != " " ) { aword=aword""achar; }
  670.             else {
  671.                 if ( aword != "" ) { atag=aword;
  672.                     see_tag();
  673.                     aword="";
  674.                     printf(" "); }
  675.                 else    {
  676.                     printf(" ");
  677.                     }
  678.             }
  679.         }
  680.         if ( aword != "" ) { atag=aword;
  681.                     see_tag();
  682.                     }
  683.         if ( nta != ntab ) { printf("    "); }
  684.     }
  685. }
  686.  
  687. function if_already() {
  688.     already="no";
  689.     if  ( npipe < 2 ) { return; }
  690.     if  ( atag == ":au" && p[2] == ":autocmd" ) { already="yes";return; }
  691.     for ( npp=2 ; npp <= npipe ; npp=npp+2 ) {
  692.         if     (  (  (index(p[npp],atag)) != 0 \
  693.                   && length(p[npp]) > length(atag) \
  694.                   && length(atag) >= 1  \
  695.                 ) \
  696.                 || (p[npp] == atag) \
  697.             ) {
  698.         # printf("p=|%s|,tag=|%s| ",p[npp],atag);
  699.         already="yes"; return; }
  700.     }
  701. }
  702.  
  703. function see_opt() {
  704.     done_opt="no";
  705.     stag=atag;
  706.     nfields = split(atag,tae,"=");
  707.     if ( nfields > 1 )  {
  708.         btag="'"tae[1]"'";
  709.         btag2=tae[1];
  710.         find_tag3();
  711.         if (done == "yes") {
  712.             for ( ntae=2 ; ntae <= nfields ; ntae++ ) {
  713.                 printf("=%s",tae[ntae]);
  714.             }
  715.             atag=stag;
  716.             done_opt="yes";
  717.             return;
  718.         }
  719.         btag=tae[1];
  720.         btag2=tae[1];
  721.         find_tag3();
  722.         if ( done=="yes" ) {
  723.             for ( ntae=2 ; ntae <= nfields ; ntae++ ) {
  724.                 printf("=%s",tae[ntae]);
  725.             }
  726.             atag=stag;
  727.             done_opt="yes";
  728.             return;
  729.         }
  730.     }
  731.     nfields = split(atag,tae,""");
  732.     if ( nfields > 1 )  {
  733.         btag="'"tae[1]"'";
  734.         btag2=tae[1];
  735.            find_tag3();
  736.         if (done == "yes") {
  737.             printf(""");
  738.             atag=stag;
  739.             done_opt="yes";
  740.             return;
  741.         }
  742.         btag=tae[1];
  743.         btag2=tae[1];
  744.         find_tag3();
  745.         if (done == "yes") {
  746.             printf(""");
  747.             atag=stag;
  748.             done_opt="yes";
  749.             return;
  750.         }
  751.     }
  752.     btag="'"tae[1]"'";
  753.     btag2=tae[1];
  754.     find_tag3();
  755.     if (done == "yes") {
  756.         atag=stag;
  757.         done_opt="yes";
  758.         return;
  759.     }
  760.     btag=tae[1];
  761.     btag2=tae[1];
  762.     find_tag3();
  763.     if (done == "yes") {
  764.         atag=stag;
  765.         done_opt="yes";
  766.         return;
  767.     }
  768.     atag=stag;
  769. }
  770.