makehtml.awk 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789
  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. # as help.txt renders into index.html and index.txt -> vimindex.html,
  10. # this hack is needed to get the links right to those pages.
  11. if ( tag[2] == "index.txt" ) {
  12. tag[2] = "vimindex.txt"
  13. } else if ( tag[2] == "help.txt" ) {
  14. tag[2] = "index.txt"
  15. }
  16. tagkey[tag[1]]="yes";tagref[tag[1]]=tag[2];
  17. }
  18. skip_word["and"]="yes";
  19. skip_word["backspace"]="yes";
  20. skip_word["beep"]="yes";
  21. skip_word["bugs"]="yes";
  22. skip_word["da"]="yes";
  23. skip_word["end"]="yes";
  24. skip_word["ftp"]="yes";
  25. skip_word["go"]="yes";
  26. skip_word["help"]="yes";
  27. skip_word["home"]="yes";
  28. skip_word["news"]="yes";
  29. skip_word["index"]="yes";
  30. skip_word["insert"]="yes";
  31. skip_word["into"]="yes";
  32. skip_word["put"]="yes";
  33. skip_word["reference"]="yes";
  34. skip_word["section"]="yes";
  35. skip_word["space"]="yes";
  36. skip_word["starting"]="yes";
  37. skip_word["toggle"]="yes";
  38. skip_word["various"]="yes";
  39. skip_word["version"]="yes";
  40. skip_word["is"]="yes";
  41. }
  42. #
  43. # protect special chars
  44. #
  45. /[><&á]/ {gsub(/&/,"\\&amp;");gsub(/>/,"\\&gt;");gsub(/</,"\\&lt;");gsub("á","\\&aacute;");}
  46. #
  47. # end of sample lines by non-blank in first column
  48. #
  49. sample == "yes" && substr($0,1,4) == "&lt;" { sample = "no"; gsub(/^&lt;/, " "); }
  50. sample == "yes" && substr($0,1,1) != " " && substr($0,1,1) != " " && length($0) > 0 { sample = "no" }
  51. #
  52. # sample lines printed bold unless empty...
  53. #
  54. sample == "yes" && $0 =="" { print ""; next; }
  55. sample == "yes" && $0 !="" { print "<B>" $0 "</B>"; next; }
  56. #
  57. # start of sample lines in next line
  58. #
  59. $0 == "&gt;" { sample = "yes"; print ""; next; }
  60. substr($0,length($0)-4,5) == " &gt;" { sample = "yes"; gsub(/ &gt;$/, ""); }
  61. #
  62. # header lines printed bold, colored
  63. #
  64. substr($0,length($0),1) == "~" { print "<B><FONT COLOR=\"PURPLE\">" substr($0,1,length($0)-1) "</FONT></B>"; next; }
  65. #
  66. #ad hoc code
  67. #
  68. /^"\|\& / {gsub(/\|/,"\\&#124;"); }
  69. / = b / {gsub(/ b /," \\&#98; "); }
  70. #
  71. # one letter tag
  72. #
  73. /[ ]\*.\*[ ]/ {gsub(/\*/,"ZWWZ"); }
  74. #
  75. # isolated "*"
  76. #
  77. /[ ]\*[ ]/ {gsub(/ \* /," \\&#42; ");
  78. gsub(/ \* /," \\&#42; ");
  79. gsub(/ \* /," \\&#42; ");
  80. gsub(/ \* /," \\&#42; "); }
  81. #
  82. # tag start
  83. #
  84. /[ ]\*[^ ]/ {gsub(/ \*/," ZWWZ");gsub(/ \*/," ZWWZ");}
  85. /^\*[^ ]/ {gsub(/^\*/,"ZWWZ");}
  86. #
  87. # tag end
  88. #
  89. /[^ ]\*$/ {gsub(/\*$/,"ZWWZ");}
  90. /[^ \/ ]\*[ ]/ {gsub(/\*/,"ZWWZ");}
  91. #
  92. # isolated "|"
  93. #
  94. /[ ]\|[ ]/ {gsub(/ \| /," \\&#124; ");
  95. gsub(/ \| /," \\&#124; ");
  96. gsub(/ \| /," \\&#124; ");
  97. gsub(/ \| /," \\&#124; "); }
  98. /'\|'/ { gsub(/'\|'/,"'\\&#124;'"); }
  99. /\^V\|/ {gsub(/\^V\|/,"^V\\&#124;");}
  100. / \\\| / {gsub(/\|/,"\\&#124;");}
  101. #
  102. # one letter pipes and "||" false pipe (digraphs)
  103. #
  104. /[ ]\|.\|[ ]/ && asciiart == "no" {gsub(/\|/,"YXXY"); }
  105. /^\|.\|[ ]/ {gsub(/\|/,"YXXY"); }
  106. /\|\|/ {gsub(/\|\|/,"\\&#124;\\&#124;"); }
  107. /^shellpipe/ {gsub(/\|/,"\\&#124;"); }
  108. #
  109. # pipe start
  110. #
  111. /[ ]\|[^ ]/ && asciiart == "no" {gsub(/ \|/," YXXY");
  112. gsub(/ \|/," YXXY");}
  113. /^\|[^ ]/ {gsub(/^\|/,"YXXY");}
  114. #
  115. # pipe end
  116. #
  117. /[^ ]\|$/ && asciiart == "no" {gsub(/\|$/,"YXXY");}
  118. /[^ ]\|[s ,.); ]/ && asciiart == "no" {gsub(/\|/,"YXXY");}
  119. /[^ ]\|]/ && asciiart == "no" {gsub(/\|/,"YXXY");}
  120. #
  121. # various
  122. #
  123. /'"/ {gsub(/'"/,"\\&#39;\\&#34;'");}
  124. /"/ {gsub(/"/,"\\&quot;");}
  125. /%/ {gsub(/%/,"\\&#37;");}
  126. NR == 1 { nf=split(FILENAME,f,".")
  127. print "<HTML>";
  128. print "<HEAD>"
  129. if ( FILENAME == "mbyte.txt" ) {
  130. # needs utf-8 as uses many languages
  131. print "<META HTTP-EQUIV=\"Content-type\" content=\"text/html; charset=UTF-8\">";
  132. } else {
  133. # common case - Latin1
  134. print "<META HTTP-EQUIV=\"Content-type\" content=\"text/html; charset=ISO-8859-1\">";
  135. }
  136. print "<TITLE>Nvim documentation: " f[1] "</TITLE>";
  137. print "</HEAD>";
  138. print "<BODY BGCOLOR=\"#ffffff\">";
  139. print "<H1>Nvim documentation: " f[1] "</H1>";
  140. print "<A NAME=\"top\"></A>";
  141. if ( FILENAME != "help.txt" ) {
  142. print "<A HREF=\"index.html\">main help file</A>\n";
  143. }
  144. print "<HR>";
  145. print "<PRE>";
  146. filename=f[1]".html";
  147. }
  148. # set to a low value to test for few lines of text
  149. # NR == 99999 { exit; }
  150. # ignore underlines and tags
  151. substr($0,1,5) == " vim:" { next; }
  152. substr($0,1,4) == "vim:" { next; }
  153. # keep just whole lines of "-", "="
  154. substr($0,1,3) == "===" && substr($0,75,1) != "=" { next; }
  155. substr($0,1,3) == "---" && substr($0,75,1) != "-" { next; }
  156. {
  157. nstar = split($0,s,"ZWWZ");
  158. for ( i=2 ; i <= nstar ; i=i+2 ) {
  159. nbla=split(s[i],blata,"[ ]");
  160. if ( nbla > 1 ) {
  161. gsub("ZWWZ","*");
  162. nstar = split($0,s,"ZWWZ");
  163. }
  164. }
  165. npipe = split($0,p,"YXXY");
  166. for ( i=2 ; i <= npipe ; i=i+2 ) {
  167. nbla=split(p[i],blata,"[ ]");
  168. if ( nbla > 1 ) {
  169. gsub("YXXY","|");
  170. ntabs = split($0,p,"YXXY");
  171. }
  172. }
  173. }
  174. FILENAME == "gui.txt" && asciiart == "no" \
  175. && $0 ~ /\+----/ && $0 ~ /----\+/ {
  176. asciiart= "yes";
  177. asciicnt=0;
  178. }
  179. FILENAME == "usr_20.txt" && asciiart == "no" \
  180. && $0 ~ /an empty line at the end:/ {
  181. asciiart= "yes";
  182. asciicnt=0;
  183. }
  184. asciiart == "yes" && $0=="" { asciicnt++; }
  185. asciiart == "yes" && asciicnt == 2 { asciiart = "no"; }
  186. asciiart == "yes" { npipe = 1; }
  187. # { print NR " <=> " asciiart; }
  188. #
  189. # line contains "*"
  190. #
  191. nstar > 2 && npipe < 3 {
  192. printf("\n");
  193. for ( i=1; i <= nstar ; i=i+2 ) {
  194. this=s[i];
  195. put_this();
  196. ii=i+1;
  197. nbla = split(s[ii],blata," ");
  198. if ( ii <= nstar ) {
  199. if ( nbla == 1 && substr(s[ii],length(s[ii]),1) != " " ) {
  200. printf("*<A NAME=\"%s\"></A>",s[ii]);
  201. printf("<B>%s</B>*",s[ii]);
  202. } else {
  203. printf("*%s*",s[ii]);
  204. }
  205. }
  206. }
  207. printf("\n");
  208. next;
  209. }
  210. #
  211. # line contains "|"
  212. #
  213. npipe > 2 && nstar < 3 {
  214. if ( npipe%2 == 0 ) {
  215. for ( i=1; i < npipe ; i++ ) {
  216. gsub("ZWWZ","*",p[i]);
  217. printf("%s|",p[i]);
  218. }
  219. printf("%s\n",p[npipe]);
  220. next;
  221. }
  222. for ( i=1; i <= npipe ; i++ )
  223. {
  224. if ( i % 2 == 1 ) {
  225. gsub("ZWWZ","*",p[i]);
  226. this=p[i];
  227. put_this();
  228. }
  229. else {
  230. nfn=split(p[i],f,".");
  231. if ( nfn == 1 || f[2] == "" || f[1] == "" || length(f[2]) < 3 ) {
  232. find_tag1();
  233. }
  234. else {
  235. if ( f[1] == "index" ) {
  236. printf "|<A HREF=\"vimindex.html\">" p[i] "</A>|";
  237. } else {
  238. if ( f[1] == "help" ) {
  239. printf "|<A HREF=\"index.html\">" p[i] "</A>|";
  240. } else {
  241. printf "|<A HREF=\"" f[1] ".html\">" p[i] "</A>|";
  242. }
  243. }
  244. }
  245. }
  246. }
  247. printf("\n");
  248. next;
  249. }
  250. #
  251. # line contains both "|" and "*"
  252. #
  253. npipe > 2 && nstar > 2 {
  254. printf("\n");
  255. for ( j=1; j <= nstar ; j=j+2 ) {
  256. npipe = split(s[j],p,"YXXY");
  257. if ( npipe > 1 ) {
  258. for ( np=1; np<=npipe; np=np+2 ) {
  259. this=p[np];
  260. put_this();
  261. i=np+1;find_tag1();
  262. }
  263. } else {
  264. this=s[j];
  265. put_this();
  266. }
  267. jj=j+1;
  268. nbla = split(s[jj],blata," ");
  269. if ( jj <= nstar && nbla == 1 && s[jj] != "" ) {
  270. printf("*<A NAME=\"%s\"></A>",s[jj]);
  271. printf("<B>%s</B>*",s[jj]);
  272. } else {
  273. if ( s[jj] != "" ) {
  274. printf("*%s*",s[jj]);
  275. }
  276. }
  277. }
  278. printf("\n");
  279. next;
  280. }
  281. #
  282. # line contains e-mail address john.doe@some.place.edu
  283. #
  284. $0 ~ /@/ && $0 ~ /[a-zA-Z0-9]@[a-z]/ \
  285. {
  286. nemail=split($0,em," ");
  287. if ( substr($0,1,1) == " " ) { printf(" "); }
  288. for ( i=1; i <= nemail; i++ ) {
  289. if ( em[i] ~ /@/ ) {
  290. if ( substr(em[i],2,3) == "lt;" && substr(em[i],length(em[i])-2,3) == "gt;" ) {
  291. mailaddr=substr(em[i],5,length(em[i])-8);
  292. printf("<A HREF=\"mailto:%s\">&lt;%s&gt;</A> ",mailaddr,mailaddr);
  293. } else {
  294. if ( substr(em[i],2,3) == "lt;" && substr(em[i],length(em[i])-3,3) == "gt;" ) {
  295. mailaddr=substr(em[i],5,length(em[i])-9);
  296. printf("<A HREF=\"mailto:%s\">&lt;%s&gt;</A>%s ",mailaddr,mailaddr,substr(em[i],length(em[i]),1));
  297. } else {
  298. printf("<A HREF=\"mailto:%s\">%s</A> ",em[i],em[i]);
  299. }
  300. }
  301. } else {
  302. printf("%s ",em[i]);
  303. }
  304. }
  305. #print "*** " NR " " FILENAME " - possible mail ref";
  306. printf("\n");
  307. next;
  308. }
  309. #
  310. # line contains http / ftp reference
  311. #
  312. $0 ~ /http:\/\// || $0 ~ /ftp:\/\// {
  313. gsub("URL:","");
  314. gsub("&lt;","");
  315. gsub("&gt;","");
  316. gsub("\\(","");
  317. gsub("\\)","");
  318. nemail=split($0,em," ");
  319. for ( i=1; i <= nemail; i++ ) {
  320. if ( substr(em[i],1,5) == "http:" ||
  321. substr(em[i],1,4) == "ftp:" ) {
  322. if ( substr(em[i],length(em[i]),1) != "." ) {
  323. printf(" <A HREF=\"%s\">%s</A>",em[i],em[i]);
  324. } else {
  325. em[i]=substr(em[i],1,length(em[i])-1);
  326. printf(" <A HREF=\"%s\">%s</A>.",em[i],em[i]);
  327. }
  328. } else {
  329. printf(" %s",em[i]);
  330. }
  331. }
  332. #print "*** " NR " " FILENAME " - possible http ref";
  333. printf("\n");
  334. next;
  335. }
  336. #
  337. # some lines contains just one "almost regular" "*"...
  338. #
  339. nstar == 2 {
  340. this=s[1];
  341. put_this();
  342. printf("*");
  343. this=s[2];
  344. put_this();
  345. printf("\n");
  346. next;
  347. }
  348. #
  349. # regular line
  350. #
  351. { ntabs = split($0,tb," ");
  352. for ( i=1; i < ntabs ; i++) {
  353. this=tb[i];
  354. put_this();
  355. printf(" ");
  356. }
  357. this=tb[ntabs];
  358. put_this();
  359. printf("\n");
  360. }
  361. asciiart == "yes" && $0 ~ /\+-\+--/ \
  362. && $0 ~ "scrollbar" { asciiart = "no"; }
  363. END {
  364. topback();
  365. print "</PRE>\n</BODY>\n\n\n</HTML>"; }
  366. #
  367. # as main we keep index.txt (by default)
  368. #
  369. function topback () {
  370. if ( FILENAME != "tags" ) {
  371. if ( FILENAME != "help.txt" ) {
  372. printf("<A HREF=\"#top\">top</A> - ");
  373. printf("<A HREF=\"index.html\">main help file</A>\n");
  374. } else {
  375. printf("<A HREF=\"#top\">top</A>\n");
  376. }
  377. }
  378. }
  379. function find_tag1() {
  380. if ( p[i] == "" ) { return; }
  381. if ( tagkey[p[i]] == "yes" ) {
  382. which=tagref[p[i]];
  383. put_href();
  384. return;
  385. }
  386. # if not found, then we have a problem
  387. print "============================================" >>"errors.log";
  388. print FILENAME ", line " NR ", pointer: >>" p[i] "<<" >>"errors.log";
  389. print $0 >>"errors.log";
  390. which="intro.html";
  391. put_href();
  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 == "&quot;" && last6of7 == "&quot;" && 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("&quot;%s",rightchar); return; }
  511. printf("%s&quot;%s",atag,rightchar);
  512. return;
  513. }
  514. if ( first6 == "&quot;" && last6 != "&quot;" ) {
  515. allow_one_char="yes";
  516. atag=substr(atag,7,length(atag)-6);
  517. if ( atag == "[" ) { printf("&quot;%s",atag); return; }
  518. if ( atag == "." ) { printf("&quot;%s",atag); return; }
  519. if ( atag == ":" ) { printf("&quot;%s",atag); return; }
  520. if ( atag == "a" ) { printf("&quot;%s",atag); return; }
  521. if ( atag == "A" ) { printf("&quot;%s",atag); return; }
  522. if ( atag == "g" ) { printf("&quot;%s",atag); return; }
  523. if_already();
  524. if ( already == "yes" ) {
  525. printf("&quot;%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 == "&quot;" && first6 == "&quot;" ) {
  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 == "&quot;" && first6 == "&quot;" ) {
  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. function find_tag2() {
  567. done="no";
  568. # no blanks present in a tag...
  569. ntags=split(atag,blata,"[ ]");
  570. if ( ntags > 1 ) { return; }
  571. if ( ( allow_one_char == "no" ) && \
  572. ( index("!#$%&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",atag) !=0 ) ) {
  573. return;
  574. }
  575. if ( skip_word[atag] == "yes" ) { return; }
  576. if ( wasset == "yes" && lineset == NR ) {
  577. wasset="no";
  578. see_opt();
  579. if ( done_opt == "yes" ) {return;}
  580. }
  581. if ( wasset == "yes" && lineset != NR ) {
  582. wasset="no";
  583. }
  584. if ( atag == ":set" ) {
  585. wasset="yes";
  586. lineset=NR;
  587. }
  588. if ( tagkey[atag] == "yes" ) {
  589. which=tagref[atag];
  590. put_href2();
  591. done="yes";
  592. }
  593. }
  594. function find_tag3() {
  595. done="no";
  596. # no blanks present in a tag...
  597. ntags=split(btag,blata,"[ ]");
  598. if ( ntags > 1 ) { return; }
  599. if ( ( allow_one_char == "no" ) && \
  600. ( index("!#$%&'()+,-./0:;=?@ACINX\\[\\]^_`at\\{\\}~",btag) !=0 ) ) {
  601. return;
  602. }
  603. if ( skip_word[btag] == "yes" ) { return; }
  604. if ( tagkey[btag] == "yes" ) {
  605. which=tagref[btag];
  606. put_href3();
  607. done="yes";
  608. }
  609. }
  610. function put_href() {
  611. if ( p[i] == "" ) { return; }
  612. if ( which == FILENAME ) {
  613. printf("|<A HREF=\"#%s\">%s</A>|",p[i],p[i]);
  614. }
  615. else {
  616. nz=split(which,zz,".");
  617. if ( zz[2] == "txt" || zz[1] == "tags" ) {
  618. printf("|<A HREF=\"%s.html#%s\">%s</A>|",zz[1],p[i],p[i]);
  619. }
  620. else {
  621. printf("|<A HREF=\"intro.html#%s\">%s</A>|",p[i],p[i]);
  622. }
  623. }
  624. }
  625. function put_href2() {
  626. if ( atag == "" ) { return; }
  627. if ( which == FILENAME ) {
  628. printf("<A HREF=\"#%s\">%s</A>",atag,atag);
  629. }
  630. else {
  631. nz=split(which,zz,".");
  632. if ( zz[2] == "txt" || zz[1] == "tags" ) {
  633. printf("<A HREF=\"%s.html#%s\">%s</A>",zz[1],atag,atag);
  634. }
  635. else {
  636. printf("<A HREF=\"intro.html#%s\">%s</A>",atag,atag);
  637. }
  638. }
  639. }
  640. function put_href3() {
  641. if ( btag == "" ) { return; }
  642. if ( which == FILENAME ) {
  643. printf("<A HREF=\"#%s\">%s</A>",btag,btag2);
  644. }
  645. else {
  646. nz=split(which,zz,".");
  647. if ( zz[2] == "txt" || zz[1] == "tags" ) {
  648. printf("<A HREF=\"%s.html#%s\">%s</A>",zz[1],btag,btag2);
  649. }
  650. else {
  651. printf("<A HREF=\"intro.html#%s\">%s</A>",btag,btag2);
  652. }
  653. }
  654. }
  655. function put_this() {
  656. ntab=split(this,ta," ");
  657. for ( nta=1 ; nta <= ntab ; nta++ ) {
  658. ata=ta[nta];
  659. lata=length(ata);
  660. aword="";
  661. for ( iata=1 ; iata <=lata ; iata++ ) {
  662. achar=substr(ata,iata,1);
  663. if ( achar != " " ) { aword=aword""achar; }
  664. else {
  665. if ( aword != "" ) { atag=aword;
  666. see_tag();
  667. aword="";
  668. printf(" "); }
  669. else {
  670. printf(" ");
  671. }
  672. }
  673. }
  674. if ( aword != "" ) { atag=aword;
  675. see_tag();
  676. }
  677. if ( nta != ntab ) { printf(" "); }
  678. }
  679. }
  680. function if_already() {
  681. already="no";
  682. if ( npipe < 2 ) { return; }
  683. if ( atag == ":au" && p[2] == ":autocmd" ) { already="yes";return; }
  684. for ( npp=2 ; npp <= npipe ; npp=npp+2 ) {
  685. if ( ( (index(p[npp],atag)) != 0 \
  686. && length(p[npp]) > length(atag) \
  687. && length(atag) >= 1 \
  688. ) \
  689. || (p[npp] == atag) \
  690. ) {
  691. # printf("p=|%s|,tag=|%s| ",p[npp],atag);
  692. already="yes"; return; }
  693. }
  694. }
  695. function see_opt() {
  696. done_opt="no";
  697. stag=atag;
  698. nfields = split(atag,tae,"=");
  699. if ( nfields > 1 ) {
  700. btag="'"tae[1]"'";
  701. btag2=tae[1];
  702. find_tag3();
  703. if (done == "yes") {
  704. for ( ntae=2 ; ntae <= nfields ; ntae++ ) {
  705. printf("=%s",tae[ntae]);
  706. }
  707. atag=stag;
  708. done_opt="yes";
  709. return;
  710. }
  711. btag=tae[1];
  712. btag2=tae[1];
  713. find_tag3();
  714. if ( done=="yes" ) {
  715. for ( ntae=2 ; ntae <= nfields ; ntae++ ) {
  716. printf("=%s",tae[ntae]);
  717. }
  718. atag=stag;
  719. done_opt="yes";
  720. return;
  721. }
  722. }
  723. nfields = split(atag,tae,"&quot;");
  724. if ( nfields > 1 ) {
  725. btag="'"tae[1]"'";
  726. btag2=tae[1];
  727. find_tag3();
  728. if (done == "yes") {
  729. printf("&quot;");
  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. printf("&quot;");
  739. atag=stag;
  740. done_opt="yes";
  741. return;
  742. }
  743. }
  744. btag="'"tae[1]"'";
  745. btag2=tae[1];
  746. find_tag3();
  747. if (done == "yes") {
  748. atag=stag;
  749. done_opt="yes";
  750. return;
  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. atag=stag;
  761. }