home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / the25.zip / thesrc251.zip / man2html.rex < prev    next >
OS/2 REXX Batch file  |  1997-11-19  |  34KB  |  1,070 lines

  1. /*
  2.  * This script converts the output from manext to HTML
  3.  *
  4.  * Arguments:
  5.  *           section: one of OVERVIEW,COMMANDS,APPENDIX,GLOSSARY
  6.  *           infile:  file name of .man file
  7.  *           tocfile: file name of Table of Contents output file
  8.  */
  9. Trace o
  10. Parse Arg ver section infile tocfile .
  11. Select
  12.   When section = 'TOCSTART'  Then Call toc 'START' ver
  13.   When section = 'TOCEND'    Then Call toc 'END' ver
  14.   When section = 'OVERVIEW'  Then Call overview  infile tocfile 'Overview'
  15.   When section = 'COMM'      Then Call commands  infile tocfile 'Commands'
  16.   When section = 'COMMSET'   Then Call commands  infile tocfile 'SET Commands'
  17.   When section = 'COMMSOS'   Then Call commands  infile tocfile 'SOS Commands'
  18.   When section = 'QUERY'     Then Call query     infile tocfile 'Query and Extract'
  19.   When section = 'GLOSSARY'  Then Call glossary  infile tocfile 'Glossary'
  20.   When section = 'APPENDIX1' Then Call appendix1 infile tocfile 'Appendix 1'
  21.   When section = 'APPENDIX2' Then Call appendix2 infile tocfile 'Appendix 2'
  22.   When section = 'APPENDIX3' Then Call appendix2 infile tocfile 'Appendix 3'
  23.   When section = 'HISTORY'   Then Call history   infile tocfile 'History of THE'
  24.   When section = 'QUICKREF'  Then Call quickref  infile tocfile 'Quick Reference for THE'
  25.   Otherwise
  26.       Do
  27.         Say 'Error: Invalid section:' section 'specified'
  28.       End
  29. End
  30. Return
  31.  
  32. /********************************************************************/
  33. overview: Procedure
  34. Parse arg infile tocfile title
  35. toc. = ''
  36. toc_idx = 0
  37. in_code_section = 'N'
  38. already_read = 'N'
  39. in_list_section = 'N'
  40. first_heading = 'N'
  41. Call heading title
  42. Do While(Lines(infile)>0)
  43.    If already_read = 'N' Then line = Linein(infile)
  44.    already_read = 'N'
  45.    Select
  46.      When Strip(line) = Copies('=',72) Then
  47.           Do
  48.             line = Strip(Linein(infile))
  49.             toc_idx = toc_idx + 1
  50.             toc.toc_idx = '<DT>'MakeTOC(line,"")'</DT>'
  51.             Say '<HR>'
  52.             Say '<A NAME="'line'"></A>'
  53.             Say '<H2>' line '</H2>'
  54.             line = Linein(infile)
  55.             Say '<HR>'
  56.             first_heading = 'Y'
  57.           End
  58.      When Strip(line) = Copies('-',74) Then Iterate
  59.      When Substr(Strip(line),1,2) = '- ' Then
  60.           Do
  61.             tmp = ''
  62.             If in_list_section = 'Y' Then
  63.               Do
  64.                 tmp = Substr(Strip(line),3)
  65.                 Do Forever
  66.                    line = Linein(infile)
  67.                    Select
  68.                      When Strip(line) = '' Then 
  69.                           Do
  70.                             Say '<LI>' handle_keywords(tmp,'') '</LI>'
  71.                             Say '</UL>'
  72.                             in_list_section = 'N'
  73.                           End
  74.                      When Substr(Strip(line),1,2) = '- ' Then
  75.                           Do
  76.                             Say '<LI>' handle_keywords(tmp,'') '</LI>'
  77.                             already_read = 'Y'
  78.                           End
  79.                      Otherwise
  80.                           Do
  81.                             tmp = tmp line
  82.                           End
  83.                    End
  84.                    If in_list_section = 'N' | already_read = 'Y' Then Leave
  85.                 End
  86.               End
  87.             Else
  88.               Do
  89.                 Say '<UL>'
  90.                 in_list_section = 'Y'
  91.                 already_read = 'Y'
  92.               End
  93.           End
  94.      When Strip(line) = '+'||Copies('-',30) Then
  95.           Do
  96.             If in_code_section = 'Y' Then
  97.                Do
  98.                  Say '<IMG SRC=divbot.gif ALT="----------"><BR>'
  99.                  Say '</BLOCKQUOTE><P>'
  100.                  in_code_section = 'N'
  101.                End
  102.             Else
  103.                Do
  104.                  Say '<BLOCKQUOTE>'
  105.                  Say '<IMG SRC=divtop.gif ALT="----------"><BR>'
  106.                  in_code_section = 'Y'
  107.                End
  108.           End
  109.       Otherwise
  110.           Do
  111.             If first_heading = 'N' Then Iterate
  112.             If in_code_section = 'Y' Then
  113.                Do
  114.                  Say Strip(line) '<BR>'
  115.                End
  116.             Else
  117.                Do
  118.                  tmp = ''
  119.                  If Strip(line) = '' Then Iterate
  120.                  Do Forever
  121.                     tmp = tmp line
  122.                     line = Linein(infile)
  123.                     If Strip(line) = '' Then
  124.                       Do
  125.                         tmp = handle_keywords(tmp,"")
  126.                         Say tmp '<P>'
  127.                         Leave
  128.                       End
  129.                  End
  130.                End
  131.           End
  132.    End
  133. End
  134. Do i = 1 To toc_idx
  135.    Call Lineout tocfile, toc.i
  136. End
  137. Say '<P Align="Center"><HR>'
  138. Say 'The HTML version of this manual was inspired by <A HREF = "mailto:judygs@uic.edu">Judith Grobe Sachs </A>'
  139. Say '<P Align="Center"><HR>'
  140. Call footing
  141. Return
  142.  
  143. /********************************************************************/
  144. commands: Procedure
  145. Parse arg infile tocfile title
  146. toc. = ''
  147. toc_idx = 0
  148. already_read_line = 'N'
  149. once = 'Y'
  150. Call heading title
  151. Do While(Lines(infile)>0)
  152.    If already_read_line = 'N' Then line = Linein(infile)
  153.    already_read_line = 'N'
  154.    Select
  155.      When Strip(line) = Copies('=',72) Then
  156.           Do
  157.             line = Strip(Linein(infile))
  158.             toc_idx = toc_idx + 1
  159.             toc.toc_idx = '<DT>'MakeTOC(line,"")'</DT>'
  160.             Say '<P><HR><A NAME="'line'"></A>'
  161.             Say '<H2>' line '</H2>'
  162.             line = Linein(infile)
  163.           End
  164.      When Strip(line) = Copies('-',74) Then
  165.           Say '<HR>'
  166.      When line = '     COMMAND' Then
  167.           Do
  168.             line = Linein(infile)
  169.             Parse var line keyword '-' desc
  170.             keyword = Strip(keyword)
  171.             keyword_words = Words(keyword)
  172.             Say '<A NAME="'||SpecialTranslate(keyword)||'"></A>'
  173.             Say '<DL><DT>'
  174.             Say Bold(Translate(keyword)) '-' desc '<BR><BR></DT>'
  175.             toc_idx = toc_idx + 1
  176.             toc.toc_idx = '<DD>'MakeTOC(keyword,desc)'</DD>'
  177.           End
  178.      When line = '     SEE ALSO' Then
  179.           Do
  180.             Say '<DT>' Bold('See Also:') '<BR></DT>'
  181.             line = Linein(infile)
  182.             tmp = ''
  183.             Do Forever
  184.                Parse Var line '<' keyword '>' line
  185.                If keyword = '' Then Leave
  186.                tmp = tmp MakeRef('UPPER',',',keyword)
  187.                If line = '' Then Leave
  188.             End
  189.             tmp = Strip(tmp,'T',',')
  190.             Say '<DD>' tmp '<P></DD>'
  191.           End
  192.      When line = '     STATUS' Then 
  193.           Do
  194.             Say '<DT>' Bold('Status:') '<BR></DT>'
  195.             Do Forever
  196.                line = Linein(infile)
  197.                If line = '' Then Leave
  198.                Say '<DD>' Strip(line) '</DD>'
  199.             End
  200.             Say '</DL><P>'
  201.           End
  202.      When line = '     SYNTAX' Then
  203.           Do
  204.             Say '<DT>' Bold('Syntax:') '<BR></DT>'
  205.             syntax_words = ''
  206.             Do Forever
  207.                line = Linein(infile)
  208.                If line = '' Then Leave
  209.                pre = Subword(line,1,keyword_words)
  210.                post = Subword(line,keyword_words+1)
  211.                Say '<DD>' Strip(pre) Italic(strip(post)) '<P></DD>'
  212.                syntax_words = syntax_words Translate(post,"     ","/|[].")
  213.             End
  214.           End
  215.      When line = '     COMPATIBILITY' Then
  216.           Do
  217.             Say '<DT>' Bold('Compatibility:') '<BR></DT>'
  218.             first = 'Y'
  219.             Do Forever
  220.                line = Linein(infile)
  221.                If line = '' Then Leave
  222.                If first = 'Y' Then
  223.                  Do
  224.                    Say '<DD>' handle_keywords(Strip(line),'')
  225.                    first = 'N'
  226.                  End
  227.                Else
  228.                    Say '</DD><DD>' handle_keywords(Strip(line),'')
  229.             End
  230.             Say '<P></DD>'
  231.           End
  232.      When line = '     DEFAULT' Then
  233.           Do
  234.             Say '<DT>' Bold('Default:') '<BR></DT>'
  235.             Do Forever
  236.                line = Linein(infile)
  237.                If line = '' Then Leave
  238.                Parse Var line pre '<' keyword '>' post
  239.                If keyword \= '' Then line = pre MakeRef('UPPER',,keyword) post
  240.                Say '<DD>' Strip(line) '<P></DD>'
  241.             End
  242.           End
  243.      When line = '     DESCRIPTION' Then
  244.           Do
  245.             Say '<DT>' Bold('Description:') '<BR></DT>'
  246.             tmp = ''
  247.             inblock = 0
  248.             Do Forever
  249.                line = Linein(infile)
  250.                If Substr(Strip(line),1,31) = '+'||Copies('-',30) Then
  251.                  Do
  252.                    Say '<BLOCKQUOTE>'
  253.                    Say '<IMG SRC=divtop.gif ALT="----------"><BR>'
  254.                    Do Forever
  255.                      line = Linein(infile)
  256.                      If Substr(Strip(line),1,31) = '+'||Copies('-',30) Then Leave
  257.                      Say line '<BR>'
  258.                    End
  259.                    Say '<IMG SRC=divbot.gif ALT="----------"><BR>'
  260.                    Say '</BLOCKQUOTE><P>'
  261.                    Iterate
  262.                  End
  263.                If Substr(Strip(line),1,31) = '*'||Copies('-',30) Then
  264.                  Do
  265.                    Say '<PRE>'
  266.                    Do Forever
  267.                      line = Linein(infile)
  268.                      If Substr(Strip(line),1,31) = '*'||Copies('-',30) Then Leave
  269.                      Say line
  270.                    End
  271.                    Say '</PRE><P>'
  272.                    Iterate
  273.                  End
  274.                If Strip(line) = '' Then
  275.                  Do
  276.                    tmp = handle_keywords(tmp,syntax_words)
  277.                    Say '<DD>' Strip(tmp) '<P></DD>'
  278.                    If Substr(tmp,Length(tmp),1) = ':' Then 
  279.                       Do
  280.                         first = 'Y'
  281.                         Do Forever
  282.                            line = Strip(Linein(infile))
  283.                            If line = '' Then Leave
  284.                            If first = 'Y' Then
  285.                              Do
  286.                               Say '<DD>' handle_keywords(line,syntax_keywords)
  287.                               first = 'N'
  288.                              End
  289.                            Else
  290.                               Say '</DD><DD>' handle_keywords(line,syntax_keywords)
  291.                         End
  292.                         Say '<P></DD>'
  293.                       End
  294.                    tmp = ''
  295.                    Iterate
  296.                  End
  297.                If line = '     COMPATIBILITY' Then 
  298.                  Do
  299.                    already_read_line = 'Y'
  300.                    Leave
  301.                  End
  302.                If Pos('<>',line) \= 0 Then
  303.                  Do
  304.                    Parse Var line pre '<>' post
  305.                    line = pre||'<>'||post
  306.                  End
  307.                tmp = tmp line
  308.             End
  309.           End
  310.      Otherwise Nop
  311.    End
  312. End
  313. Do i = 1 To toc_idx
  314.    Call Lineout tocfile, toc.i
  315. End
  316. Call footing
  317. Return
  318.  
  319. /********************************************************************/
  320. glossary: Procedure
  321. Parse arg infile tocfile title
  322. toc. = ''
  323. toc_idx = 0
  324. already_read_line = 'N'
  325. first_time = 'Y'
  326. Call heading title
  327. Do While(Lines(infile)>0)
  328.    If already_read_line = 'N' Then line = Linein(infile)
  329.    already_read_line = 'N'
  330.    Select
  331.      When Strip(line) = Copies('=',72) Then
  332.           Do
  333.             line = Strip(Linein(infile))
  334.             toc_idx = toc_idx + 1
  335.             toc.toc_idx = '<DT>'MakeTOC(line,"")'</DT>'
  336.             Say '<HR><A NAME="'line'"></A>'
  337.             Say '<H2>' line '</H2>'
  338.             Say '<HR><P>'
  339.             Say '<DL>'
  340.             line = Linein(infile)
  341.           End
  342.      When Strip(line) = '' Then Nop
  343.      When Strip(line) = Copies('-',74) Then Say '</DL><HR>'
  344.      When Substr(line,1,15) = Copies(' ',15) Then
  345.           Do
  346.             tmp = Strip(line)
  347.             Do Forever
  348.                line = Strip(Linein(infile))
  349.                If line = '' Then Leave
  350.                tmp = tmp line
  351.             End
  352.             tmp = handle_keywords(tmp,'')
  353.             Say '<DD>' Strip(tmp) '<P></DD>'
  354.           End
  355.      Otherwise
  356.           Do
  357.             line = Strip(line)
  358.             Say '<DT><A NAME="'Translate(line)'">' Bold(line) '</A></DT>'
  359.             toc_idx = toc_idx + 1
  360.             toc.toc_idx = '<DD>'MakeTOC(line,"")'</DD>'
  361.           End
  362.    End
  363. End
  364. Do i = 1 To toc_idx
  365.    Call Lineout tocfile, toc.i
  366. End
  367. Call footing
  368. Return
  369.  
  370. /********************************************************************/
  371. query: Procedure
  372. Parse arg infile tocfile title
  373. toc. = ''
  374. toc_idx = 0
  375. already_read_line = 'N'
  376. once = 'Y'
  377. in_table = 'N'
  378. first_time = 'Y'
  379. Call heading title
  380. Do While(Lines(infile)>0)
  381.    If already_read_line = 'N' Then line = Linein(infile)
  382.    already_read_line = 'N'
  383.    Select
  384.      When Strip(line) = Copies('=',72) Then
  385.           Do
  386.             line = Strip(Linein(infile))
  387.             toc_idx = toc_idx + 1
  388.             toc.toc_idx = '<DT>'MakeTOC(line,"")'</DT>'
  389.             If first_time = 'N' Then Say '</DL>'
  390.             first_time = 'N'
  391.             Say '<A NAME="'Translate(line)'"></A>'
  392.             Say '<HR><H2>' line '</H2>'
  393.             Say '<HR><DL>'
  394.             line = Linein(infile)
  395.           End
  396.      When Strip(line) = '' & in_table = 'Y' Then
  397.           Do
  398.             in_table = 'N'
  399.             Say '</TABLE><P></DD>'
  400.           End
  401.      When Strip(line) = '' Then Nop
  402.      When Strip(line) = Copies('-',74) Then
  403.           Do
  404.             Say '</DL>'
  405.             Say '<HR>'
  406.           End
  407.      When Substr(line,26,3) = ' - ' Then
  408.           Do
  409.             If in_table = 'N' Then
  410.               Do
  411.                 Say '<DD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1>'
  412.                 in_table = 'Y'
  413.               End
  414.             Parse Var line col1 '-' col2
  415.             Say '<TR><TD>'||Strip(col1)||'</TD><TD>-</TD><TD>'||handle_keywords(Strip(col2),'')||'</TD></TR>'
  416.           End
  417.      When Substr(line,1,15) = Copies(' ',15) Then
  418.           Do
  419.             Say '<DD>' Strip(line) '</DD>'
  420.           End
  421.      When Substr(line,1,14) = Copies(' ',14) Then
  422.           Do
  423.             Say '<DD>'
  424.             Say '<IMG SRC=divtop.gif ALT="----------"><BR>'
  425.             Say Strip(line) '<BR>'
  426.             Do Forever
  427.               line = Linein(infile)
  428.               If Strip(line) = '' Then Leave
  429.               Say Strip(line) '<BR>'
  430.             End
  431.             Say '<IMG SRC=divbot.gif ALT="----------"><BR>'
  432.             Say '<P></DD>'
  433.           End
  434.      When Substr(line,1,10) = Copies(' ',10) Then
  435.           Do
  436.             tmp = line
  437.             Do Forever
  438.                line = Strip(Linein(infile))
  439.                Select
  440.                  When Substr(line,1,1) = '(' Then
  441.                       Do
  442.                         tmp = handle_keywords(tmp,'')
  443.                         Say '<DD>' Strip(tmp) '</DD>'
  444.                         Say '<DD>' line '<P></DD>'
  445.                         Leave
  446.                       End
  447.                  When line = '' Then 
  448.                       Do
  449.                         tmp = handle_keywords(tmp,'')
  450.                         Say '<DD>' Strip(tmp) '<P></DD>'
  451.                         Leave
  452.                       End
  453.                  Otherwise
  454.                       Do
  455.                         tmp = tmp line
  456.                       End
  457.                End
  458.             End
  459.           End
  460.      Otherwise
  461.           Do
  462.             pre = Subword(line,1,1)
  463.             post = Subword(line,2)
  464.             Say '<DT>'
  465.             If post = '' Then Say Bold(Strip(pre)) '<BR>'
  466.             Else Say Bold(Strip(pre)) Italic(strip(post)) '<BR>'
  467.             Say '</DT>'
  468.             syntax_words = Translate(post,"     ","/|[].")
  469.           End
  470.    End
  471. End
  472. Do i = 1 To toc_idx
  473.    Call Lineout tocfile, toc.i
  474. End
  475. Call footing
  476. Return
  477.  
  478. /********************************************************************/
  479. history: Procedure
  480. Parse arg infile tocfile title
  481. toc. = ''
  482. toc_idx = 0
  483. in_env = 'N'
  484. Call heading title
  485. inlist = 0
  486. ul = ''
  487. toc_idx = toc_idx + 1
  488. toc.toc_idx = '<DT>'MakeTOC(title,"")'</DT>'
  489. Say '<A NAME="'Translate(title)'"></A>'
  490. Say '<H2>' title '</H2>'
  491. Do While(Lines(infile)>0)
  492.    line = Linein(infile)
  493.    Select
  494.      When Strip(line) = '' Then Nop
  495.      When Substr(line,1,7) = 'Version' Then
  496.           Do
  497.             If inlist Then
  498.               Do
  499.                 If ul \= '' Then Say ul
  500.                 inlist = 0
  501.                 Say '</UL>'
  502.               End
  503.             Parse Var line v ver dt tail
  504.             head = v ver
  505.             toc_idx = toc_idx + 1
  506.             toc.toc_idx = '<DD>'MakeTOC(Strip(head),dt tail)'</DD>'
  507.             Say '<A NAME="'Translate(Strip(head))'"></A>'
  508.             Say '<HR>'
  509.             Say '<H2>' line '</H2>'
  510.             Say '<HR>'
  511.             ul = ''
  512.           End
  513.      When Substr(line,1,4) = " ---" Then
  514.           Do
  515.             If inlist Then
  516.               Do
  517.                 If ul \= '' Then Say ul
  518.                 inlist = 0
  519.                 Say '</UL>'
  520.               End
  521.             Say '<H4>'||Substr(line,5)||'</H4><UL>'
  522.             ul = ''
  523.           End
  524.      When Substr(line,1,6) = "     o" Then
  525.           Do
  526.             If ul \= '' Then Say ul
  527.             ul = '<LI>' Strip(Substr(line,7))
  528.             inlist = 1
  529.           End
  530.      When line = "         +---------------" Then
  531.           Do
  532.             If ul \= '' Then Say ul
  533.             Say '<PRE>'
  534.             inblock = 0
  535.             Do Forever
  536.                line = Linein(infile)
  537.                If line = "         +---------------" Then Leave
  538.                Say line
  539.             End
  540.             Say '</PRE><P>'
  541.             ul = ''
  542.           End
  543.      Otherwise
  544.           Do
  545.             ul = ul Strip(line)
  546.           End
  547.    End
  548. End
  549. Do i = 1 To toc_idx
  550.    Call Lineout tocfile, toc.i
  551. End
  552. If ul \= '' Then Say '<LI>' ul
  553. Say '</UL><HR>'
  554. Call footing
  555. Return
  556.  
  557. /********************************************************************/
  558. appendix1: Procedure
  559. Parse arg infile tocfile title
  560. toc. = ''
  561. toc_idx = 0
  562. in_env = 'N'
  563. Call heading title
  564. Do While(Lines(infile)>0)
  565.    line = Linein(infile)
  566.    Select
  567.      When Strip(line) = Copies('=',72) Then
  568.           Do
  569.             line = Strip(Linein(infile))
  570.             Parse Var line head '-' tail
  571.             toc_idx = toc_idx + 1
  572.             toc.toc_idx = '<DT>'MakeTOC(Strip(head),tail)'</DT>'
  573.             Say '<A NAME="'Strip(head)'"></A>'
  574.             Say '<H2>' line '</H2>'
  575.             Say '<HR>'
  576.             line = Linein(infile)
  577.           End
  578.      When Strip(line) = Copies('-',74) Then Say '<HR>'
  579.      When Substr(Strip(line),1,15) = Copies('-',15) Then
  580.           Do
  581.             line = Strip(Linein(infile))
  582.             Say '<HR>'
  583.             Say '<CENTER><B>'||line||'</B></CENTER>'
  584.             line = Linein(infile)
  585.             Say '<HR>'
  586.           End
  587.      When Substr(line,1,10) = '      THE_' Then
  588.           Do
  589.             Parse Var line env '-' rem
  590.             If in_env = 'N' Then Say '<DL>'
  591.             in_env = 'Y'
  592.             rem = handle_keywords(rem,'')
  593.             Say '<DT><B>'env'</B></DT>'
  594.             Say '<DD>' rem '<P></DD>'
  595.           End
  596.      When Strip(line) = '' & in_env = 'Y' Then 
  597.           Do
  598.             Say '</DL>'
  599.             in_env = 'N'
  600.           End
  601.      When Strip(line) = '' Then Nop
  602.      Otherwise
  603.           Do
  604.             tmp = Strip(line)
  605.             Do Forever
  606.                line = Strip(Linein(infile))
  607.                If line = '' Then Leave
  608.                tmp = tmp line
  609.             End
  610.           tmp = handle_keywords(tmp,'')
  611.           Say tmp '<P>'
  612.           End
  613.    End
  614. End
  615. Do i = 1 To toc_idx
  616.    Call Lineout tocfile, toc.i
  617. End
  618. Call footing
  619. Return
  620.  
  621. /********************************************************************/
  622. appendix2: Procedure
  623. Parse arg infile tocfile title
  624. toc. = ''
  625. toc_idx = 0
  626. in_table = 'N'
  627. Call heading title
  628. Do While(Lines(infile)>0)
  629.    line = Linein(infile)
  630.    Select
  631.      When Strip(line) = Copies('=',72) Then
  632.           Do
  633.             line = Strip(Linein(infile))
  634.             Parse Var line head '-' tail
  635.             toc_idx = toc_idx + 1
  636.             toc.toc_idx = '<DT>'MakeTOC(Strip(head),tail)'</DT>'
  637.             Say '<A NAME="'Strip(head)'"></A>'
  638.             Say '<H2>' line '</H2>'
  639.             Say '<HR>'
  640.             line = Linein(infile)
  641.           End
  642.      When Strip(line) = Copies('-',74) Then Say '<HR>'
  643.      When Substr(Strip(line),1,1) = '-' Then
  644.           Do
  645.             line = Linein(infile)
  646.             Say '<B>' Strip(line) '</B><P>'
  647.             line = Linein(infile)
  648.           End
  649.      When Substr(Strip(line),1,5) = '+----' & Length(Strip(line)) = 31 Then
  650.           Do
  651.             Say '<BLOCKQUOTE>'
  652.             Say '<IMG SRC=divtop.gif ALT="----------"><BR>'
  653.             Do Forever
  654.               line = Strip(Linein(infile))
  655.               If Substr(line,1,5) = '+----' Then Leave
  656.               If Pos('<',line) \= 0 Then
  657.                 Do
  658.                   Parse Var line pre '<Key>' rem
  659.                   Say Strip(pre) '<Key>'||rem '<BR>'
  660.                 End
  661.               Else
  662.                 Say line '<BR>'
  663.             End
  664.             Say '<IMG SRC=divbot.gif ALT="----------"><BR>'
  665.             Say '</BLOCKQUOTE><P>'
  666.           End
  667.      When Substr(Strip(line),1,5) = '+----' Then
  668.           Do
  669.             columns = Words(Translate(line,' ','-')) - 1
  670.             If columns = 1 Then 
  671.               Do
  672.                 align1 = '<CENTER>'
  673.                 align2 = '</CENTER>'
  674.               End
  675.             Else 
  676.               Do
  677.                 align1 = ''
  678.                 align2 = ''
  679.               End
  680.             Say '<CENTER><TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2>'
  681.             line = Strip(Linein(infile))
  682.             line = Strip(Strip(line,,'|'))
  683.             tmp = '<TR>'
  684.             Do i = 1 To columns
  685.                Parse Var line col '|' line
  686.                If col = '' Then col = '<BR>'
  687.                tmp = tmp'<TH>'Strip(col)'</TH>'
  688.             End
  689.             Say tmp'</TR>'
  690.             line = Linein(infile) /* remove heading underline */
  691.             col. = ''
  692.             Do Forever
  693.                line = Strip(Linein(infile))
  694.                If line = '' | Translate(line,'  ','+-') = '' Then Leave
  695.                line = Strip(Strip(line,,'|'))
  696.                If columns = 1 & line = '|' Then col.1 = col.1||'|'||'<BR>'
  697.                Else
  698.                  Do i = 1 To columns
  699.                    Parse Var line col '|' line
  700.                    col.i = col.i||Strip(col)||'<BR>'
  701.                  End
  702.             End
  703.             tmp = '<TR>'
  704.             Do i = 1 To columns
  705.                tmp = tmp'<TD>'||align1||col.i||align2||'</TD>'
  706.             End
  707.             Say tmp'</TR></TABLE></CENTER><P>'
  708.           End
  709.      When Strip(line) = '' Then Nop
  710.      When Substr(line,1,7) = Copies(' ',7) Then 
  711.           Do
  712.             Say '<DD>'Strip(line)'</DD>'
  713.           End
  714.      Otherwise
  715.           Do
  716.             tmp = Strip(line)
  717.             Do Forever
  718.                line = Strip(linein(infile))
  719.                If line = '' Then Leave
  720.                tmp = tmp line
  721.             End
  722.           tmp = handle_keywords(tmp,'')
  723.           Say tmp '<P>'
  724.           End
  725.    End
  726. End
  727. Do i = 1 To toc_idx
  728.    Call Lineout tocfile, toc.i
  729. End
  730. Call footing
  731. Return
  732.  
  733. /********************************************************************/
  734. quickref: Procedure
  735. Parse arg infile tocfile title
  736. toc. = ''
  737. toc_idx = 0
  738. table_head. = ''
  739. colval. = ''
  740. in_table = 'N'
  741. in_start = 'Y'
  742. Call heading title
  743. toc_idx = toc_idx + 1
  744. toc.toc_idx = '<DT>'MakeTOC(title,"")'</DT>'
  745. Say '<A NAME="'Translate(title)'"></A>'
  746. Do While(Lines(infile)>0)
  747.    line = Linein(infile)
  748.    If in_start = 'Y' Then
  749.      Do
  750.        line = Strip(line)
  751.        If Length(line) = 0 Then
  752.          Do
  753.            in_start = 'N'
  754.            Say '<CENTER><HR></CENTER>'
  755.            Iterate
  756.          End
  757.        Say '<CENTER><H1>' line '</H1></CENTER>'
  758.        Iterate
  759.      End
  760.    Select
  761.      When Strip(line) = Copies('-',74) Then Say '<HR>'
  762.      When Substr(Strip(line),1,1) = '-' Then
  763.           Do
  764.             line = Linein(infile)
  765.             header = Strip(line)
  766.             toc_idx = toc_idx + 1
  767.             toc.toc_idx = '<DD>'MakeTOC(header,'')'</DD>'
  768.             Say '<A NAME="'Translate(header)'"></A>'
  769.             Say '<H2>' header '</H2>'
  770.             line = Linein(infile)
  771.           End
  772.      When Substr(Strip(line),1,5) = '+----' Then
  773.           Do
  774.             columns = Words(Translate(line,' ','-')) - 1
  775.             If columns = 1 Then 
  776.               Do
  777.                 align1 = '<CENTER>'
  778.                 align2 = '</CENTER>'
  779.               End
  780.             Else 
  781.               Do
  782.                 align1 = ''
  783.                 align2 = ''
  784.               End
  785.             Say '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2>'
  786.             line = Strip(Linein(infile))
  787.             tmp = '<TR>'
  788.             Do i = 0 To columns
  789.                Parse Var line col '|' line
  790.                If col = '' Then col = '<BR>'
  791.                table_head.i = Strip(col)'<BR>'
  792.             End
  793.             Do Forever
  794.                line = Strip(Linein(infile))
  795.                If Substr(line,1,5) = '+----' Then Leave
  796.                Do i = 0 To columns
  797.                   Parse Var line col '|' line
  798.                   If col = '' Then col = '<BR>'
  799.                   table_head.i = table_head.i||Strip(col)||'<BR>'
  800.                End
  801.             End
  802.             tmp = ''
  803.             Do i = 1 To columns
  804.                tmp = tmp'<TH>'table_head.i'</TH>'
  805.             End
  806.             Say tmp'</TR>'
  807.             col. = ''
  808.             Do Forever
  809.                line = Strip(Linein(infile))
  810.                If Substr(line,1,5) = '+----' Then Leave
  811.                If line = '' | Translate(line,'  ','+-') = '' Then Leave
  812.                line = Strip(Strip(line,,'|'))
  813.                If columns = 1 & line = '|' Then col.1 = col.1||'|'||'<BR>'
  814.                Else
  815.                  Do i = 1 To columns
  816.                    Parse Var line col '|' line
  817.                    col.i = col.i||Strip(col)||'<BR>'
  818.                  End
  819.             End
  820.             tmp = '<TR>'
  821.             Do i = 1 To columns
  822.                tmp = tmp'<TD>'||align1||col.i||align2||'</TD>'
  823.             End
  824.             Say tmp'</TR></TABLE><P>'
  825.           End
  826.      When Strip(line) = '' Then Nop
  827.      When header = 'Command-line invocation' Then
  828.           Do
  829.             Select
  830.               When Word(line,1) = 'the' Then
  831.                    Do
  832.                      Say '<B>' Strip(line) '</B><P>'
  833.                    End
  834.               When Word(line,1) = 'Where:' Then
  835.                    Do
  836.                      Say '<B>' Strip(line) '</B><P>'
  837.                      Say '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2><TR>'
  838.                      ar = '<TD>'
  839.                      dr = '<TD>'
  840.                      Do Forever
  841.                         line = Linein(infile)
  842.                         If Strip(line) = '' Then Leave
  843.                         Parse Var line 1 arg 19 desc
  844.                         arg = Strip(arg)
  845.                         desc = Strip(desc)
  846.                         ar = ar arg'<BR>'
  847.                         dr = dr desc'<BR>'
  848.                      End
  849.                      Say ar'</TD>'
  850.                      Say dr'</TD>'
  851.                      Say '</TR></TABLE><P>'
  852.                    End
  853.               When Word(line,1) = 'Option' Then
  854.                    Do
  855.                      Say '<B>' Strip(line) '</B><BR>'
  856.                    End
  857.               Otherwise Nop
  858.             End
  859.           End
  860.      When header = 'Prefix commands' Then
  861.           Do 
  862.             Say '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2><TR>'
  863.             ar = '<TD>'
  864.             dr = '<TD>'
  865.             Do Forever
  866.               Parse Var line arg '-' desc
  867.               arg = Strip(arg)
  868.               desc = Strip(desc)
  869.               ar = ar arg'<BR>'
  870.               dr = dr desc'<BR>'
  871.               line = Linein(infile)
  872.               If Strip(line) = '' Then Leave
  873.             End
  874.             Say ar'</TD>'
  875.             Say dr'</TD>'
  876.             Say '</TR></TABLE><P>'
  877.           End
  878.      When header = 'Line Targets' Then
  879.           Do 
  880.             Say '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2><TR>'
  881.             ar = '<TD>'
  882.             dr = '<TD>'
  883.             Do Forever
  884.               Parse Var line arg 27 desc
  885.               arg = Strip(arg)
  886.               desc = Strip(desc)
  887.               ar = ar arg'<BR>'
  888.               dr = dr desc'<BR>'
  889.               line = Linein(infile)
  890.               If Strip(line) = '' Then Leave
  891.             End
  892.             Say ar'</TD>'
  893.             Say dr'</TD>'
  894.             Say '</TR></TABLE><P>'
  895.             Do Forever
  896.                line = Strip(Linein(infile))
  897.                If line = '' Then Leave
  898.                Say line '<BR>'
  899.             End
  900.           End
  901.      When Substr(line,2,5) = '[SET]' | Substr(line,2,3) = 'SET' Then
  902.           Do
  903.             Say '<A HREF = "commset.htm#SET' Translate(Word(line,2))'"> [SET]' Word(line,2) '</A>' Subword(line,3) '<BR>'
  904.           End
  905.      When Substr(line,2,3) = 'SOS' Then
  906.           Do
  907.             Say '<A HREF = "commsos.htm#SOS' Translate(Word(line,2))'"> SOS' Word(line,2) '</A>' Subword(line,3) '<BR>'
  908.           End
  909.      When Substr(line,2,1) \= ' ' Then
  910.           Do
  911.             Select
  912.               When Word(line,1) = '[Locate]' Then word1 = 'LOCATE'
  913.               When Substr(Word(line,1),1,1) = '?' Then word1 = SpecialTranslate('?')
  914.               When Substr(Word(line,1),1,1) = '!' Then word1 = SpecialTranslate('!')
  915.               When Substr(Word(line,1),1,1) = '=' Then word1 = SpecialTranslate('=')
  916.               When Substr(Word(line,1),1,1) = '&' Then word1 = SpecialTranslate('&')
  917.               Otherwise word1 = Translate(Word(line,1))
  918.             End
  919.             Say '<A HREF = "comm.htm#'word1'">' Word(line,1) '</A>' Subword(line,2) '<BR>'
  920.           End
  921.      When Substr(line,1,7) = Copies(' ',7) Then 
  922.           Do
  923.             Say Strip(line)'<BR>'
  924.           End
  925.      Otherwise
  926.           Do
  927.             tmp = Strip(line)
  928.             Do Forever
  929.                line = Strip(linein(infile))
  930.                If line = '' Then Leave
  931.                tmp = tmp line
  932.             End
  933.           tmp = handle_keywords(tmp,'')
  934.           Say tmp '<P>'
  935.           End
  936.    End
  937. End
  938. Do i = 1 To toc_idx
  939.    Call Lineout tocfile, toc.i
  940. End
  941. Call footing
  942. Return
  943.  
  944. /********************************************************************/
  945. toc: Procedure
  946. Parse arg action ver
  947. If action = 'START' Then 
  948.   Do
  949.     Call heading 'Table of Contents'
  950.     Say '<HR><CENTER><H1>The Hessling Editor</H1> </CENTER>'
  951.     Say '<HR><CENTER><H1>Version' ver '</H1> </CENTER><P>'
  952.     Say '<A NAME="TOC"></A>'
  953.     Say '<HR><CENTER><H2>TABLE OF CONTENTS</H2> </CENTER><HR><DL>'
  954.   End
  955. Else
  956.   Do
  957.     Say '</DL><HR>'
  958.     Call footing 'TOC'
  959.   End
  960. Return
  961.  
  962. /********************************************************************/
  963. Bold: Procedure
  964. Parse Arg line
  965. Return '<B>'line'</B>'
  966.  
  967. /********************************************************************/
  968. Italic: Procedure
  969. Parse Arg line
  970. Return '<I>'line'</I>'
  971.  
  972. /********************************************************************/
  973. MakeTOC: Procedure Expose infile
  974. Parse Arg keyword,desc
  975. Parse Var infile base '.' .
  976. name = SpecialTranslate(keyword)
  977. Return '<A HREF = "'base'.htm#'name'">' keyword '</A>' desc '<BR>'
  978.  
  979. /********************************************************************/
  980. MakeRef: Procedure
  981. Parse Arg trans,extra,keyword
  982. Select
  983.   When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'SET' Then filename = 'commset.htm'
  984.   When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'SOS' Then filename = 'commsos.htm'
  985.   When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'QUERY,' Then filename = 'query.htm'
  986.   When keyword \= Translate(keyword) Then filename = 'glossary.htm'
  987.   Otherwise 
  988.        Do
  989.          if keyword = 'REXX' Then filename = 'glossary.htm'
  990.          else filename = 'comm.htm'
  991.        End
  992. End
  993. If trans = 'UPPER' Then name = Strip(SpecialTranslate(keyword),,"'")
  994. Else name = Strip(keyword,,"'")
  995. Return '<A HREF = "'filename'#'name'">'||keyword||'</A>'extra
  996.  
  997. /********************************************************************/
  998. heading: Procedure
  999. Parse Arg title
  1000. Say '<HTML>'
  1001. Say '<HEAD><TITLE>THE Reference -' title '</TITLE></HEAD>'
  1002. Say '<BODY BGCOLOR="#F1EDD1" LINK = "#0000FF" VLINK = "#FF0022" ALINK = "#808000">'
  1003. Say '<CENTER> <img WIDTH="64" HEIGHT="64" HSPACE="20" SRC="the64.gif" ALT="THE"> </CENTER>'
  1004. Return
  1005.  
  1006. /********************************************************************/
  1007. footing: Procedure
  1008. Parse Arg src .
  1009. Say '<ADDRESS>'
  1010. Say 'The Hessling Editor is Copyright © <A HREF = "http://www.lightlink.com/hessling/">Mark Hessling</A>, 1990-1997'
  1011. Say '<<A HREF = "mailto:M.Hessling@qut.edu.au">M.Hessling@qut.edu.au</A>>'
  1012. Say '<BR>Generated on:' Date()
  1013. Say '</ADDRESS><HR>'
  1014. If src \= 'TOC' Then Say 'Return to <A HREF = "index.htm#TOC"> Table of Contents </A><BR>'
  1015. Say '</BODY> </HTML>'
  1016. Return
  1017.  
  1018. /********************************************************************/
  1019. handle_keywords: Procedure
  1020. Parse Arg line,syntax_words
  1021. tmp = ''
  1022. Do Forever    /* handle links */
  1023.    Parse Var line pre '<' keyword '>' line
  1024.    Select
  1025.      When keyword = '' Then tmp = tmp pre
  1026.      Otherwise tmp = tmp Strip(pre) MakeRef('UPPER',,keyword)
  1027.    End
  1028.    If line = '' Then Leave
  1029. End
  1030. line = tmp
  1031. tmp = ''
  1032. Do Forever              /* handle arguments */
  1033.    Parse Var line pre "'" keyword "'" line
  1034.    Select
  1035.      When keyword = '' Then tmp = tmp pre
  1036.      Otherwise 
  1037.        Do
  1038.          If Words(syntax_words) \= 0 & Wordpos(Translate(keyword),Translate(syntax_words)) = 0 Then
  1039.             tmp = tmp pre "'"keyword"'"
  1040.          Else
  1041.             Do
  1042.               If pre = '' Then
  1043.                  tmp = tmp pre Italic(keyword)
  1044.               Else
  1045.                  Do
  1046.                    strip_pre = Strip(pre)
  1047.                    If Substr(strip_pre,Length(strip_pre)) = "#" Then
  1048.                       tmp = tmp pre || keyword
  1049.                    Else
  1050.                       tmp = tmp pre Italic(keyword)
  1051.                  End
  1052.             End
  1053.        End
  1054.    End
  1055.    If line = '' Then Leave
  1056. End
  1057. Return tmp
  1058.  
  1059. /********************************************************************/
  1060. SpecialTranslate: Procedure
  1061. Parse Arg keyword
  1062. Select
  1063.   When keyword = '?' Then Return('QUESTIONMARK')
  1064.   When keyword = '=' Then Return('EQUALSIGN')
  1065.   When keyword = '!' Then Return('EXCLAIMARK')
  1066.   When keyword = '&' Then Return('AMPERSAND')
  1067.   Otherwise Return Translate(keyword)
  1068. End
  1069. Return 'WRONG!!'
  1070.