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 */
9Trace o
10Parse Arg html_ext ver section infile tocfile dest .
11Parse Version ?port .
12Parse Source ?os .
13If ?os = 'OS/2' Then ?slash = '\'
14Else ?slash = '/'
15Select
16  When section = 'TOCSTART'  Then Call toc 'START' ver infile tocfile
17  When section = 'TOCEND'    Then Call toc 'END' ver infile tocfile
18  When section = 'OVERVIEW'  Then Call overview  infile tocfile 'Overview'
19  When section = 'COMM'      Then Call commands  'comm' infile tocfile 'Commands'
20  When section = 'COMMSET'   Then Call commands  'commset' infile tocfile 'SET Commands'
21  When section = 'COMMSOS'   Then Call commands  'commsos' infile tocfile 'SOS Commands'
22  When section = 'QUERY'     Then Call query     infile tocfile 'Query and Extract'
23  When section = 'GLOSSARY'  Then Call glossary  infile tocfile 'Glossary'
24  When section = 'APPENDIX1' Then Call appendix1 infile tocfile 'Appendix 1'
25  When section = 'APPENDIX2' Then Call appendix2 'app2' infile tocfile 'Appendix 2'
26  When section = 'APPENDIX3' Then Call appendix2 'app3' infile tocfile 'Appendix 3'
27  When section = 'APPENDIX4' Then Call appendix2 'app4' infile tocfile 'Appendix 4'
28  When section = 'APPENDIX5' Then Call appendixx infile tocfile 'Appendix 5'
29  When section = 'APPENDIX6' Then Call appendixx infile tocfile 'Appendix 6'
30  When section = 'APPENDIX7' Then Call appendix2 'app7' infile tocfile 'Appendix 7'
31  When section = 'HISTORY'   Then Call history   infile tocfile 'History of THE'
32  When section = 'QUICKREF'  Then Call quickref  infile tocfile 'Quick Reference for THE'
33  When section = 'FDL'       Then Call fdl       infile tocfile 'GNU Free Documentation License'
34  Otherwise
35      Do
36        Say 'Error: Invalid section:' section 'specified'
37      End
38End
39Return
40
41/********************************************************************/
42overview: Procedure Expose html_ext ?port ?slash ?os dest
43Parse arg infile tocfile title
44toc. = ''
45toc_idx = 0
46in_code_section = 'N'
47already_read = 'N'
48in_list_section = 'N'
49first_heading = 'N'
50If ?os = 'OS/2' Then
51   Do
52      here = Directory()
53      If Directory(dest||?slash'misc') = '' Then Address Command 'mkdir' dest||?slash'misc'
54      Call Directory here
55   End
56Else
57   Do
58      If Stream(dest||?slash'misc','C','QUERY EXISTS') = '' Then Address System 'mkdir -p' dest||?slash'misc'
59   End
60thisfile = dest||?slash'misc'?slash'overview' || html_ext
61Call heading thisfile,,title
62Do While(Lines(infile)>0)
63   If already_read = 'N' Then line = Linein(infile)
64   already_read = 'N'
65   Select
66     When Strip(line) = Copies('=',72) Then
67          Do
68            line = Strip(Linein(infile))
69            Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,line,"")'</DT>'
70            Call Lineout thisfile, '<HR>'
71            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(line) || '"></A>'
72            Call Lineout thisfile, '<H2>' line '</H2>'
73            line = Linein(infile)
74            Call Lineout thisfile, '<HR>'
75            first_heading = 'Y'
76          End
77     When Strip(line) = Copies('-',74) Then Iterate
78     When Substr(Strip(line),1,2) = '- ' Then
79          Do
80            tmp = ''
81            If in_list_section = 'Y' Then
82              Do
83                tmp = Substr(Strip(line),3)
84                Do Forever
85                   line = Linein(infile)
86                   Select
87                     When Strip(line) = '' Then
88                          Do
89                            Call Lineout thisfile, '<LI>' handle_keywords(tmp,'') '</LI>'
90                            Call Lineout thisfile, '</UL>'
91                            in_list_section = 'N'
92                          End
93                     When Substr(Strip(line),1,2) = '- ' Then
94                          Do
95                            Call Lineout thisfile, '<LI>' handle_keywords(tmp,'') '</LI>'
96                            already_read = 'Y'
97                          End
98                     Otherwise
99                          Do
100                            tmp = tmp line
101                          End
102                   End
103                   If in_list_section = 'N' | already_read = 'Y' Then Leave
104                End
105              End
106            Else
107              Do
108                Call Lineout thisfile, '<UL>'
109                in_list_section = 'Y'
110                already_read = 'Y'
111              End
112          End
113     When Strip(line) = '+'||Copies('-',30) Then
114          Do
115            If in_code_section = 'Y' Then
116               Do
117                 Call Lineout thisfile, '<IMG SRC="../images/divbot.png" ALT="----------"><BR>'
118                 Call Lineout thisfile, '</BLOCKQUOTE><P>'
119                 in_code_section = 'N'
120               End
121            Else
122               Do
123                 Call Lineout thisfile, '<BLOCKQUOTE>'
124                 Call Lineout thisfile, '<IMG SRC="../images/divtop.png" ALT="----------"><BR>'
125                 in_code_section = 'Y'
126               End
127          End
128      Otherwise
129          Do
130            If first_heading = 'N' Then Iterate
131            If in_code_section = 'Y' Then
132               Do
133                 Call Lineout thisfile, Strip(line) '<BR>'
134               End
135            Else
136               Do
137                 tmp = ''
138                 If Strip(line) = '' Then Iterate
139                 Do Forever
140                    tmp = tmp line
141                    line = Linein(infile)
142                    If Strip(line) = '' Then
143                      Do
144                        tmp = handle_keywords(tmp,"")
145                        Call Lineout thisfile, tmp '<P>'
146                        Leave
147                      End
148                 End
149               End
150          End
151   End
152End
153Do i = 1 To toc_idx
154   Call Lineout tocfile, toc.i
155End
156Call Lineout thisfile, '<P Align="Center"><HR>'
157Call Lineout thisfile, 'The HTML version of this manual was inspired by <A HREF = "mailto:judygs@uic.edu">Judith Grobe Sachs </A>'
158Call Lineout thisfile, '<P Align="Center"><HR>'
159Call footing thisfile
160Return
161
162/********************************************************************/
163commands: Procedure Expose html_ext ?port ?slash ?os dest
164Parse arg fn infile tocfile title
165toc. = ''
166toc_idx = 0
167already_read_line = 'N'
168once = 'Y'
169fn = dest||?slash||fn
170If ?os = 'OS/2' Then
171   Do
172      here = Directory()
173      If Directory( fn ) = '' Then Address Command 'mkdir' fn
174      Call Directory here
175   End
176Else
177   Do
178      If Stream(fn, 'C', 'QUERY EXISTS') = '' Then Address System 'mkdir -p' fn
179   End
180thisfile = ''
181Do While(Lines(infile)>0)
182   If already_read_line = 'N' Then line = Linein(infile)
183   already_read_line = 'N'
184   Select
185     When Strip(line) = Copies('=',72) Then
186          Do
187            line = Strip(Linein(infile))
188/*            Say '<DT>'MakeTOC('#','../' || fn || '/index' || html_ext,line,"")'</DT>' */
189            Call Lineout tocfile,'<B>'Translate(title)'</B>'
190            line = Linein(infile)
191          End
192     When Strip(line) = Copies('-',74) & thisfile \= '' Then
193          Call Lineout thisfile, '<HR>'
194     When line = '     COMMAND' Then
195          Do
196            line = Linein(infile)
197            Parse var line keyword '-' desc
198            keyword = Strip(keyword)
199            keyword_words = Words(keyword)
200            If thisfile \= '' Then Call footing thisfile
201            thisfile = fn || ?slash || RemoveSpaces(SpecialTranslate(keyword)) || '.html'
202            If ?port = 'REXXSAA' & ?os = 'OS/2' Then
203               Do
204                  Call Stream thisfile, 'C', 'OPEN WRITE'
205                  Call Stream thisfile, 'C', 'CLOSE'
206               End
207            Else
208               Call Stream thisfile, 'C', 'OPEN WRITE REPLACE'
209            Call heading thisfile,,title '-' keyword
210            Call Lineout thisfile, '<HR>'
211            Call Lineout thisfile, '<DL><DT>'
212            Call Lineout thisfile, Bold(Translate(keyword)) '-' desc '<BR><BR></DT>'
213            toc_idx = toc_idx + 1
214            toc.toc_idx = '<DD>'MakeTOC('/',thisfile,keyword,desc)'</DD>'
215          End
216     When line = '     SEE ALSO' Then
217          Do
218            Call Lineout thisfile, '<DT>' Bold('See Also:') '<BR></DT>'
219            line = Linein(infile)
220            tmp = ''
221            Do Forever
222               Parse Var line '<' keyword '>' line
223               If keyword = '' Then Leave
224               tmp = tmp MakeRef('UPPER',',',keyword)
225               If line = '' Then Leave
226            End
227            tmp = Strip(tmp,'T',',')
228            Call Lineout thisfile, '<DD>' tmp '<P></DD>'
229          End
230     When line = '     STATUS' Then
231          Do
232            Call Lineout thisfile, '<DT>' Bold('Status:') '<BR></DT>'
233            Do Forever
234               line = Linein(infile)
235               If line = '' Then Leave
236               Call Lineout thisfile, '<DD>' Strip(line) '</DD>'
237            End
238            Call Lineout thisfile, '</DL><P>'
239          End
240     When line = '     SYNTAX' Then
241          Do
242            Call Lineout thisfile, '<DT>' Bold('Syntax:') '<BR></DT>'
243            syntax_words = ''
244            Do Forever
245               line = Linein(infile)
246               If line = '' Then Leave
247               pre = Subword(line,1,keyword_words)
248               post = Subword(line,keyword_words+1)
249               Call Lineout thisfile, '<DD>' Strip(pre) Italic(strip(post)) '<P></DD>'
250               syntax_words = syntax_words Translate(post,"     ","/|[].")
251            End
252          End
253     When line = '     COMPATIBILITY' Then
254          Do
255            Call Lineout thisfile, '<DT>' Bold('Compatibility:') '<BR></DT>'
256            first = 'Y'
257            Do Forever
258               line = Linein(infile)
259               If line = '' Then Leave
260               If first = 'Y' Then
261                 Do
262                   Call Lineout thisfile, '<DD>' handle_keywords(Strip(line),'')
263                   first = 'N'
264                 End
265               Else
266                   Call Lineout thisfile, '</DD><DD>' handle_keywords(Strip(line),'')
267            End
268            Call Lineout thisfile, '<P></DD>'
269          End
270     When line = '     DEFAULT' Then
271          Do
272            Call Lineout thisfile, '<DT>' Bold('Default:') '<BR></DT>'
273            Do Forever
274               line = Linein(infile)
275               If line = '' Then Leave
276               Parse Var line pre '<' keyword '>' post
277               If keyword \= '' Then line = pre MakeRef('UPPER',,keyword) post
278               Call Lineout thisfile, '<DD>' Strip(line) '<P></DD>'
279            End
280          End
281     When line = '     DESCRIPTION' Then
282          Do
283            Call Lineout thisfile, '<DT>' Bold('Description:') '<BR></DT>'
284            tmp = ''
285            inblock = 0
286            Do Forever
287               line = Linein(infile)
288               If Substr(Strip(line),1,31) = '+'||Copies('-',30) Then
289                 Do
290                   Call Lineout thisfile, '<BLOCKQUOTE>'
291                   Call Lineout thisfile, '<IMG SRC="../images/divtop.png" ALT="----------"><BR>'
292                   Do Forever
293                     line = Linein(infile)
294                     If Substr(Strip(line),1,31) = '+'||Copies('-',30) Then Leave
295                     Call Lineout thisfile, line '<BR>'
296                   End
297                   Call Lineout thisfile, '<IMG SRC="../images/divbot.png" ALT="----------"><BR>'
298                   Call Lineout thisfile, '</BLOCKQUOTE><P>'
299                   Iterate
300                 End
301               If Substr(Strip(line),1,31) = '*'||Copies('-',30) Then
302                 Do
303                   Call Lineout thisfile, '<PRE>'
304                   Do Forever
305                     line = Linein(infile)
306                     If Substr(Strip(line),1,31) = '*'||Copies('-',30) Then Leave
307                     Call Lineout thisfile, line
308                   End
309                   Call Lineout thisfile, '</PRE><P>'
310                   Iterate
311                 End
312               If Strip(line) = '' Then
313                 Do
314                   tmp = handle_keywords(tmp,syntax_words)
315                   Call Lineout thisfile, '<DD>' Strip(tmp) '<P></DD>'
316                   If Substr(tmp,Length(tmp),1) = ':' Then
317                      Do
318                        first = 'Y'
319                        Do Forever
320                           line = Strip(Linein(infile))
321                           If line = '' Then Leave
322                           If first = 'Y' Then
323                             Do
324                              Call Lineout thisfile, '<DD>' handle_keywords(line,syntax_keywords)
325                              first = 'N'
326                             End
327                           Else
328                              Call Lineout thisfile, '</DD><DD>' handle_keywords(line,syntax_keywords)
329                        End
330                        Call Lineout thisfile, '<P></DD>'
331                      End
332                   tmp = ''
333                   Iterate
334                 End
335               If line = '     COMPATIBILITY' Then
336                 Do
337                   already_read_line = 'Y'
338                   Leave
339                 End
340               If Pos('<>',line) \= 0 Then
341                 Do
342                   Parse Var line pre '<>' post
343                   line = pre||'&lt;&gt;'||post
344                 End
345               tmp = tmp line
346            End
347          End
348     Otherwise Nop
349   End
350End
351Do i = 1 To toc_idx
352   Call Lineout tocfile, toc.i
353End
354Call footing thisfile
355Return
356
357/********************************************************************/
358glossary: Procedure Expose html_ext section ?port ?slash ?os dest
359Parse arg infile tocfile title
360toc. = ''
361toc_idx = 0
362already_read_line = 'N'
363first_time = 'Y'
364thisfile = dest||?slash'misc'?slash'glossary' || html_ext
365Call heading thisfile,,title
366Do While(Lines(infile)>0)
367   If already_read_line = 'N' Then line = Linein(infile)
368   already_read_line = 'N'
369   Select
370     When Strip(line) = Copies('=',72) Then
371          Do
372            line = Strip(Linein(infile))
373            Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,line,"")'</DT>'
374            Call Lineout thisfile, '<A NAME="' || line || '"></A>'
375            Call Lineout thisfile, '<H2>' line '</H2>'
376            Call Lineout thisfile, '<HR>'
377            line = Linein(infile)
378          End
379     When Strip(line) = '' Then Nop
380     When Strip(line) = Copies('-',74) Then Call Lineout thisfile, '</DL><HR>'
381     When Substr(line,1,15) = Copies(' ',15) Then
382          Do
383            tmp = Strip(line)
384            Do Forever
385               line = Strip(Linein(infile))
386               If line = '' Then Leave
387               tmp = tmp line
388            End
389            tmp = handle_keywords(tmp,'')
390            tmp = ConvertSpecialChars(tmp)
391            Call Lineout thisfile, '<DD>' Strip(tmp) '<P></DD>'
392          End
393     Otherwise
394          Do
395            line = Strip(line)
396            Call Lineout thisfile, '<DT><A NAME="' || RemoveSpaces(Translate(line)) || '">' Bold(line) '</A></DT>'
397/*
398            toc_idx = toc_idx + 1
399            toc.toc_idx = '<DD>'MakeTOC('#',thisfile,line,"")'</DD>'
400*/
401          End
402   End
403End
404Do i = 1 To toc_idx
405   Call Lineout tocfile, toc.i
406End
407Call footing thisfile
408Return
409
410/********************************************************************/
411query: Procedure Expose html_ext ?port ?slash ?os
412Parse arg infile tocfile title
413toc. = ''
414toc_idx = 0
415already_read_line = 'N'
416once = 'Y'
417thisfile = 'misc'?slash'query' || html_ext
418Call heading thisfile,,title
419in_table = 'N'
420first_time = 'Y'
421Do While(Lines(infile)>0)
422   If already_read_line = 'N' Then line = Linein(infile)
423   already_read_line = 'N'
424   Select
425     When Strip(line) = Copies('=',72) Then
426          Do
427            line = Strip(Linein(infile))
428            Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,line,"")'</DT>'
429            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(line) || '"></A>'
430            line = Linein(infile)
431          End
432     When Strip(line) = '' & in_table = 'Y' Then
433          Do
434            in_table = 'N'
435            Call Lineout thisfile, '</TABLE><P></DD>'
436          End
437     When Strip(line) = '' Then Nop
438     When Strip(line) = Copies('-',74) Then
439          Do
440            Call Lineout thisfile, '</DL>'
441            Call Lineout thisfile, '<HR>'
442          End
443     When Substr(line,26,3) = ' - ' Then
444          Do
445            If in_table = 'N' Then
446              Do
447                Call Lineout thisfile, '<DD><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=1>'
448                in_table = 'Y'
449              End
450            Parse Var line col1 '-' col2
451            Call Lineout thisfile, '<TR><TD>'||Strip(col1)||'</TD><TD>-</TD><TD>'||handle_keywords(Strip(col2),'')||'</TD></TR>'
452          End
453     When Substr(line,1,15) = Copies(' ',15) Then
454          Do
455            Call Lineout thisfile, '<DD>' Strip(line) '</DD>'
456          End
457     When Substr(line,1,14) = Copies(' ',14) Then
458          Do
459            Call Lineout thisfile, '<BLOCKQUOTE>'
460            Call Lineout thisfile, '<IMG SRC="../images/divtop.png" ALT="----------"><BR>'
461            Call Lineout thisfile, Strip(line) '<BR>'
462            Do Forever
463              line = Linein(infile)
464              If Strip(line) = '' Then Leave
465              Call Lineout thisfile, Strip(line) '<BR>'
466            End
467            Call Lineout thisfile, '<IMG SRC="../images/divbot.png" ALT="----------"><BR>'
468            Call Lineout thisfile, '<P></BLOCKQUOTE>'
469          End
470     When Substr(line,1,10) = Copies(' ',10) Then
471          Do
472            tmp = line
473            Do Forever
474               line = Strip(Linein(infile))
475               Select
476                 When Substr(line,1,1) = '(' Then
477                      Do
478                        tmp = handle_keywords(tmp,'')
479                        Call Lineout thisfile, '<DD>' Strip(tmp) '</DD>'
480                        Call Lineout thisfile, '<DD>' line '<P></DD>'
481                        Leave
482                      End
483                 When line = '' Then
484                      Do
485                        tmp = handle_keywords(tmp,'')
486                        Call Lineout thisfile, '<DD>' Strip(tmp) '<P></DD>'
487                        Leave
488                      End
489                 Otherwise
490                      Do
491                        tmp = tmp line
492                      End
493               End
494            End
495          End
496     Otherwise
497          Do
498            pre = Subword(line,1,1)
499            post = Subword(line,2)
500            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(Translate(Strip(pre))) || '"></A>'
501            Call Lineout thisfile, '<DT>'
502            If post = '' Then Call Lineout thisfile, Bold(Strip(pre)) '<BR>'
503            Else Call Lineout thisfile, Bold(Strip(pre)) Italic(strip(post)) '<BR>'
504            Call Lineout thisfile, '</DT>'
505            syntax_words = Translate(post,"     ","/|[].")
506          End
507   End
508End
509Do i = 1 To toc_idx
510   Call Lineout tocfile, toc.i
511End
512Call footing thisfile
513Return
514
515/********************************************************************/
516history: Procedure Expose html_ext ?port ?slash ?os
517Parse arg infile tocfile title
518toc. = ''
519toc_idx = 0
520in_env = 'N'
521thisfile = 'misc'?slash'history' || html_ext
522Call heading thisfile,,title
523inlist = 0
524ul = ''
525Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,title,"")'</DT>'
526Do While(Lines(infile)>0)
527   line = Linein(infile)
528   Select
529     When Strip(line) = '' Then Nop
530     When Substr(line,1,7) = 'Version' Then
531          Do
532            If inlist Then
533              Do
534                If ul \= '' Then Call Lineout thisfile, ul
535                inlist = 0
536                Call Lineout thisfile, '</UL>'
537              End
538            Parse Var line v ver dt tail
539            head = v ver
540/*
541            toc_idx = toc_idx + 1
542            toc.toc_idx = '<DD>'MakeTOC('#',thisfile,Strip(head),tail)'</DD>'
543*/
544            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(Translate(Strip(head))) || '"></A>'
545            Call Lineout thisfile, '<HR>'
546            Call Lineout thisfile, '<H3>' line '</H3>'
547            Call Lineout thisfile, '<HR>'
548            ul = ''
549          End
550     When Substr(line,1,4) = " ---" Then
551          Do
552            If inlist Then
553              Do
554                If ul \= '' Then Call Lineout thisfile, ul
555                inlist = 0
556                Call Lineout thisfile, '</UL>'
557              End
558            Call Lineout thisfile, '<H4>'||Substr(line,5)||'</H4><UL>'
559            ul = ''
560          End
561     When Substr(line,1,6) = "     o" Then
562          Do
563            If ul \= '' Then Call Lineout thisfile, ul
564            ul = '<LI>' Strip(Substr(line,7))
565            inlist = 1
566          End
567     When line = "         +---------------" Then
568          Do
569            If ul \= '' Then Call Lineout thisfile, ul
570            Call Lineout thisfile, '<PRE>'
571            inblock = 0
572            Do Forever
573               line = Linein(infile)
574               If line = "         +---------------" Then Leave
575               Call Lineout thisfile, line
576            End
577            Call Lineout thisfile, '</PRE><P>'
578            ul = ''
579          End
580     Otherwise
581          Do
582            ul = ul Strip(line)
583          End
584   End
585End
586Do i = 1 To toc_idx
587   Call Lineout tocfile, toc.i
588End
589If ul \= '' Then Call Lineout thisfile, '<LI>' ul
590Call Lineout thisfile, '</UL><HR>'
591Call footing thisfile
592Return
593
594/********************************************************************/
595appendix1: Procedure Expose html_ext ?port ?slash ?os
596Parse arg infile tocfile title
597toc. = ''
598toc_idx = 0
599thisfile = 'misc'?slash'app1' || html_ext
600Call heading thisfile,,title
601in_env = 'N'
602Do While(Lines(infile)>0)
603   line = Linein(infile)
604   Select
605     When Strip(line) = Copies('=',72) Then
606          Do
607            line = Strip(Linein(infile))
608            Parse Var line head '-' tail
609            Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,Strip(head),tail)'</DT>'
610            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(Strip(head)) || '"></A>'
611            Call Lineout thisfile, '<H2>' line '</H2>'
612            Call Lineout thisfile, '<HR>'
613            line = Linein(infile)
614          End
615     When Strip(line) = Copies('-',74) Then Call Lineout thisfile, '<HR>'
616     When Strip(line) = Copies('*',9) Then Call Lineout thisfile, '<B><H3><CENTER>'line'</CENTER></H3></B>'
617     When Substr(Strip(line),1,15) = Copies('-',15) Then
618          Do
619            line = Strip(Linein(infile))
620            Call Lineout thisfile, '<HR>'
621            Call Lineout thisfile, '<CENTER><B>'||line||'</B></CENTER>'
622            line = Linein(infile)
623            Call Lineout thisfile, '<HR>'
624          End
625     When Substr(line,1,10) = '      THE_' Then
626          Do
627            Parse Var line env '-' rem
628            If in_env = 'N' Then Call Lineout thisfile, '<DL>'
629            in_env = 'Y'
630            rem = handle_keywords(rem,'')
631            Call Lineout thisfile, '<DT><B>'env'</B></DT>'
632            Call Lineout thisfile, '<DD>' rem '<P></DD>'
633          End
634     When Strip(line) = '' & in_env = 'Y' Then
635          Do
636            Call Lineout thisfile, '</DL>'
637            in_env = 'N'
638          End
639     When Strip(line) = '' Then Nop
640     Otherwise
641          Do
642            tmp = Strip(line)
643            Do Forever
644               line = Strip(Linein(infile))
645               If line = '' Then Leave
646               tmp = tmp line
647            End
648          tmp = handle_keywords(tmp,'')
649          Call Lineout thisfile, tmp '<P>'
650          End
651   End
652End
653Do i = 1 To toc_idx
654   Call Lineout tocfile, toc.i
655End
656Call footing thisfile
657Return
658
659/********************************************************************/
660appendix2: Procedure Expose html_ext section ?port ?slash ?os
661Parse arg outfn infile tocfile title
662toc. = ''
663toc_idx = 0
664before_table = 1
665in_table = 'N'
666thisfile = 'misc' || ?slash || outfn || html_ext
667Call heading thisfile,,title
668Do While(Lines(infile)>0)
669   line = Linein(infile)
670   Select
671     When Strip(line) = Copies('=',72) Then
672          Do
673            line = Strip(Linein(infile))
674            Parse Var line head '-' tail
675            Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,Strip(head),tail)'</DT>'
676            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(Strip(head)) || '"></A>'
677            Call Lineout thisfile, '<H2>' line '</H2>'
678            Call Lineout thisfile, '<HR>'
679            line = Linein(infile)
680          End
681     When Strip(line) = Copies('-',74) Then Call Lineout thisfile, '<HR>'
682     When Substr(Strip(line),1,1) = '-' Then
683          Do
684            line = Linein(infile)
685            Call Lineout thisfile, '<B>' Strip(line) '</B><P>'
686            line = Linein(infile)
687          End
688     When Substr(Strip(line),1,2) = '==' Then
689          Do
690            line = Linein(infile)
691            Call Lineout thisfile,'<H2>' Strip(line) '</H2><P>'
692            line = Linein(infile)
693          End
694     When Substr(Strip(line),1,5) = '+----' & Length(Strip(line)) = 31 Then
695          Do
696            Call Lineout thisfile, '<BLOCKQUOTE>'
697            Call Lineout thisfile, '<IMG SRC="../images/divtop.png" ALT="----------"><BR>'
698            Do Forever
699              line = Strip(Linein(infile))
700              If Substr(line,1,5) = '+----' Then Leave
701              If Pos('<',line) \= 0 Then
702                Do
703                  Parse Var line pre '<Key>' rem
704                  Call Lineout thisfile, Strip(pre) '&lt;Key&gt;'||rem '<BR>'
705                End
706              Else
707                Call Lineout thisfile, line '<BR>'
708            End
709            Call Lineout thisfile, '<IMG SRC="../images/divbot.png" ALT="----------"><BR>'
710            Call Lineout thisfile, '</BLOCKQUOTE><P>'
711          End
712     When Substr(Strip(line),1,5) = '+----' Then
713          Do
714            before_table = 0
715            columns = Words(Translate(line,' ','-')) - 1
716            If columns = 1 Then
717              Do
718                align1 = '<CENTER>'
719                align2 = '</CENTER>'
720              End
721            Else
722              Do
723                align1 = ''
724                align2 = ''
725              End
726            Call Lineout thisfile, '<CENTER><TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2>'
727            line = Strip(Linein(infile))
728            line = Strip(Strip(line,,'|'))
729            tmp = '<TR>'
730            Do i = 1 To columns
731               Parse Var line col '|' line
732               If col = '' Then col = '<BR>'
733               tmp = tmp'<TH>'Strip(col)'</TH>'
734            End
735            Call Lineout thisfile, tmp'</TR>'
736            line = Linein(infile) /* remove heading underline */
737            col. = ''
738            Do Forever
739               line = Strip(Linein(infile))
740               If line = '' Then Leave
741               If Translate(line,'  ','+-') = '' Then
742                  Do
743                     /* write out the row */
744                     tmp = '<TR>'
745                     Do i = 1 To columns
746                        tmp = tmp'<TD>'||align1||col.i||align2||'</TD>'
747                     End
748                     Call Lineout thisfile, tmp'</TR>'
749                     col. = ''
750                     Iterate
751                  End
752               line = Strip(Strip(line,,'|'))
753               If columns = 1 & line = '|' Then col.1 = col.1||'|'||'<BR>'
754               Else
755                 Do i = 1 To columns
756                   Parse Var line col '|' line
757                   col.i = col.i||Strip(col)||'<BR>'
758                 End
759            End
760            /* write out the row */
761            tmp = '<TR>'
762            Do i = 1 To columns
763               tmp = tmp'<TD>'||align1||col.i||align2||'</TD>'
764            End
765            Call Lineout thisfile, tmp'</TR></TABLE></CENTER><P>'
766          End
767     When Strip(line) = '' Then Nop
768     When Substr(line,1,7) = Copies(' ',7) Then
769          Do
770            Call Lineout thisfile, '<DD>'Strip(line)'</DD>'
771          End
772     Otherwise
773          Do
774            tmp = Strip(line)
775            Do Forever
776               line = linein(infile)
777               If Strip(line) = '' Then Leave
778               Select
779                  When section = 'APPENDIX4' Then
780                     Do
781                        Select
782                           When Substr(Strip(line),1,7) = 'Syntax:' | Substr(Strip(line),1,19) = 'Meaning of options:' | Substr(Strip(line),1,17) = "ECOLOR Character:" Then
783                              Do
784                                 If tmp \= '' Then
785                                    Do
786                                       tmp = handle_keywords(tmp,'')
787                                       Call Lineout thisfile, tmp '<BR>'
788                                    End
789                                 Call Lineout thisfile,'<I><B>'Strip(line)'</B></I><BR>'
790                                 tmp = ''
791                              End
792                           When Substr(line,1,8) = Copies(' ',8) & Substr(line,9,1) \= ' '  Then
793                              Do
794                                 If tmp \= '' Then
795                                    Do
796                                       tmp = handle_keywords(tmp,'')
797                                       Call Lineout thisfile,tmp '<BR>'
798                                    End
799                                 Call Lineout thisfile,'<I>'Strip(line)'</I><BR>'
800                                 tmp = ''
801                              End
802                           Otherwise tmp = tmp Strip(line)
803                        End
804                     End
805                  When section = 'APPENDIX7' & Pos(Right( Strip( line ), 1 ), ':;.' ) \= 0 Then
806                     Do
807                        If before_table Then Call Lineout thisfile,handle_keywords( tmp Strip( line ) )'<BR>'
808                        Else Call Lineout thisfile,tmp Strip( line )'<BR>'
809                        tmp = ''
810                     End
811                  Otherwise tmp = tmp Strip(line)
812               End
813            End
814          tmp = handle_keywords(tmp,'')
815          Call Lineout thisfile, tmp '<P>'
816          End
817   End
818End
819Do i = 1 To toc_idx
820   Call Lineout tocfile, toc.i
821End
822Call footing thisfile
823Return
824
825/********************************************************************/
826appendixx: Procedure Expose html_ext section ?port ?slash ?os
827Parse arg infile tocfile title
828If section = 'APPENDIX5' Then
829   Do
830      head = 'DEFAULT STATUS SETTINGS IN THE'
831      thisfile = 'misc'?slash'app5' || html_ext
832   End
833Else
834   Do
835      head = 'THE BY TASKS'
836      thisfile = 'misc'?slash'app6' || html_ext
837   End
838Call heading thisfile,,title
839Call Lineout tocfile, '<DT>'MakeTOC('#',thisfile,Translate(title),head)'</DT>'
840Do While(Lines(infile)>0)
841   line = Linein(infile)
842   If ?port = 'REXXSAA' & ?os = 'OS/2' Then num = OS2Countstr("A HREF",line)
843   Else num = Countstr("A HREF",line)
844   outline = ''
845   If num = 0 Then Call Lineout thisfile, line
846   Else
847      Do
848         Do num
849            Parse Var line start "A HREF" . '=' . '"' loc '"' . '>' rem
850            Select
851               When Substr(loc,1,6) = 'mailto' Then
852                  Do
853                     anchor = 'A HREF="' || loc || '">'
854                     outline = outline || start || anchor
855                     line = rem
856                  End
857               When Substr(loc,1,7) = 'commsos' Then
858                  Do
859                     Parse Var loc . '#' cmd .
860                     anchor = 'A HREF="../commsos/' || cmd || html_ext || '">'
861                     outline = outline || start || anchor
862                     line = rem
863                  End
864               When Substr(loc,1,7) = 'commset' Then
865                  Do
866                     Parse Var loc . '#' cmd .
867                     anchor = 'A HREF="../commset/' || cmd || html_ext || '">'
868                     outline = outline || start || anchor
869                     line = rem
870                  End
871               When Substr(loc,1,4) = 'comm' Then
872                  Do
873                     Parse Var loc . '#' cmd .
874                     anchor = 'A HREF="../comm/' || cmd || html_ext || '">'
875                     outline = outline || start || anchor
876                     line = rem
877                  End
878               Otherwise
879                  Do
880                     Parse Var loc pre '.' . '#' cmd .
881                     anchor = 'A HREF="../misc/' || pre || html_ext || '#' || cmd || '">'
882                     outline = outline || start || anchor
883                     line = rem
884                  End
885            End
886         End
887         Call Charout thisfile, outline
888         Call Lineout thisfile, line
889      End
890End
891Return
892
893/********************************************************************/
894quickref: Procedure Expose html_ext ?port ?slash ?os
895Parse arg infile tocfile title
896toc. = ''
897toc_idx = 0
898table_head. = ''
899colval. = ''
900in_table = 'N'
901in_start = 'Y'
902thisfile = 'misc'?slash'quickref' || html_ext
903Call heading thisfile,,title
904Call Lineout tocfile,'<DT>'MakeTOC('#',thisfile,title,"")'</DT>'
905Call Lineout thisfile, '<A NAME="' || RemoveSPaces(Translate(title)) || '"></A>'
906Do While(Lines(infile)>0)
907   line = Linein(infile)
908   If in_start = 'Y' Then
909     Do
910       line = Strip(line)
911       If Length(line) = 0 Then
912         Do
913           in_start = 'N'
914           Call Lineout thisfile, '<CENTER><HR></CENTER>'
915           Iterate
916         End
917       Call Lineout thisfile, '<CENTER><H1>' line '</H1></CENTER>'
918       Iterate
919     End
920   Select
921     When Strip(line) = Copies('-',74) Then Call Lineout thisfile, '<HR>'
922     When Substr(Strip(line),1,1) = '-' Then
923          Do
924            line = Linein(infile)
925            header = Strip(line)
926/*
927            toc_idx = toc_idx + 1
928            toc.toc_idx = '<DD>'MakeTOC('#',thisfile,header,'')'</DD>'
929*/
930            Call Lineout thisfile, '<A NAME="' || RemoveSpaces(Translate(header)) || '"></A>'
931            Call Lineout thisfile, '<H2>' header '</H2>'
932            line = Linein(infile)
933          End
934     When Substr(Strip(line),1,5) = '+----' Then
935          Do
936            columns = Words(Translate(line,' ','-')) - 1
937            If columns = 1 Then
938              Do
939                align1 = '<CENTER>'
940                align2 = '</CENTER>'
941              End
942            Else
943              Do
944                align1 = ''
945                align2 = ''
946              End
947            Call Lineout thisfile, '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2>'
948            line = Strip(Linein(infile))
949            tmp = '<TR>'
950            Do i = 0 To columns
951               Parse Var line col '|' line
952               If col = '' Then col = '<BR>'
953               table_head.i = Strip(col)'<BR>'
954            End
955            Do Forever
956               line = Strip(Linein(infile))
957               If Substr(line,1,5) = '+----' Then Leave
958               Do i = 0 To columns
959                  Parse Var line col '|' line
960                  If col = '' Then col = '<BR>'
961                  table_head.i = table_head.i||Strip(col)||'<BR>'
962               End
963            End
964            tmp = ''
965            Do i = 1 To columns
966               tmp = tmp'<TH>'table_head.i'</TH>'
967            End
968            Call Lineout thisfile, tmp'</TR>'
969            col. = ''
970            Do Forever
971               line = Strip(Linein(infile))
972               If Substr(line,1,5) = '+----' Then Leave
973               If line = '' | Translate(line,'  ','+-') = '' Then Leave
974               line = Strip(Strip(line,,'|'))
975               If columns = 1 & line = '|' Then col.1 = col.1||'|'||'<BR>'
976               Else
977                 Do i = 1 To columns
978                   Parse Var line col '|' line
979                   col.i = col.i||Strip(col)||'<BR>'
980                 End
981            End
982            tmp = '<TR>'
983            Do i = 1 To columns
984               tmp = tmp'<TD>'||align1||col.i||align2||'</TD>'
985            End
986            Call Lineout thisfile, tmp'</TR></TABLE><P>'
987          End
988     When Strip(line) = '' Then Nop
989     When header = 'Command-line invocation' Then
990          Do
991            Select
992              When Word(line,1) = 'the' Then
993                   Do
994                     Call Lineout thisfile, '<B>' Strip(line) '</B><P>'
995                   End
996              When Word(line,1) = 'Where:' Then
997                   Do
998                     Call Lineout thisfile, '<B>' Strip(line) '</B><P>'
999                     Call Lineout thisfile, '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2><TR>'
1000                     ar = '<TD>'
1001                     dr = '<TD>'
1002                     Do Forever
1003                        line = Linein(infile)
1004                        If Strip(line) = '' Then Leave
1005                        Parse Var line 1 arg 19 desc
1006                        arg = Strip(arg)
1007                        desc = Strip(desc)
1008                        ar = ar arg'<BR>'
1009                        dr = dr desc'<BR>'
1010                     End
1011                     Call Lineout thisfile, ar'</TD>'
1012                     Call Lineout thisfile, dr'</TD>'
1013                     Call Lineout thisfile, '</TR></TABLE><P>'
1014                   End
1015              When Word(line,1) = 'Option' Then
1016                   Do
1017                     Call Lineout thisfile, '<B>' Strip(line) '</B><BR>'
1018                   End
1019              Otherwise Nop
1020            End
1021          End
1022     When header = 'Prefix commands' Then
1023          Do
1024            Call Lineout thisfile, '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2><TR>'
1025            ar = '<TD>'
1026            dr = '<TD>'
1027            Do Forever
1028              Parse Var line arg '-' desc
1029              arg = Strip(arg)
1030              desc = Strip(desc)
1031              ar = ar arg'<BR>'
1032              dr = dr desc'<BR>'
1033              line = Linein(infile)
1034              If Strip(line) = '' Then Leave
1035            End
1036            Call Lineout thisfile, ar'</TD>'
1037            Call Lineout thisfile, dr'</TD>'
1038            Call Lineout thisfile, '</TR></TABLE><P>'
1039          End
1040     When header = 'Line Targets' Then
1041          Do
1042            Call Lineout thisfile, '<TABLE BORDER=1 CELLSPACING=1 CELLPADDING=2><TR>'
1043            ar = '<TD>'
1044            dr = '<TD>'
1045            Do Forever
1046              Parse Var line arg 27 desc
1047              arg = Strip(arg)
1048              desc = Strip(desc)
1049              ar = ar arg'<BR>'
1050              dr = dr desc'<BR>'
1051              line = Linein(infile)
1052              If Strip(line) = '' Then Leave
1053            End
1054            Call Lineout thisfile, ar'</TD>'
1055            Call Lineout thisfile, dr'</TD>'
1056            Call Lineout thisfile, '</TR></TABLE><P>'
1057            Do Forever
1058               line = Strip(Linein(infile))
1059               If line = '' Then Leave
1060               Call Lineout thisfile, line '<BR>'
1061            End
1062          End
1063     When Substr(line,2,5) = '[SET]' | Substr(line,2,3) = 'SET' Then
1064          Do
1065            If Translate(Word(line,2)) = 'SET_COMMAND' Then
1066               Call Lineout thisfile, '<A HREF = "../comm/SET' || html_ext || '"> SET' Word(line,2) '</A>' Subword(line,3) '<BR>'
1067            Else
1068               Call Lineout thisfile, '<A HREF = "../commset/SET' || Translate(Word(line,2)) || html_ext'"> [SET]' Word(line,2) '</A>' Subword(line,3) '<BR>'
1069          End
1070     When Substr(line,2,3) = 'SOS' Then
1071          Do
1072            If Translate(Word(line,2)) = 'SOS_COMMAND' Then
1073               Call Lineout thisfile, '<A HREF = "../comm/SOS' || html_ext'"> SOS' Word(line,2) '</A>' Subword(line,3) '<BR>'
1074            Else
1075               Call Lineout thisfile, '<A HREF = "../commsos/SOS' || Translate(Word(line,2)) || html_ext'"> SOS' Word(line,2) '</A>' Subword(line,3) '<BR>'
1076          End
1077     When Substr(line,2,1) \= ' ' Then
1078          Do
1079            Select
1080              When Word(line,1) = '[Locate]' Then word1 = 'LOCATE'
1081              When Substr(Word(line,1),1,1) = '?' Then word1 = SpecialTranslate('?')
1082              When Substr(Word(line,1),1,1) = '!' Then word1 = SpecialTranslate('!')
1083              When Substr(Word(line,1),1,1) = '=' Then word1 = SpecialTranslate('=')
1084              When Substr(Word(line,1),1,1) = '&' Then word1 = SpecialTranslate('&')
1085              Otherwise word1 = Translate(Word(line,1))
1086            End
1087            Call Lineout thisfile, '<A HREF = "../comm/' || word1 || html_ext'">' Word(line,1) '</A>' Subword(line,2) '<BR>'
1088          End
1089     When Substr(line,1,7) = Copies(' ',7) Then
1090          Do
1091            Call Lineout thisfile, Strip(line)'<BR>'
1092          End
1093     Otherwise
1094          Do
1095            tmp = Strip(line)
1096            Do Forever
1097               line = Strip(linein(infile))
1098               If line = '' Then Leave
1099               tmp = tmp line
1100            End
1101          tmp = handle_keywords(tmp,'')
1102          Call Lineout thisfile, tmp '<P>'
1103          End
1104   End
1105End
1106Do i = 1 To toc_idx
1107   Call Lineout tocfile, toc.i
1108End
1109Call footing thisfile
1110Return
1111
1112/********************************************************************/
1113fdl: Procedure Expose html_ext section ?port ?slash ?os
1114Parse arg infile tocfile title
1115thisfile = 'misc'?slash'fdl' || html_ext
1116Call heading thisfile,,title
1117Do While(Lines(infile)>0)
1118   Call Lineout thisfile,Linein(infile)
1119End
1120Return
1121
1122/********************************************************************/
1123toc: Procedure Expose html_ext ?port ?slash ?os
1124Parse arg action ver section tocfile
1125If action = 'START' Then
1126  Do
1127    Call heading tocfile,'INDEX','Table of Contents'
1128    Call Lineout tocfile, '<HR><CENTER><H1>The Hessling Editor</H1> </CENTER>'
1129    Call Lineout tocfile, '<HR><CENTER><H1>Version' ver '</H1> </CENTER><P>'
1130    Call Lineout tocfile, '<A NAME="TOC"></A>'
1131    Select
1132       When section = 'COMM' Then Call Lineout tocfile, '<HR><CENTER><H2>Commands</H2> </CENTER><HR><DL>'
1133       When section = 'COMMSET' Then Call Lineout tocfile, '<HR><CENTER><H2>SET Commands</H2> </CENTER><HR><DL>'
1134       When section = 'COMMSOS' Then Call Lineout tocfile, '<HR><CENTER><H2>SOS Commands</H2> </CENTER><HR><DL>'
1135       When section = 'GLOSSARY' Then Call Lineout tocfile, '<HR><CENTER><H2>GLOSSARY</H2> </CENTER><HR><DL>'
1136       When section = 'HISTORY' Then Call Lineout tocfile, '<HR><CENTER><H2>History of THE</H2> </CENTER><HR><DL>'
1137       When section = 'QUERY' Then Call Lineout tocfile, '<HR><CENTER><H2>Query and Extract</H2> </CENTER><HR><DL>'
1138       When section = 'APPENDIX1' Then Call Lineout tocfile, '<HR><DL>'
1139       When section = 'APPENDIX2' Then Call Lineout tocfile, '<HR><DL>'
1140       When section = 'APPENDIX3' Then Call Lineout tocfile, '<HR><DL>'
1141       When section = 'APPENDIX4' Then Call Lineout tocfile, '<HR><DL>'
1142       When section = 'APPENDIX5' Then Call Lineout tocfile, '<HR><DL>'
1143       When section = 'FDL' Then Call Lineout tocfile, '<HR><DL>'
1144       Otherwise Call Lineout tocfile, '<HR><CENTER><H2>TABLE OF CONTENTS</H2> </CENTER><HR><DL>'
1145    End
1146  End
1147Else
1148  Do
1149    Call Lineout tocfile, '</DL><HR>'
1150    Call footing tocfile 'TOC'
1151  End
1152Return
1153
1154/********************************************************************/
1155Bold: Procedure Expose html_ext ?port ?slash ?os
1156Parse Arg line
1157Return '<B>'line'</B>'
1158
1159/********************************************************************/
1160Italic: Procedure Expose html_ext ?port ?slash ?os
1161Parse Arg line
1162Return '<I>'line'</I>'
1163
1164/********************************************************************/
1165MakeTOC: Procedure Expose html_ext ?port ?slash ?os
1166Parse Arg type,fn,keyword,desc
1167name = RemoveSpaces(SpecialTranslate(keyword))
1168/* fn = Substr(fn,4) */
1169If type = '#' Then
1170   Return '<A HREF = "'fn || '#'name'">' keyword '</A>' desc '<BR>'
1171Else
1172   Return '<A HREF = "'fn || '">' keyword '</A>' desc '<BR>'
1173
1174/********************************************************************/
1175MakeRef: Procedure Expose html_ext ?port ?slash ?os
1176Parse Arg trans,extra,keyword
1177If trans = 'UPPER' Then name = Strip(SpecialTranslate(keyword),,"'")
1178Else name = Strip(keyword,,"'")
1179name = RemoveSpaces(name)
1180Select
1181  When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'SET' Then
1182     Do
1183        filename = '../commset/'
1184        name = name || html_ext
1185     End
1186  When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'SOS' Then
1187     Do
1188        filename = '../commsos/'
1189        name = name || html_ext
1190     End
1191  When Words(keyword) > 1 & Translate(Word(keyword,1)) = 'QUERY,' Then
1192     Do
1193        filename = '../misc/query' || html_ext || '#'
1194     End
1195  When keyword \= Translate(keyword) Then
1196     Do
1197        filename = '../misc/glossary' || html_ext || '#'
1198     End
1199  Otherwise
1200       Do
1201         if keyword = 'REXX' Then
1202            Do
1203               filename = '../misc/glossary' || html_ext || '#'
1204               keyword = 'Rexx'
1205            End
1206         else
1207            Do
1208               filename = '../comm/'
1209               name = name || html_ext
1210            End
1211       End
1212End
1213Return '<A HREF = "'filename || name'">'||keyword||'</A>'extra
1214
1215/********************************************************************/
1216heading: Procedure Expose html_ext ?port ?slash ?os
1217Parse Arg fn, section, title
1218Call Lineout fn, '<HTML>'
1219Call Lineout fn, '<HEAD><TITLE>THE Reference -' title '</TITLE></HEAD>'
1220Call Lineout fn, '<BODY BGCOLOR="#F1EDD1" LINK = "#0000FF" VLINK = "#FF0022" ALINK = "#808000">'
1221If section = 'INDEX' Then
1222   Call Lineout fn, '<CENTER> <img WIDTH="64" HEIGHT="64" HSPACE="20" SRC="images/the64.png"" ALT="THE"> </CENTER>'
1223Else
1224   Call Lineout fn, '<CENTER> <img WIDTH="64" HEIGHT="64" HSPACE="20" SRC="../images/the64.png"" ALT="THE"> </CENTER>'
1225Return
1226
1227/********************************************************************/
1228footing: Procedure Expose html_ext ?port ?slash ?os
1229Parse Arg fn src .
1230Call Lineout fn, '<ADDRESS>'
1231Call Lineout fn, 'The Hessling Editor is Copyright &copy; <A HREF = "http://www.rexx.org/">Mark Hessling</A>, 1990-'Left( Date('S'), 4 )
1232Call Lineout fn, '&lt;<A HREF = "mailto:mark@rexx.org">mark@rexx.org</A>&gt;'
1233Call Lineout fn, '<BR>Generated on:' Date()
1234Call Lineout fn, '</ADDRESS><HR>'
1235If src \= 'TOC' Then Call Lineout fn, 'Return to <A HREF = "../index' || html_ext || '#TOC"> Table of Contents </A><BR>'
1236Call Lineout fn, '</BODY> </HTML>'
1237Call Stream fn, 'C', 'CLOSE'
1238Return
1239
1240/********************************************************************/
1241handle_keywords: Procedure Expose html_ext ?port ?slash ?os
1242Parse Arg line,syntax_words
1243tmp = ''
1244Do Forever    /* handle links */
1245   Parse Var line pre '<' keyword '>' line
1246   Select
1247     When keyword = '' Then tmp = tmp pre
1248     When Left( keyword, 5 ) = 'http:' Then
1249        Do
1250           tmp = tmp pre '<a href="'keyword'">'keyword'</a>'
1251        End
1252     Otherwise tmp = tmp Strip(pre) MakeRef('UPPER',,keyword)
1253   End
1254   If line = '' Then Leave
1255End
1256line = tmp
1257tmp = ''
1258Do Forever              /* handle arguments */
1259   Parse Var line pre "'" keyword "'" line
1260   Select
1261     When keyword = '' Then tmp = tmp pre
1262     Otherwise
1263       Do
1264         If Words(syntax_words) \= 0 & Wordpos(Translate(keyword),Translate(syntax_words)) = 0 Then
1265            tmp = tmp pre "'"keyword"'"
1266         Else
1267            Do
1268              If pre = '' Then
1269                 tmp = tmp pre Italic(keyword)
1270              Else
1271                 Do
1272                   strip_pre = Strip(pre)
1273                   If Substr(strip_pre,Length(strip_pre)) = "#" Then
1274                      tmp = tmp pre || keyword
1275                   Else
1276                      tmp = tmp pre Italic(keyword)
1277                 End
1278            End
1279       End
1280   End
1281   If line = '' Then Leave
1282End
1283Return tmp
1284
1285/********************************************************************/
1286SpecialTranslate: Procedure
1287Parse Arg keyword
1288Select
1289  When keyword = '?' Then Return('QUESTIONMARK')
1290  When keyword = '=' Then Return('EQUALSIGN')
1291  When keyword = '!' Then Return('EXCLAIMARK')
1292  When keyword = '&' Then Return('AMPERSAND')
1293  Otherwise Return Translate(keyword)
1294End
1295Return 'WRONG!!'
1296
1297/********************************************************************/
1298RemoveSpaces: Procedure
1299Parse Arg val
1300retval = ''
1301Do i = 1 To Words(val)
1302   retval = retval || Word(val,i)
1303End
1304Return retval
1305
1306/********************************************************************/
1307ConvertSpecialChars: Procedure
1308Parse Arg val
1309newval = ''
1310intag = 0
1311Do i = 1 To Length(val)
1312   char = Substr(val,i,1)
1313   Select
1314      When Substr(val,i,2) = '<A' Then
1315         Do
1316           intag = 1
1317           newval = newval || Substr(val,i,2)
1318           i = i + 1
1319         End
1320      When Substr(val,i,4) = '</A>' Then
1321         Do
1322           intag = 0
1323           newval = newval || Substr(val,i,4)
1324           i = i + 3
1325         End
1326      When char = '"' & intag = 0 Then newval = newval || '&quot;'
1327      When char = '>' & intag = 0 Then newval = newval || '&gt;'
1328      When char = '<' & intag = 0 Then newval = newval || '&lt;'
1329      Otherwise newval = newval || char
1330   End
1331End
1332Return newval
1333
1334OS2Countstr: Procedure
1335Parse Arg needle, haystack
1336ltest = Length( needle )
1337Parse Var haystack . '' -(ltest) qtest
1338If qtest == needle Then haystack = haystack || needle
1339Do i = 0 Until haystack == ''
1340   Parse Var haystack . (needle) haystack
1341End
1342Return i
1343