/* * This script converts the output from manext to HTML * * Arguments: * section: one of OVERVIEW,COMMANDS,APPENDIX,GLOSSARY * infile: file name of .man file * tocfile: file name of Table of Contents output file */ Trace o Parse Arg html_ext ver section infile tocfile . Select When section = 'TOCSTART' Then Call toc 'START' ver When section = 'TOCEND' Then Call toc 'END' ver When section = 'OVERVIEW' Then Call overview infile tocfile 'Overview' When section = 'COMM' Then Call commands infile tocfile 'Commands' When section = 'COMMSET' Then Call commands infile tocfile 'SET Commands' When section = 'COMMSOS' Then Call commands infile tocfile 'SOS Commands' When section = 'QUERY' Then Call query infile tocfile 'Query and Extract' When section = 'GLOSSARY' Then Call glossary infile tocfile 'Glossary' When section = 'APPENDIX1' Then Call appendix1 infile tocfile 'Appendix 1' When section = 'APPENDIX2' Then Call appendix2 infile tocfile 'Appendix 2' When section = 'APPENDIX3' Then Call appendix2 infile tocfile 'Appendix 3' When section = 'APPENDIX4' Then Call appendix2 infile tocfile 'Appendix 4' When section = 'APPENDIX5' Then Call appendixx infile tocfile 'Appendix 5' When section = 'APPENDIX6' Then Call appendixx infile tocfile 'Appendix 6' When section = 'APPENDIX7' Then Call appendix2 infile tocfile 'Appendix 7' When section = 'HISTORY' Then Call history infile tocfile 'History of THE' When section = 'QUICKREF' Then Call quickref infile tocfile 'Quick Reference for THE' When section = 'FDL' Then Call fdl infile tocfile 'GNU Free Documentation License' Otherwise Do Say 'Error: Invalid section:' section 'specified' End End Return /********************************************************************/ overview: Procedure Expose html_ext Parse arg infile tocfile title toc. = '' toc_idx = 0 in_code_section = 'N' already_read = 'N' in_list_section = 'N' in_sublist_section = 'N' first_heading = 'N' Call heading title Do While(Lines(infile)>0) If already_read = 'N' Then line = Linein(infile) already_read = 'N' Select When Strip(line) = Copies('=',72) Then Do line = Strip(Linein(infile)) toc_idx = toc_idx + 1 toc.toc_idx = '
'MakeTOC(line,"")'
' Say '
' Say '' Say '

' line '

