/* * 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 = '
' in_code_section = 'Y' End End Otherwise Do If first_heading = 'N' Then Iterate If in_code_section = 'Y' Then Do Say Strip(line) ' |
' End When Strip(line) = '' Then Nop When Strip(line) = Copies('-',74) Then Do Say '' Say '
| '||Strip(col1)||' | - | '||handle_keywords(Strip(col2),'')||' |
' Say Strip(line)' |
'
inblock = 0
Do Forever
line = Linein(infile)
If line = " +---------------" Then Leave
Say line
End
Say '' ul = '' End Otherwise Do ul = ul Strip(line) End End End Do i = 1 To toc_idx Call Lineout tocfile, toc.i End If ul \= '' Then Say '
' 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 = '
' line = Linein(infile) End When Substr(Strip(line),1,2) = '..' & section = 'APPENDIX4' Then Do line = Linein(infile) Say '
' 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 '
' 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 ' |
' End When Substr(Strip(line),1,5) = '+----' Then Do before_table = 0 columns = Words(Translate(line,' ','-')) - 1 If columns = 1 Then Do align1 = '
| 'Strip(col)' | ' End Say tmp'
|---|
| '||align1||col.i||align2||' | ' End Say tmp'
| '||align1||col.i||align2||' | ' End Say tmp'
' End When Strip(line) = '' Then Nop When Substr(line,1,7) = Copies(' ',7) Then Do Say '
' 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, '
| 'table_head.i' | ' End Say tmp'
|---|
| '||align1||col.i||align2||' | ' End Say tmp'
' 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 '
| ' 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' | '
Say dr''
Say '
'
End
When Word(line,1) = 'Option' Then
Do
Say '' Strip(line) '
'
End
Otherwise Nop
End
End
When header = 'Prefix commands' Then
Do
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' | '
Say dr''
Say '
' End When header = 'Line Targets' Then Do 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' | '
Say dr''
Say '
'
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, '