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 / mac / vim55rt.sit / runtime / doc / makehtml.awk < prev    next >
Encoding:
AWK Script  |  1999-09-25  |  16.2 KB  |  744 lines  |  [TEXT/MPS ]

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