' line = Linein(infile) Say '
' first_heading = 'Y' End When Strip(line) = Copies('-',74) Then Iterate When Substr(Strip(line),1,2) = '- 'Then Do tmp = '' If in_list_section = 'Y' Then Do tmp = Substr(Strip(line),3) Do Forever line = Linein(infile) Select When Strip(line) = '' Then Do Say '
  • ' handle_keywords(tmp,'') '
  • ' Say '' in_list_section = 'N' End When Substr(Strip(line),1,2) = '- ' Then Do Say '
  • ' handle_keywords(tmp,'') '
  • ' already_read = 'Y' End When Substr(Strip(line),1,2) = 'o ' Then Do If in_sublist_section = 'N' Then tmp = tmp '<(DL)>' in_sublist_section = 'Y' tmp = tmp '<(DD)>'Subword(line,2) End Otherwise Do If in_sublist_section = 'Y' Then Do tmp = tmp '<(/DL)><(BR)>'line in_sublist_section = 'N' End Else tmp = tmp line End End If in_list_section = 'N' | already_read = 'Y' Then Leave End End Else Do Say '' End Parse Var line v ver dt tail head = v ver toc_idx = toc_idx + 1 toc.toc_idx = '
    'MakeTOC(Strip(head),dt tail)'
    ' Say '' Say '
    ' Say '

    ' line '

    ' Say '
    ' ul = '' End When Substr(line,1,4) = " ---" Then Do If inlist Then Do If ul \= '' Then Say ul inlist = 0 Say '' End Say '

    '||Substr(line,5)||'


    ' Call footing Return /********************************************************************/ appendix1: Procedure Expose html_ext Parse arg infile tocfile title toc. = '' toc_idx = 0 in_env = 'N' Call heading title Do While(Lines(infile)>0) line = Linein(infile) Select When Strip(line) = Copies('=',72) Then Do line = Strip(Linein(infile)) Parse Var line head '-' tail toc_idx = toc_idx + 1 toc.toc_idx = '
    'MakeTOC(Strip(head),tail)'
    ' Say '' Say '

    ' line '

    ' Say '
    ' line = Linein(infile) End When Strip(line) = Copies('-',74) Then Say '
    ' When Strip(line) = Copies('*',9) Then Say '
    'line'
    ' When Substr(Strip(line),1,15) = Copies('-',15) Then Do line = Strip(Linein(infile)) Say '
    ' Say '

    '||line||'

    ' line = Linein(infile) Say '
    ' End When Substr(line,1,10) = ' THE_' Then Do Parse Var line env '-' rem If in_env = 'N' Then Say '
    ' in_env = 'Y' rem = handle_keywords(rem,'') Say '
    'env'
    ' Say '
    ' rem '

    ' End When Strip(line) = '' & in_env = 'Y' Then Do Say '
    ' in_env = 'N' End When Strip(line) = '' Then Nop Otherwise Do tmp = Strip(line) Do Forever line = Strip(Linein(infile)) If line = '' Then Leave tmp = tmp line End tmp = handle_keywords(tmp,'') Say tmp '

    ' End End End Do i = 1 To toc_idx Call Lineout tocfile, toc.i End Call footing Return /********************************************************************/ appendix2: Procedure Expose html_ext section Parse arg infile tocfile title toc. = '' toc_idx = 0 before_table = 1 Call heading title Do While(Lines(infile)>0) line = Linein(infile) Select When Strip(line) = Copies('=',72) Then Do line = Strip(Linein(infile)) Parse Var line head '-' tail toc_idx = toc_idx + 1 toc.toc_idx = '

    'MakeTOC(Strip(head),tail)'
    ' Say '' Say '

    ' line '

    ' Say '
    ' line = Linein(infile) End When Strip(line) = Copies('-',74) Then Say '
    ' When Substr(Strip(line),1,2) = '--' & section = 'APPENDIX4' Then Do line = Linein(infile) Say '

    ' Strip(line) '

    ' line = Linein(infile) End When Substr(Strip(line),1,2) = '..' & section = 'APPENDIX4' Then Do line = Linein(infile) Say '

    ' Strip(line) '

    ' line = Linein(infile) End When Substr(Strip(line),1,1) = '-' Then Do line = Linein(infile) Say '' Strip(line) '

    ' line = Linein(infile) End When Substr(Strip(line),1,2) = '==' Then Do line = Linein(infile) Say '

    ' Strip(line) '

    ' line = Linein(infile) End When Substr(Strip(line),1,5) = '+----' & Length(Strip(line)) = 31 Then Do Say '
    ' Do Forever line = Strip(Linein(infile)) If Substr(line,1,5) = '+----' Then Leave If Pos('<',line) \= 0 Then Do Parse Var line pre '' rem Say Strip(pre) '<Key>'||rem '
    ' End Else Say line '
    ' End Say '

    ' End When Substr(Strip(line),1,5) = '+----' Then Do before_table = 0 columns = Words(Translate(line,' ','-')) - 1 If columns = 1 Then Do align1 = '

    ' align2 = '
    ' End Else Do align1 = '' align2 = '' End Say '
    ' line = Strip(Linein(infile)) line = Strip(Strip(line,,'|')) tmp = '' Do i = 1 To columns Parse Var line col '|' line If col = '' Then col = '
    ' tmp = tmp'' End Say tmp'' line = Linein(infile) /* remove heading underline */ col. = '' Do Forever line = Strip(Linein(infile)) If line = '' Then Leave If Translate(line,' ','+-') = '' Then Do /* write out the row */ tmp = '' Do i = 1 To columns tmp = tmp'' End Say tmp'' col. = '' Iterate End line = Strip(Strip(line,,'|')) If columns = 1 & line = '|' Then col.1 = col.1||'|'||'
    ' Else Do i = 1 To columns Parse Var line col '|' line col.i = col.i||Strip(col)||'
    ' End End /* write out the row */ tmp = '' Do i = 1 To columns tmp = tmp'' End Say tmp'
    'Strip(col)'
    '||align1||col.i||align2||'
    '||align1||col.i||align2||'

    ' End When Strip(line) = '' Then Nop When Substr(line,1,7) = Copies(' ',7) Then Do Say '

    'Strip(line)'
    ' End Otherwise Do tmp = Strip(line) Do Forever line = linein(infile) If Strip(line) = '' Then Leave Select When section = 'APPENDIX4' Then Do Select When Substr(Strip(line),1,7) = 'Syntax:' | Substr(Strip(line),1,19) = 'Meaning of options:' | Substr(Strip(line),1,17) = "ECOLOR Character:" Then Do If tmp \= '' Then Do tmp = handle_keywords(tmp,'') Say tmp '
    ' End Say ''Strip(line)'
    ' tmp = '' End When Substr(line,1,8) = Copies(' ',8) & Substr(line,9,1) \= ' ' Then Do If tmp \= '' Then Do tmp = handle_keywords(tmp,'') Say tmp '
    ' End Say ''Strip(line)'
    ' tmp = '' End Otherwise tmp = tmp Strip(line) End End When section = 'APPENDIX7' & Pos(Right( Strip( line ), 1 ), ':;.' ) \= 0 Then Do If before_table Then Say handle_keywords( tmp Strip( line ) )'
    ' Else Say tmp Strip( line )'
    ' tmp = '' End Otherwise tmp = tmp Strip(line) End End tmp = handle_keywords(tmp,'') Say tmp '

    ' End End End Do i = 1 To toc_idx Call Lineout tocfile, toc.i End Call footing Return /********************************************************************/ appendixx: Procedure Expose html_ext section Parse arg infile tocfile title If section = 'APPENDIX5' Then head = 'DEFAULT STATUS SETTINGS IN THE' Else head = 'THE BY TASKS' Do While Lines(infile) > 0 line = Linein(infile) pos = Pos('.htm',line) If pos \= 0 & html_ext \= '.htm' Then Do Parse Var line start '.htm' end line = start || html_ext || end End Say line End If section = 'APPENDIX5' Then infile = 'app5.man' Else infile = 'app6.man' Call Lineout tocfile, '

    'MakeTOC(Translate(title),head)'
    ' Return /********************************************************************/ quickref: Procedure Expose html_ext Parse arg infile tocfile title toc. = '' toc_idx = 0 table_head. = '' colval. = '' in_table = 'N' in_start = 'Y' Call heading title toc_idx = toc_idx + 1 toc.toc_idx = '
    'MakeTOC(title,"")'
    ' Say '' Call Charout ,'

    ' Do While(Lines(infile)>0) line = Linein(infile) If in_start = 'Y' Then Do line = Strip(line) If Length(line) = 0 Then Do in_start = 'N' Say '

    ' Say '

    ' Iterate End /* Say '

    ' line '

    ' */ Say line'
    ' Iterate End Select When Strip(line) = Copies('-',74) Then Say '
    ' When Substr(Strip(line),1,1) = '-' Then Do line = Linein(infile) header = Strip(line) toc_idx = toc_idx + 1 toc.toc_idx = '
    'MakeTOC(header,'')'
    ' Say '' Say '

    ' header '

    ' line = Linein(infile) End When Substr(Strip(line),1,5) = '+----' Then Do columns = Words(Translate(line,' ','-')) - 1 If columns = 1 Then Do align1 = '
    ' align2 = '
    ' End Else Do align1 = '' align2 = '' End Say '' line = Strip(Linein(infile)) tmp = '' Do i = 0 To columns Parse Var line col '|' line If col = '' Then col = '
    ' table_head.i = Strip(col)'
    ' End Do Forever line = Strip(Linein(infile)) If Substr(line,1,5) = '+----' Then Leave Do i = 0 To columns Parse Var line col '|' line If col = '' Then col = '
    ' table_head.i = table_head.i||Strip(col)||'
    ' End End tmp = '' Do i = 1 To columns tmp = tmp'' End Say tmp'' col. = '' Do Forever line = Strip(Linein(infile)) If Substr(line,1,5) = '+----' Then Leave If line = '' | Translate(line,' ','+-') = '' Then Leave line = Strip(Strip(line,,'|')) If columns = 1 & line = '|' Then col.1 = col.1||'|'||'
    ' Else Do i = 1 To columns Parse Var line col '|' line col.i = col.i||Strip(col)||'
    ' End End tmp = '' Do i = 1 To columns tmp = tmp'' End Say tmp'
    'table_head.i'
    '||align1||col.i||align2||'

    ' End When Strip(line) = '' Then Nop When header = 'Command-line invocation' Then Do Select When Word(line,1) = 'the' Then Do Say '' Strip(line) '

    ' End When Word(line,1) = 'Where:' Then Do Say '' Strip(line) '

    ' Say '' ar = '' Say dr'' Say '
    ' dr = '' Do Forever line = Linein(infile) If Strip(line) = '' Then Leave Parse Var line 1 arg 19 desc arg = Strip(arg) desc = Strip(desc) ar = ar arg'
    ' dr = dr desc'
    ' End Say ar'

    ' End When Word(line,1) = 'Option' Then Do Say '' Strip(line) '
    ' End Otherwise Nop End End When header = 'Prefix commands' Then Do Say '' ar = '' Say dr'' Say '
    ' dr = '' Do Forever Parse Var line arg '-' desc arg = Strip(arg) desc = Strip(desc) ar = ar arg'
    ' dr = dr desc'
    ' line = Linein(infile) If Strip(line) = '' Then Leave End Say ar'

    ' End When header = 'Line Targets' Then Do Say '' ar = '' Say dr'' Say '
    ' dr = '' Do Forever Parse Var line arg 27 desc arg = Strip(arg) desc = Strip(desc) ar = ar arg'
    ' dr = dr desc'
    ' line = Linein(infile) If Strip(line) = '' Then Leave End Say ar'

    ' Do Forever line = Strip(Linein(infile)) If line = '' Then Leave Say line '
    ' End End When Substr(line,2,5) = '[SET]' | Substr(line,2,3) = 'SET' Then Do If Translate(Word(line,2)) = 'SET_COMMAND' Then Say ' SET' Word(line,2) '' Subword(line,3) '
    ' Else Say ' [SET]' Word(line,2) '' Subword(line,3) '
    ' End When Substr(line,2,3) = 'SOS' Then Do If Translate(Word(line,2)) = 'SOS_COMMAND' Then Say ' SOS' Word(line,2) '' Subword(line,3) '
    ' Else Say ' SOS' Word(line,2) '' Subword(line,3) '
    ' End When Substr(line,2,1) \= ' ' Then Do Select When Word(line,1) = '[Locate]' Then word1 = 'LOCATE' When Substr(Word(line,1),1,1) = '?' Then word1 = SpecialTranslate('?') When Substr(Word(line,1),1,1) = '!' Then word1 = SpecialTranslate('!') When Substr(Word(line,1),1,1) = '=' Then word1 = SpecialTranslate('=') When Substr(Word(line,1),1,1) = '&' Then word1 = SpecialTranslate('&') Otherwise word1 = Translate(Word(line,1)) End Say '' Word(line,1) '' Subword(line,2) '
    ' End When Substr(line,1,7) = Copies(' ',7) Then Do Say Strip(line)'
    ' End Otherwise Do tmp = Strip(line) Do Forever line = Strip(linein(infile)) If line = '' Then Leave tmp = tmp line End tmp = handle_keywords(tmp,'') Say tmp '

    ' End End End Do i = 1 To toc_idx Call Lineout tocfile, toc.i End Call footing Return /********************************************************************/ fdl: Procedure Expose html_ext section Parse arg infile tocfile title Call heading thisfile,,title Do While(Lines(infile)>0) Say Linein(infile) End infile = 'fdl.man' Call Lineout tocfile, '

    'MakeTOC(Translate(title),"")'
    ' Return /********************************************************************/ toc: Procedure Expose html_ext Parse arg action ver If action = 'START' Then Do Call heading 'Table of Contents' Say '

    The Hessling Editor
    ' Say 'Version' ver '

    ' Say '' Say '


    TABLE OF CONTENTS

    ' End Else Do Say '

    ' Call footing 'TOC' End Return /********************************************************************/ Bold: Procedure Expose html_ext Parse Arg line Return ''line'' /********************************************************************/ Italic: Procedure Expose html_ext Parse Arg line Return ''line'' /********************************************************************/ MakeTOC: Procedure Expose infile html_ext Parse Arg keyword,desc Parse Var infile base '.' . last_slash = Lastpos( '/', base ) If last_slash \= 0 Then base = Substr( base, last_slash+1 ) name = RemoveSpaces(SpecialTranslate(keyword)) Return '' keyword '' desc '
    ' /********************************************************************/ MakeRef: Procedure Expose html_ext Parse Arg trans,extra,keyword Select When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'SET' Then filename = 'commset' || html_ext When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'SOS' Then filename = 'commsos' || html_ext When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'QUERY,' Then filename = 'query' || html_ext When keyword \= Translate(keyword) Then filename = 'glossary' || html_ext Otherwise Do If keyword = 'REXX' | keyword = 'Rexx' Then filename = 'glossary' || html_ext else filename = 'comm' || html_ext End End If trans = 'UPPER' Then name = Strip(SpecialTranslate(keyword),,"'") Else name = Strip(keyword,,"'") name = RemoveSpaces(name) Return ''||keyword||''extra /********************************************************************/ heading: Procedure Expose html_ext Parse Arg title Say '' Say 'THE Reference -' title '' Say '' Say '
    THE
    ' Return /********************************************************************/ footing: Procedure Expose html_ext Parse Arg src . Say '
    ' Say 'The Hessling Editor is Copyright © Mark Hessling, 1990-'Left( Date('S'), 4 ) Say '<mark@rexx.org>' Say '
    Generated on:' Date() Say '

    ' If src \= 'TOC' Then Say 'Return to Table of Contents
    ' Say ' ' Return /********************************************************************/ handle_keywords: Procedure Expose html_ext Parse Arg line,syntax_words tmp = '' Do Forever /* handle links */ Parse Var line pre '<' keyword '>' line Select When Left(keyword,1) = '(' & Right(keyword,1) = ')' Then Do tmp = tmp pre '<'Strip(Strip(keyword,'L','('),'T',')')'>' End When keyword = '' Then tmp = tmp pre When Left( keyword, 5 ) = 'http:' Then Do tmp = tmp pre ''keyword'' End Otherwise tmp = tmp Strip(pre) MakeRef('UPPER',,keyword) End If line = '' Then Leave End line = tmp tmp = '' Do Forever /* handle arguments */ Parse Var line pre "'" keyword "'" line Select When keyword = '' Then tmp = tmp pre Otherwise Do If Words(syntax_words) \= 0 & Wordpos(Translate(keyword),Translate(syntax_words)) = 0 Then tmp = tmp pre "'"keyword"'" Else Do If pre = '' Then tmp = tmp pre Italic(keyword) Else Do strip_pre = Strip(pre) If Substr(strip_pre,Length(strip_pre)) = "#" Then tmp = tmp pre || keyword Else tmp = tmp pre Italic(keyword) End End End End If line = '' Then Leave End Return tmp /********************************************************************/ SpecialTranslate: Procedure Parse Arg keyword Select When keyword = '?' Then Return('QUESTIONMARK') When keyword = '=' Then Return('EQUALSIGN') When keyword = '!' Then Return('EXCLAIMARK') When keyword = '&' Then Return('AMPERSAND') Otherwise Return Translate(keyword) End Return 'WRONG!!' /********************************************************************/ RemoveSpaces: Procedure Parse Arg val retval = '' Do i = 1 To Words(val) retval = retval || Word(val,i) End Return retval /********************************************************************/ ConvertSpecialChars: Procedure Parse Arg val newval = '' intag = 0 Do i = 1 To Length(val) char = Substr(val,i,1) Select When Substr(val,i,2) = '