1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Converts Latex to HTML
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
26 #include "wx/arrstr.h"
32 #if !WXWIN_COMPATIBILITY_2_4
33 static inline wxChar
* copystring(const wxChar
* s
)
34 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
37 extern wxHashTable TexReferences
;
40 extern void DecToHex(int, wxChar
*);
41 void GenerateHTMLIndexFile(wxChar
*fname
);
43 void GenerateHTMLWorkshopFiles(wxChar
*fname
);
44 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
);
45 void HTMLWorkshopStartContents();
46 void HTMLWorkshopEndContents();
48 void OutputContentsFrame(void);
50 #include "readshg.h" // Segmented hypergraphics parsing
52 wxChar
*ChaptersName
= NULL
;
53 wxChar
*SectionsName
= NULL
;
54 wxChar
*SubsectionsName
= NULL
;
55 wxChar
*SubsubsectionsName
= NULL
;
56 wxChar
*TitlepageName
= NULL
;
57 wxChar
*lastFileName
= NULL
;
58 wxChar
*lastTopic
= NULL
;
59 wxChar
*currentFileName
= NULL
;
60 wxChar
*contentsFrameName
= NULL
;
62 static TexChunk
*descriptionItemArg
= NULL
;
63 static TexChunk
*helpRefFilename
= NULL
;
64 static TexChunk
*helpRefText
= NULL
;
65 static int indentLevel
= 0;
66 static int citeCount
= 1;
67 extern FILE *Contents
;
68 FILE *FrameContents
= NULL
;
69 FILE *Titlepage
= NULL
;
70 // FILE *FrameTitlepage = NULL;
72 bool subsectionStarted
= FALSE
;
74 // Which column of a row are we in? (Assumes no nested tables, of course)
75 int currentColumn
= 0;
77 // Are we in verbatim mode? If so, format differently.
78 static bool inVerbatim
= FALSE
;
80 // Need to know whether we're in a table or figure for benefit
81 // of listoffigures/listoftables
82 static bool inFigure
= FALSE
;
83 static bool inTable
= FALSE
;
85 // This is defined in the Tex2Any library.
86 extern wxChar
*BigBuffer
;
88 // DHS Two-column table dimensions.
89 static int TwoColWidthA
= -1;
90 static int TwoColWidthB
= -1;
93 class HyperReference
: public wxObject
98 HyperReference(wxChar
*name
, wxChar
*file
)
100 if (name
) refName
= copystring(name
);
101 if (file
) refFile
= copystring(file
);
105 class TexNextPage
: public wxObject
110 TexNextPage(wxChar
*theLabel
, wxChar
*theFile
)
112 label
= copystring(theLabel
);
113 filename
= copystring(theFile
);
122 wxHashTable
TexNextPages(wxKEY_STRING
);
124 static wxChar
*CurrentChapterName
= NULL
;
125 static wxChar
*CurrentChapterFile
= NULL
;
126 static wxChar
*CurrentSectionName
= NULL
;
127 static wxChar
*CurrentSectionFile
= NULL
;
128 static wxChar
*CurrentSubsectionName
= NULL
;
129 static wxChar
*CurrentSubsectionFile
= NULL
;
130 static wxChar
*CurrentSubsubsectionName
= NULL
;
131 static wxChar
*CurrentSubsubsectionFile
= NULL
;
132 static wxChar
*CurrentTopic
= NULL
;
134 static void SetCurrentTopic(wxChar
*s
)
136 if (CurrentTopic
) delete[] CurrentTopic
;
137 CurrentTopic
= copystring(s
);
140 void SetCurrentChapterName(wxChar
*s
, wxChar
*file
)
142 if (CurrentChapterName
) delete[] CurrentChapterName
;
143 CurrentChapterName
= copystring(s
);
144 if (CurrentChapterFile
) delete[] CurrentChapterFile
;
145 CurrentChapterFile
= copystring(file
);
147 currentFileName
= CurrentChapterFile
;
151 void SetCurrentSectionName(wxChar
*s
, wxChar
*file
)
153 if (CurrentSectionName
) delete[] CurrentSectionName
;
154 CurrentSectionName
= copystring(s
);
155 if (CurrentSectionFile
) delete[] CurrentSectionFile
;
156 CurrentSectionFile
= copystring(file
);
158 currentFileName
= CurrentSectionFile
;
161 void SetCurrentSubsectionName(wxChar
*s
, wxChar
*file
)
163 if (CurrentSubsectionName
) delete[] CurrentSubsectionName
;
164 CurrentSubsectionName
= copystring(s
);
165 if (CurrentSubsectionFile
) delete[] CurrentSubsectionFile
;
166 CurrentSubsectionFile
= copystring(file
);
167 currentFileName
= CurrentSubsectionFile
;
170 void SetCurrentSubsubsectionName(wxChar
*s
, wxChar
*file
)
172 if (CurrentSubsubsectionName
) delete[] CurrentSubsubsectionName
;
173 CurrentSubsubsectionName
= copystring(s
);
174 if (CurrentSubsubsectionFile
) delete[] CurrentSubsubsectionFile
;
175 CurrentSubsubsectionFile
= copystring(file
);
176 currentFileName
= CurrentSubsubsectionFile
;
181 // mapping between fileId and filenames if truncateFilenames=false:
182 static wxArrayString gs_filenames
;
186 * Close former filedescriptor and reopen using another filename.
190 void ReopenFile(FILE **fd
, wxChar
**fileName
, const wxChar
*label
)
194 wxFprintf(*fd
, _T("\n</FONT></BODY></HTML>\n"));
199 if (truncateFilenames
)
201 wxSprintf(buf
, _T("%s%d.htm"), FileRoot
, fileId
);
205 wxSprintf(buf
, _T("%s_%s.html"), FileRoot
, label
);
206 gs_filenames
.SetCount(fileId
+ 1);
207 gs_filenames
[fileId
] = buf
;
209 if (*fileName
) delete[] *fileName
;
210 *fileName
= copystring(wxFileNameFromPath(buf
));
211 *fd
= wxFopen(buf
, _T("w"));
212 wxFprintf(*fd
, _T("<HTML>\n"));
216 * Reopen section contents file, i.e. the index appended to each section
217 * in subsectionCombine mode
220 static wxChar
*SectionContentsFilename
= NULL
;
221 static FILE *SectionContentsFD
= NULL
;
223 void ReopenSectionContentsFile(void)
225 if ( SectionContentsFD
)
227 fclose(SectionContentsFD
);
229 if ( SectionContentsFilename
)
230 delete[] SectionContentsFilename
;
231 SectionContentsFD
= NULL
;
232 SectionContentsFilename
= NULL
;
234 // Create the name from the current section filename
235 if ( CurrentSectionFile
)
238 wxStrcpy(buf
, CurrentSectionFile
);
239 wxStripExtension(buf
);
240 wxStrcat(buf
, _T(".con"));
241 SectionContentsFilename
= copystring(buf
);
243 SectionContentsFD
= wxFopen(SectionContentsFilename
, _T("w"));
249 * Given a TexChunk with a string value, scans through the string
250 * converting Latex-isms into HTML-isms, such as 2 newlines -> <P>.
254 void ProcessText2HTML(TexChunk
*chunk
)
256 bool changed
= FALSE
;
260 int len
= wxStrlen(chunk
->value
);
263 ch
= chunk
->value
[i
];
265 // 2 newlines means \par
266 if (!inVerbatim
&& chunk
->value
[i
] == 10 && ((len
> i
+1 && chunk
->value
[i
+1] == 10) ||
267 ((len
> i
+1 && chunk
->value
[i
+1] == 13) &&
268 (len
> i
+2 && chunk
->value
[i
+2] == 10))))
270 BigBuffer
[ptr
] = 0; wxStrcat(BigBuffer
, _T("<P>\n\n")); ptr
+= 5;
274 else if (!inVerbatim
&& ch
== '`' && (len
>= i
+1 && chunk
->value
[i
+1] == '`'))
276 BigBuffer
[ptr
] = '"'; ptr
++;
280 else if (!inVerbatim
&& ch
== '`') // Change ` to '
282 BigBuffer
[ptr
] = 39; ptr
++;
286 else if (ch
== '<') // Change < to <
289 wxStrcat(BigBuffer
, _T("<"));
294 else if (ch
== '>') // Change > to >
297 wxStrcat(BigBuffer
, _T(">"));
314 chunk
->value
= copystring(BigBuffer
);
319 * Scan through all chunks starting from the given one,
320 * calling ProcessText2HTML to convert Latex-isms to RTF-isms.
321 * This should be called after Tex2Any has parsed the file,
322 * and before TraverseDocument is called.
326 void Text2HTML(TexChunk
*chunk
)
329 if (stopRunning
) return;
333 case CHUNK_TYPE_MACRO
:
335 TexMacroDef
*def
= chunk
->def
;
337 if (def
&& def
->ignore
)
340 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
343 wxNode
*node
= chunk
->children
.GetFirst();
346 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
347 Text2HTML(child_chunk
);
348 node
= node
->GetNext();
351 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
358 wxNode
*node
= chunk
->children
.GetFirst();
361 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
362 Text2HTML(child_chunk
);
363 node
= node
->GetNext();
368 case CHUNK_TYPE_STRING
:
371 ProcessText2HTML(chunk
);
378 * Add appropriate browse buttons to this page.
382 void AddBrowseButtons(wxChar
*upLabel
, wxChar
*upFilename
,
383 wxChar
*previousLabel
, wxChar
*previousFilename
,
384 wxChar
*thisLabel
, wxChar
*thisFilename
)
386 wxChar contentsReferenceBuf
[80];
387 wxChar upReferenceBuf
[80];
388 wxChar backReferenceBuf
[80];
389 wxChar forwardReferenceBuf
[80];
390 if (htmlBrowseButtons
== HTML_BUTTONS_NONE
)
393 wxChar
*contentsReference
; // no need to initialize because always assigned below
394 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
395 contentsReference
= ContentsNameString
;
398 // contentsReference = "<img align=center src=\"contents.gif\" BORDER=0 ALT=\"Contents\">";
399 contentsReference
= contentsReferenceBuf
;
400 wxSprintf(contentsReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">"), ConvertCase(_T("contents.gif")));
403 wxChar
*upReference
; // no need to initialize because always assigned below
404 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
405 upReference
= UpNameString
;
408 // upReference = "<img align=center src=\"up.gif\" ALT=\"Up\">";
409 upReference
= upReferenceBuf
;
410 wxSprintf(upReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">"), ConvertCase(_T("up.gif")));
413 wxChar
*backReference
; // no need to initialize because always assigned below
414 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
415 backReference
= _T("<<");
418 // backReference = "<img align=center src=\"back.gif\" ALT=\"Previous\">";
419 backReference
= backReferenceBuf
;
420 wxSprintf(backReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">"), ConvertCase(_T("back.gif")));
423 wxChar
*forwardReference
; // no need to initialize because always assigned below
424 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
425 forwardReference
= _T(">>");
428 // forwardReference = "<img align=center src=\"forward.gif\" ALT=\"Next\">";
429 forwardReference
= forwardReferenceBuf
;
430 wxSprintf(forwardReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">"), ConvertCase(_T("forward.gif")));
433 TexOutput(_T("<CENTER>"));
442 if (truncateFilenames
)
445 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
446 wxSprintf(buf
, _T("\n<A HREF=\"%s.%s\">%s</A> "), buf1
, ConvertCase(_T("htm")), contentsReference
);
451 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
452 wxSprintf(buf
, _T("\n<A HREF=\"%s%s\">%s</A> "), buf1
, ConvertCase(_T("_contents.html")), contentsReference
);
454 // TexOutput(_T("<NOFRAMES>"));
456 // TexOutput(_T("</NOFRAMES>"));
463 if (upLabel
&& upFilename
)
465 if (wxStrlen(upLabel
) > 0)
466 wxSprintf(buf
, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(upFilename
), upLabel
, upReference
);
468 wxSprintf(buf
, _T("<A HREF=\"%s\">%s</A> "), ConvertCase(upFilename
), upReference
);
469 if (wxStrcmp(upLabel
, _T("contents")) == 0)
471 // TexOutput(_T("<NOFRAMES>"));
473 // TexOutput(_T("</NOFRAMES>"));
484 if (previousLabel
&& previousFilename
)
486 wxSprintf(buf
, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(previousFilename
), previousLabel
, backReference
);
487 if (wxStrcmp(previousLabel
, _T("contents")) == 0)
489 // TexOutput(_T("<NOFRAMES>"));
491 // TexOutput(_T("</NOFRAMES>"));
498 // A placeholder so the buttons don't keep moving position
499 wxSprintf(buf
, _T("%s "), backReference
);
503 wxChar
*nextLabel
= NULL
;
504 wxChar
*nextFilename
= NULL
;
506 // Get the next page, and record the previous page's 'next' page
508 TexNextPage
*nextPage
= (TexNextPage
*)TexNextPages
.Get(thisLabel
);
511 nextLabel
= nextPage
->label
;
512 nextFilename
= nextPage
->filename
;
514 if (previousLabel
&& previousFilename
)
516 TexNextPage
*oldNextPage
= (TexNextPage
*)TexNextPages
.Get(previousLabel
);
520 TexNextPages
.Delete(previousLabel
);
522 TexNextPage
*newNextPage
= new TexNextPage(thisLabel
, thisFilename
);
523 TexNextPages
.Put(previousLabel
, newNextPage
);
531 if (nextLabel
&& nextFilename
)
533 wxSprintf(buf
, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(nextFilename
), nextLabel
, forwardReference
);
538 // A placeholder so the buttons don't keep moving position
539 wxSprintf(buf
, _T("%s "), forwardReference
);
544 * Horizontal rule to finish it off nicely.
547 TexOutput(_T("</CENTER>"));
548 TexOutput(_T("<HR>\n"));
550 // Update last topic/filename
552 delete[] lastFileName
;
553 lastFileName
= copystring(thisFilename
);
556 lastTopic
= copystring(thisLabel
);
559 // A colour string is either 3 numbers separated by semicolons (RGB),
560 // or a reference to a GIF. Return the filename or a hex string like #934CE8
561 wxChar
*ParseColourString(wxChar
*bkStr
, bool *isPicture
)
563 static wxChar resStr
[300];
564 wxStrcpy(resStr
, bkStr
);
565 wxStringTokenizer
tok(resStr
, _T(";"), wxTOKEN_STRTOK
);
566 if (tok
.HasMoreTokens())
568 wxString token1
= tok
.GetNextToken();
569 if (!tok
.HasMoreTokens())
576 wxString token2
= tok
.GetNextToken();
578 if (tok
.HasMoreTokens())
580 wxString token3
= tok
.GetNextToken();
582 // Now convert 3 strings into decimal numbers, and then hex numbers.
583 int red
= wxAtoi(token1
.c_str());
584 int green
= wxAtoi(token2
.c_str());
585 int blue
= wxAtoi(token3
.c_str());
587 wxStrcpy(resStr
, _T("#"));
591 wxStrcat(resStr
, buf
);
592 DecToHex(green
, buf
);
593 wxStrcat(resStr
, buf
);
595 wxStrcat(resStr
, buf
);
604 void OutputFont(void)
606 // Only output <font face> if explicitly requested by htmlFaceName= directive in
607 // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's
611 // Output <FONT FACE=...>
612 TexOutput(_T("<FONT FACE=\""));
613 TexOutput(htmlFaceName
);
614 TexOutput(_T("\">\n"));
618 // Output start of <BODY> block
619 void OutputBodyStart(void)
621 TexOutput(_T("\n<BODY"));
622 if (backgroundImageString
)
624 bool isPicture
= FALSE
;
625 wxChar
*s
= ParseColourString(backgroundImageString
, &isPicture
);
628 TexOutput(_T(" BACKGROUND=\""));
633 if (backgroundColourString
)
635 bool isPicture
= FALSE
;
636 wxChar
*s
= ParseColourString(backgroundColourString
, &isPicture
);
639 TexOutput(_T(" BGCOLOR="));
644 // Set foreground text colour, if one is specified
645 if (textColourString
)
647 bool isPicture
= FALSE
;
648 wxChar
*s
= ParseColourString(textColourString
, &isPicture
);
651 TexOutput(_T(" TEXT=")); TexOutput(s
);
654 // Set link text colour, if one is specified
655 if (linkColourString
)
657 bool isPicture
= FALSE
;
658 wxChar
*s
= ParseColourString(linkColourString
, &isPicture
);
661 TexOutput(_T(" LINK=")); TexOutput(s
);
664 // Set followed link text colour, if one is specified
665 if (followedLinkColourString
)
667 bool isPicture
= FALSE
;
668 wxChar
*s
= ParseColourString(followedLinkColourString
, &isPicture
);
671 TexOutput(_T(" VLINK=")); TexOutput(s
);
674 TexOutput(_T(">\n"));
681 TexOutput(_T("<head>"));
682 if (htmlStylesheet
) {
683 TexOutput(_T("<link rel=stylesheet type=\"text/css\" href=\""));
684 TexOutput(htmlStylesheet
);
685 TexOutput(_T("\">"));
689 void HTMLHeadTo(FILE* f
)
692 wxFprintf(f
,_T("<head><link rel=stylesheet type=\"text/css\" href=\"%s\">"),htmlStylesheet
);
694 wxFprintf(f
,_T("<head>"));
697 // Called on start/end of macro examination
698 void HTMLOnMacro(int macroId
, int no_args
, bool start
)
704 case ltCHAPTERHEADING
:
712 if (macroId
!= ltCHAPTERSTAR
)
715 SetCurrentOutput(NULL
);
716 startedSections
= TRUE
;
718 wxChar
*topicName
= FindTopicName(GetNextChunk());
719 ReopenFile(&Chapters
, &ChaptersName
, topicName
);
720 AddTexRef(topicName
, ChaptersName
, ChapterNameString
);
722 SetCurrentChapterName(topicName
, ChaptersName
);
723 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(0, topicName
, ChaptersName
);
725 SetCurrentOutput(Chapters
);
728 TexOutput(_T("<title>"));
729 OutputCurrentSection(); // Repeat section header
730 TexOutput(_T("</title></head>\n"));
733 wxChar titleBuf
[200];
734 if (truncateFilenames
)
735 wxSprintf(titleBuf
, _T("%s.htm"), wxFileNameFromPath(FileRoot
));
737 wxSprintf(titleBuf
, _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
739 wxFprintf(Chapters
, _T("<A NAME=\"%s\"></A>"), topicName
);
741 AddBrowseButtons(_T(""), titleBuf
, // Up
742 lastTopic
, lastFileName
, // Last topic
743 topicName
, ChaptersName
); // This topic
745 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), topicName
);
747 if (htmlFrameContents
&& FrameContents
)
749 SetCurrentOutput(FrameContents
);
750 wxFprintf(FrameContents
, _T("\n<LI><A HREF=\"%s#%s\" TARGET=\"mainwindow\">"), ConvertCase(ChaptersName
), topicName
);
751 OutputCurrentSection();
752 wxFprintf(FrameContents
, _T("</A>\n"));
755 SetCurrentOutputs(Contents
, Chapters
);
756 wxFprintf(Chapters
, _T("\n<H2>"));
757 OutputCurrentSection();
758 wxFprintf(Contents
, _T("</A>\n"));
759 wxFprintf(Chapters
, _T("</H2>\n"));
761 SetCurrentOutput(Chapters
);
763 // Add this section title to the list of keywords
766 OutputCurrentSectionToString(wxTex2RTFBuffer
);
767 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, ConvertCase(currentFileName
));
774 case ltSECTIONHEADING
:
781 subsectionStarted
= FALSE
;
783 if (macroId
!= ltSECTIONSTAR
)
786 SetCurrentOutput(NULL
);
787 startedSections
= TRUE
;
789 wxChar
*topicName
= FindTopicName(GetNextChunk());
790 ReopenFile(&Sections
, &SectionsName
, topicName
);
791 AddTexRef(topicName
, SectionsName
, SectionNameString
);
793 SetCurrentSectionName(topicName
, SectionsName
);
794 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(1, topicName
, SectionsName
);
796 SetCurrentOutput(Sections
);
798 TexOutput(_T("<title>"));
799 OutputCurrentSection();
800 TexOutput(_T("</title></head>\n"));
803 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
804 AddBrowseButtons(CurrentChapterName
, CurrentChapterFile
, // Up
805 lastTopic
, lastFileName
, // Last topic
806 topicName
, SectionsName
); // This topic
808 FILE *jumpFrom
= ((DocumentStyle
== LATEX_ARTICLE
) ? Contents
: Chapters
);
810 SetCurrentOutputs(jumpFrom
, Sections
);
811 if (DocumentStyle
== LATEX_ARTICLE
)
812 wxFprintf(jumpFrom
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(SectionsName
), topicName
);
814 wxFprintf(jumpFrom
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SectionsName
), topicName
);
816 wxFprintf(Sections
, _T("\n<H2>"));
817 OutputCurrentSection();
819 if (DocumentStyle
== LATEX_ARTICLE
)
820 wxFprintf(jumpFrom
, _T("</A>\n"));
822 wxFprintf(jumpFrom
, _T("</B></A><BR>\n"));
823 wxFprintf(Sections
, _T("</H2>\n"));
825 SetCurrentOutput(Sections
);
826 // Add this section title to the list of keywords
829 OutputCurrentSectionToString(wxTex2RTFBuffer
);
830 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
836 case ltSUBSECTIONSTAR
:
837 case ltMEMBERSECTION
:
838 case ltFUNCTIONSECTION
:
844 OnError(_T("You cannot have a subsection before a section!"));
850 if (macroId
!= ltSUBSECTIONSTAR
)
853 if ( combineSubSections
&& !subsectionStarted
)
855 // Read old .con file in at this point
857 wxStrcpy(buf
, CurrentSectionFile
);
858 wxStripExtension(buf
);
859 wxStrcat(buf
, _T(".con"));
860 FILE *fd
= wxFopen(buf
, _T("r"));
871 wxFprintf(Sections
, _T("<P>\n"));
873 // Close old file, create a new file for the sub(sub)section contents entries
874 ReopenSectionContentsFile();
877 startedSections
= TRUE
;
878 subsectionStarted
= TRUE
;
880 wxChar
*topicName
= FindTopicName(GetNextChunk());
882 if ( !combineSubSections
)
884 SetCurrentOutput(NULL
);
885 ReopenFile(&Subsections
, &SubsectionsName
, topicName
);
886 AddTexRef(topicName
, SubsectionsName
, SubsectionNameString
);
887 SetCurrentSubsectionName(topicName
, SubsectionsName
);
888 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SubsectionsName
);
889 SetCurrentOutput(Subsections
);
892 TexOutput(_T("<title>"));
893 OutputCurrentSection();
894 TexOutput(_T("</title></head>\n"));
897 wxFprintf(Subsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
898 AddBrowseButtons(CurrentSectionName
, CurrentSectionFile
, // Up
899 lastTopic
, lastFileName
, // Last topic
900 topicName
, SubsectionsName
); // This topic
902 SetCurrentOutputs(Sections
, Subsections
);
903 wxFprintf(Sections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName
), topicName
);
905 wxFprintf(Subsections
, _T("\n<H3>"));
906 OutputCurrentSection();
907 wxFprintf(Sections
, _T("</B></A><BR>\n"));
908 wxFprintf(Subsections
, _T("</H3>\n"));
910 SetCurrentOutput(Subsections
);
914 AddTexRef(topicName
, SectionsName
, SubsectionNameString
);
915 SetCurrentSubsectionName(topicName
, SectionsName
);
917 // if ( subsectionNo != 0 )
918 wxFprintf(Sections
, _T("\n<HR>\n"));
920 // We're putting everything into the section file
921 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
922 wxFprintf(Sections
, _T("\n<H3>"));
923 OutputCurrentSection();
924 wxFprintf(Sections
, _T("</H3>\n"));
926 SetCurrentOutput(SectionContentsFD
);
927 wxFprintf(SectionContentsFD
, _T("<A HREF=\"#%s\">"), topicName
);
928 OutputCurrentSection();
929 TexOutput(_T("</A><BR>\n"));
931 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
932 SetCurrentOutput(Sections
);
934 // Add this section title to the list of keywords
937 OutputCurrentSectionToString(wxTex2RTFBuffer
);
938 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
945 case ltSUBSUBSECTION
:
946 case ltSUBSUBSECTIONSTAR
:
950 if (!Subsections
&& !combineSubSections
)
952 OnError(_T("You cannot have a subsubsection before a subsection!"));
956 if (macroId
!= ltSUBSUBSECTIONSTAR
)
959 startedSections
= TRUE
;
961 wxChar
*topicName
= FindTopicName(GetNextChunk());
963 if ( !combineSubSections
)
965 SetCurrentOutput(NULL
);
966 ReopenFile(&Subsubsections
, &SubsubsectionsName
, topicName
);
967 AddTexRef(topicName
, SubsubsectionsName
, SubsubsectionNameString
);
968 SetCurrentSubsubsectionName(topicName
, SubsubsectionsName
);
969 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(3, topicName
, SubsubsectionsName
);
971 SetCurrentOutput(Subsubsections
);
973 TexOutput(_T("<title>"));
974 OutputCurrentSection();
975 TexOutput(_T("</title></head>\n"));
978 wxFprintf(Subsubsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
980 AddBrowseButtons(CurrentSubsectionName
, CurrentSubsectionFile
, // Up
981 lastTopic
, lastFileName
, // Last topic
982 topicName
, SubsubsectionsName
); // This topic
984 SetCurrentOutputs(Subsections
, Subsubsections
);
985 wxFprintf(Subsections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName
), topicName
);
987 wxFprintf(Subsubsections
, _T("\n<H3>"));
988 OutputCurrentSection();
989 wxFprintf(Subsections
, _T("</B></A><BR>\n"));
990 wxFprintf(Subsubsections
, _T("</H3>\n"));
994 AddTexRef(topicName
, SectionsName
, SubsubsectionNameString
);
995 SetCurrentSubsectionName(topicName
, SectionsName
);
996 wxFprintf(Sections
, _T("\n<HR>\n"));
998 // We're putting everything into the section file
999 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1000 wxFprintf(Sections
, _T("\n<H3>"));
1001 OutputCurrentSection();
1002 wxFprintf(Sections
, _T("</H3>\n"));
1003 /* TODO: where do we put subsubsection contents entry - indented, with subsection entries?
1004 SetCurrentOutput(SectionContentsFD);
1005 wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName);
1006 OutputCurrentSection();
1007 TexOutput(_T("</A><BR>"));
1009 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
1010 SetCurrentOutput(Sections
);
1013 // Add this section title to the list of keywords
1016 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1017 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
1026 if ( !combineSubSections
)
1027 SetCurrentOutput(Subsections
);
1029 SetCurrentOutput(Sections
);
1040 if ( !combineSubSections
)
1041 SetCurrentOutput(Subsections
);
1043 SetCurrentOutput(Sections
);
1054 if ( !combineSubSections
)
1055 SetCurrentOutput(Subsections
);
1057 SetCurrentOutput(Sections
);
1068 // TexOutput(_T("<B>void</B>"));
1072 TexOutput(_T("HARDY"));
1076 TexOutput(_T("wxCLIPS"));
1080 TexOutput(_T("&"));
1082 case ltSPECIALAMPERSAND
:
1088 // End cell, start cell
1090 TexOutput(_T("</FONT></TD>"));
1092 // Start new row and cell, setting alignment for the first cell.
1093 if (currentColumn
< noColumns
)
1097 if (TableData
[currentColumn
].justification
== 'c')
1098 wxSprintf(buf
, _T("\n<TD ALIGN=CENTER>"));
1099 else if (TableData
[currentColumn
].justification
== 'r')
1100 wxSprintf(buf
, _T("\n<TD ALIGN=RIGHT>"));
1101 else if (TableData
[currentColumn
].absWidth
)
1103 // Convert from points * 20 into pixels.
1104 int points
= TableData
[currentColumn
].width
/ 20;
1106 // Say the display is 100 DPI (dots/pixels per inch).
1107 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1108 int pixels
= (int)(points
* 100.0 / 72.0);
1109 wxSprintf(buf
, _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1112 wxSprintf(buf
, _T("\n<TD ALIGN=LEFT>"));
1117 TexOutput(_T("&"));
1121 case ltBACKSLASHCHAR
:
1127 // End row. In fact, tables without use of \row or \ruledrow isn't supported for
1128 // HTML: the syntax is too different (e.g. how do we know where to put the first </TH>
1129 // if we've ended the last row?). So normally you wouldn't use \\ to end a row.
1130 TexOutput(_T("</TR>\n"));
1133 TexOutput(_T("<BR>\n"));
1144 // Start new row and cell, setting alignment for the first cell.
1146 if (TableData
[currentColumn
].justification
== 'c')
1147 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=CENTER>"));
1148 else if (TableData
[currentColumn
].justification
== 'r')
1149 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=RIGHT>"));
1150 else if (TableData
[currentColumn
].absWidth
)
1152 // Convert from points * 20 into pixels.
1153 int points
= TableData
[currentColumn
].width
/ 20;
1155 // Say the display is 100 DPI (dots/pixels per inch).
1156 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1157 int pixels
= (int)(points
* 100.0 / 72.0);
1158 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1161 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=LEFT>"));
1168 // Start new row and cell
1169 TexOutput(_T("</FONT></TD>\n</TR>\n"));
1173 // HTML-only: break until the end of the picture (both margins are clear).
1177 TexOutput(_T("<BR CLEAR=ALL>"));
1180 case ltRTFSP
: // Explicit space, RTF only
1182 case ltSPECIALTILDE
:
1196 TexOutput(_T("<UL><UL>\n"));
1198 TexOutput(_T("</UL></UL>\n"));
1204 // case ltTWOCOLLIST:
1211 if (macroId
== ltENUMERATE
)
1212 listType
= LATEX_ENUMERATE
;
1213 else if (macroId
== ltITEMIZE
)
1214 listType
= LATEX_ITEMIZE
;
1216 listType
= LATEX_DESCRIPTION
;
1218 itemizeStack
.Insert(new ItemizeStruc(listType
));
1222 TexOutput(_T("<UL>\n"));
1224 case LATEX_ENUMERATE
:
1225 TexOutput(_T("<OL>\n"));
1227 case LATEX_DESCRIPTION
:
1229 TexOutput(_T("<DL>\n"));
1236 if (itemizeStack
.GetFirst())
1238 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
1239 switch (struc
->listType
)
1242 TexOutput(_T("</UL>\n"));
1244 case LATEX_ENUMERATE
:
1245 TexOutput(_T("</OL>\n"));
1247 case LATEX_DESCRIPTION
:
1249 TexOutput(_T("</DL>\n"));
1254 delete itemizeStack
.GetFirst();
1262 TexOutput(_T("\n<TABLE>\n"));
1264 TexOutput(_T("\n</TABLE>\n"));
1274 TexOutput(_T("<P>\n"));
1277 /* For footnotes we need to output the text at the bottom of the page and
1278 * insert a reference to it. Is it worth the trouble...
1280 case ltFOOTNOTEPOPUP:
1284 TexOutput(_T("<FN>"));
1286 else TexOutput(_T("</FN>"));
1293 TexOutput(_T("<TT>"));
1294 else TexOutput(_T("</TT>"));
1302 wxSprintf(buf
, _T("<PRE>\n"));
1305 else TexOutput(_T("</PRE>\n"));
1313 TexOutput(_T("<CENTER>"));
1315 else TexOutput(_T("</CENTER>"));
1323 TexOutput(_T("{\\ql "));
1325 else TexOutput(_T("}\\par\\pard\n"));
1334 TexOutput(_T("{\\qr "));
1336 else TexOutput(_T("}\\par\\pard\n"));
1344 // Netscape extension
1345 TexOutput(_T("<FONT SIZE=2>"));
1347 else TexOutput(_T("</FONT>"));
1354 // Netscape extension
1355 TexOutput(_T("<FONT SIZE=1>"));
1357 else TexOutput(_T("</FONT>"));
1364 // Netscape extension
1365 TexOutput(_T("<FONT SIZE=3>"));
1367 else TexOutput(_T("</FONT>"));
1374 // Netscape extension
1375 TexOutput(_T("<FONT SIZE=4>"));
1377 else TexOutput(_T("</FONT>"));
1384 // Netscape extension
1385 TexOutput(_T("<FONT SIZE=5>"));
1387 else TexOutput(_T("</FONT>"));
1394 // Netscape extension
1395 TexOutput(_T("<FONT SIZE=6>"));
1397 else TexOutput(_T("</FONT>"));
1406 TexOutput(_T("<B>"));
1408 else TexOutput(_T("</B>"));
1417 TexOutput(_T("<I>"));
1419 else TexOutput(_T("</I>"));
1427 TexOutput(_T("<EM>"));
1429 else TexOutput(_T("</EM>"));
1436 TexOutput(_T("<UL>"));
1438 else TexOutput(_T("</UL>"));
1447 TexOutput(_T("<TT>"));
1449 else TexOutput(_T("</TT>"));
1455 TexOutput(_T("©"), TRUE
);
1461 TexOutput(_T("®"), TRUE
);
1467 if (start
) TexOutput(_T("<--"));
1472 if (start
) TexOutput(_T("<=="));
1477 if (start
) TexOutput(_T("-->"));
1482 if (start
) TexOutput(_T("==>"));
1485 case ltLEFTRIGHTARROW
:
1487 if (start
) TexOutput(_T("<-->"));
1490 case ltLEFTRIGHTARROW2
:
1492 if (start
) TexOutput(_T("<==>"));
1505 wxNode
*node
= itemizeStack
.GetFirst();
1508 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
1509 struc
->currentItem
+= 1;
1510 if (struc
->listType
== LATEX_DESCRIPTION
)
1512 if (descriptionItemArg
)
1514 TexOutput(_T("<DT> "));
1515 TraverseChildrenFromChunk(descriptionItemArg
);
1516 TexOutput(_T("\n"));
1517 descriptionItemArg
= NULL
;
1519 TexOutput(_T("<DD>"));
1522 TexOutput(_T("<LI>"));
1529 if (start
&& DocumentTitle
&& DocumentAuthor
)
1531 // Add a special label for the contents page.
1532 // TexOutput(_T("<CENTER>\n"));
1533 TexOutput(_T("<A NAME=\"contents\">"));
1534 TexOutput(_T("<H2 ALIGN=CENTER>\n"));
1535 TraverseChildrenFromChunk(DocumentTitle
);
1536 TexOutput(_T("</H2>"));
1537 TexOutput(_T("<P>"));
1538 TexOutput(_T("</A>\n"));
1539 TexOutput(_T("<P>\n\n"));
1540 TexOutput(_T("<H3 ALIGN=CENTER>"));
1541 TraverseChildrenFromChunk(DocumentAuthor
);
1542 TexOutput(_T("</H3><P>\n\n"));
1545 TexOutput(_T("<H3 ALIGN=CENTER>"));
1546 TraverseChildrenFromChunk(DocumentDate
);
1547 TexOutput(_T("</H3><P>\n\n"));
1549 // TexOutput(_T("\n</CENTER>\n"));
1550 TexOutput(_T("\n<P><HR><P>\n"));
1553 // Now do optional frame contents page
1554 if (htmlFrameContents && FrameContents)
1556 SetCurrentOutput(FrameContents);
1558 // Add a special label for the contents page.
1559 TexOutput(_T("<CENTER>\n"));
1560 TexOutput(_T("<H3>\n"));
1561 TraverseChildrenFromChunk(DocumentTitle);
1562 TexOutput(_T("</H3>"));
1563 TexOutput(_T("<P>"));
1564 TexOutput(_T("</A>\n"));
1565 TexOutput(_T("<P>\n\n"));
1566 TexOutput(_T("<H3>"));
1567 TraverseChildrenFromChunk(DocumentAuthor);
1568 TexOutput(_T("</H3><P>\n\n"));
1571 TexOutput(_T("<H4>"));
1572 TraverseChildrenFromChunk(DocumentDate);
1573 TexOutput(_T("</H4><P>\n\n"));
1575 TexOutput(_T("\n</CENTER>\n"));
1576 TexOutput(_T("<P><HR><P>\n"));
1578 SetCurrentOutput(Titlepage);
1591 helpRefFilename
= NULL
;
1596 case ltBIBLIOGRAPHY
:
1600 DefaultOnMacro(macroId
, no_args
, start
);
1604 DefaultOnMacro(macroId
, no_args
, start
);
1605 TexOutput(_T("</DL>\n"));
1613 TexOutput(_T("<HR>\n"));
1621 TexOutput(_T("<HR>\n"));
1625 case ltTABLEOFCONTENTS
:
1629 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1635 putc(ch
, Titlepage
);
1642 TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n"));
1643 OnInform(_T("Run Tex2RTF again to include contents page."));
1651 TexOutput(_T("<"));
1657 TexOutput(_T(">"));
1664 TexOutput(_T("<BLOCKQUOTE>"));
1666 TexOutput(_T("</BLOCKQUOTE>"));
1675 TexOutput(_T("\n<CAPTION>"));
1683 if (DocumentStyle
!= LATEX_ARTICLE
)
1684 wxSprintf(figBuf
, _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1686 wxSprintf(figBuf
, _T("%s %d: "), FigureNameString
, figureNo
);
1692 if (DocumentStyle
!= LATEX_ARTICLE
)
1693 wxSprintf(figBuf
, _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1695 wxSprintf(figBuf
, _T("%s %d: "), TableNameString
, tableNo
);
1703 TexOutput(_T("\n</CAPTION>\n"));
1705 wxChar
*topicName
= FindTopicName(GetNextChunk());
1707 int n
= inFigure
? figureNo
: tableNo
;
1709 AddTexRef(topicName
, NULL
, NULL
,
1710 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1711 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1717 if (start
) TexOutput(_T("ß"));
1722 if (start
) inFigure
= TRUE
;
1723 else inFigure
= FALSE
;
1728 if (start
) inTable
= TRUE
;
1729 else inTable
= FALSE
;
1733 DefaultOnMacro(macroId
, no_args
, start
);
1738 // Called on start/end of argument examination
1739 bool HTMLOnArgument(int macroId
, int arg_no
, bool start
)
1745 case ltCHAPTERHEADING
:
1748 case ltSECTIONHEADING
:
1750 case ltSUBSECTIONSTAR
:
1751 case ltSUBSUBSECTION
:
1752 case ltSUBSUBSECTIONSTAR
:
1754 case ltMEMBERSECTION
:
1755 case ltFUNCTIONSECTION
:
1757 if (!start
&& (arg_no
== 1))
1758 currentSection
= GetArgChunk();
1763 if (start
&& (arg_no
== 1))
1764 TexOutput(_T("<B>"));
1766 if (!start
&& (arg_no
== 1))
1767 TexOutput(_T("</B> "));
1769 if (start
&& (arg_no
== 2))
1771 if (!suppressNameDecoration
) TexOutput(_T("<B>"));
1772 currentMember
= GetArgChunk();
1774 if (!start
&& (arg_no
== 2))
1776 if (!suppressNameDecoration
) TexOutput(_T("</B>"));
1779 if (start
&& (arg_no
== 3))
1781 if (!start
&& (arg_no
== 3))
1787 if (start
&& (arg_no
== 1))
1788 TexOutput(_T("<B>"));
1789 if (!start
&& (arg_no
== 1))
1790 TexOutput(_T("</B> "));
1792 if (start
&& (arg_no
== 2))
1794 if (!suppressNameDecoration
) TexOutput(_T("( "));
1795 currentMember
= GetArgChunk();
1797 if (!start
&& (arg_no
== 2))
1801 if (!start
&& (arg_no
== 3))
1807 if (!start
&& (arg_no
== 1))
1810 if (start
&& (arg_no
== 2))
1811 TexOutput(_T("(*"));
1812 if (!start
&& (arg_no
== 2))
1815 if (start
&& (arg_no
== 2))
1816 currentMember
= GetArgChunk();
1818 if (start
&& (arg_no
== 3))
1820 if (!start
&& (arg_no
== 3))
1826 if (start
&& (arg_no
== 1))
1827 TexOutput(_T("<B>"));
1828 if (!start
&& (arg_no
== 1))
1829 TexOutput(_T("</B>"));
1830 if (start
&& (arg_no
== 2))
1832 TexOutput(_T("<I>"));
1834 if (!start
&& (arg_no
== 2))
1836 TexOutput(_T("</I>"));
1842 if (start
&& (arg_no
== 1))
1843 TexOutput(_T("<B>"));
1844 if (!start
&& (arg_no
== 1))
1845 TexOutput(_T("</B> ")); // This is the difference from param - one space!
1846 if (start
&& (arg_no
== 2))
1848 TexOutput(_T("<I>"));
1850 if (!start
&& (arg_no
== 2))
1852 TexOutput(_T("</I>"));
1858 if (!start
&& (arg_no
== 1))
1861 if (start
&& (arg_no
== 2))
1862 currentMember
= GetArgChunk();
1871 wxChar
*refName
= GetArgData();
1874 TexRef
*texRef
= FindReference(refName
);
1877 sec
= texRef
->sectionNumber
;
1890 if (IsArgOptional())
1892 else if ((GetNoArgs() - arg_no
) == 1)
1895 helpRefText
= GetArgChunk();
1898 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1902 TexChunk
*ref
= GetArgChunk();
1903 TexOutput(_T("<A HREF=\""));
1905 TraverseChildrenFromChunk(ref
);
1907 TexOutput(_T("\">"));
1909 TraverseChildrenFromChunk(helpRefText
);
1910 TexOutput(_T("</A>"));
1920 if (IsArgOptional())
1923 helpRefFilename
= GetArgChunk();
1926 if ((GetNoArgs() - arg_no
) == 1)
1929 helpRefText
= GetArgChunk();
1932 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1936 wxChar
*refName
= GetArgData();
1937 wxChar
*refFilename
= NULL
;
1941 TexRef
*texRef
= FindReference(refName
);
1944 if (texRef
->refFile
&& wxStrcmp(texRef
->refFile
, _T("??")) != 0)
1945 refFilename
= texRef
->refFile
;
1947 TexOutput(_T("<A HREF=\""));
1948 // If a filename is supplied, use it, otherwise try to
1949 // use the filename associated with the reference (from this document).
1950 if (helpRefFilename
)
1952 TraverseChildrenFromChunk(helpRefFilename
);
1955 else if (refFilename
)
1957 TexOutput(ConvertCase(refFilename
));
1961 TexOutput(_T("\">"));
1963 TraverseChildrenFromChunk(helpRefText
);
1964 TexOutput(_T("</A>"));
1969 TraverseChildrenFromChunk(helpRefText
);
1971 TexOutput(_T(" (REF NOT FOUND)"));
1973 errBuf
.Printf(_T("Warning: unresolved reference '%s'"), refName
);
1974 OnInform((wxChar
*)errBuf
.c_str());
1977 else TexOutput(_T("??"));
1992 wxChar
*alignment
= _T("");
1993 if (macroId
== ltIMAGEL
)
1994 alignment
= _T(" align=left");
1995 else if (macroId
== ltIMAGER
)
1996 alignment
= _T(" align=right");
1998 // Try to find an XBM or GIF image first.
1999 wxChar
*filename
= copystring(GetArgData());
2002 wxStrcpy(buf
, filename
);
2003 StripExtension(buf
);
2004 wxStrcat(buf
, _T(".xbm"));
2005 wxString f
= TexPathList
.FindValidPath(buf
);
2007 if (f
== _T("")) // Try for a GIF instead
2009 wxStrcpy(buf
, filename
);
2010 StripExtension(buf
);
2011 wxStrcat(buf
, _T(".gif"));
2012 f
= TexPathList
.FindValidPath(buf
);
2015 if (f
== _T("")) // Try for a JPEG instead
2017 wxStrcpy(buf
, filename
);
2018 StripExtension(buf
);
2019 wxStrcat(buf
, _T(".jpg"));
2020 f
= TexPathList
.FindValidPath(buf
);
2023 if (f
== _T("")) // Try for a PNG instead
2025 wxStrcpy(buf
, filename
);
2026 StripExtension(buf
);
2027 wxStrcat(buf
, _T(".png"));
2028 f
= TexPathList
.FindValidPath(buf
);
2033 wxChar
*inlineFilename
= copystring(f
);
2035 wxChar
*originalFilename
= TexPathList
.FindValidPath(filename
);
2036 // If we have found the existing filename, make the inline
2037 // image point to the original file (could be PS, for example)
2038 if (originalFilename
&& (wxStrcmp(inlineFilename
, originalFilename
) != 0))
2040 TexOutput(_T("<A HREF=\""));
2041 TexOutput(ConvertCase(originalFilename
));
2042 TexOutput(_T("\">"));
2043 TexOutput(_T("<img src=\""));
2044 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2045 TexOutput(_T("\""));
2046 TexOutput(alignment
);
2047 TexOutput(_T("></A>"));
2052 TexOutput(_T("<img src=\""));
2053 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2054 TexOutput(_T("\""));
2055 TexOutput(alignment
);
2057 delete[] inlineFilename
;
2062 // Last resort - a link to a PS file.
2063 TexOutput(_T("<A HREF=\""));
2064 TexOutput(ConvertCase(wxFileNameFromPath(filename
)));
2065 TexOutput(_T("\">Picture</A>\n"));
2066 wxSprintf(buf
, _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2073 // First arg is PSBOX spec (ignored), second is image file, third is map name.
2076 static wxChar
*imageFile
= NULL
;
2077 if (start
&& (arg_no
== 2))
2079 // Try to find an XBM or GIF image first.
2080 wxChar
*filename
= copystring(GetArgData());
2083 wxStrcpy(buf
, filename
);
2084 StripExtension(buf
);
2085 wxStrcat(buf
, _T(".xbm"));
2086 wxString f
= TexPathList
.FindValidPath(buf
);
2088 if (f
== _T("")) // Try for a GIF instead
2090 wxStrcpy(buf
, filename
);
2091 StripExtension(buf
);
2092 wxStrcat(buf
, _T(".gif"));
2093 f
= TexPathList
.FindValidPath(buf
);
2098 wxSprintf(buf
, _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2107 imageFile
= copystring(f
);
2110 else if (start
&& (arg_no
== 3))
2114 // First, try to find a .shg (segmented hypergraphics file)
2115 // that we can convert to a map file
2117 wxStrcpy(buf
, imageFile
);
2118 StripExtension(buf
);
2119 wxStrcat(buf
, _T(".shg"));
2120 wxString f
= TexPathList
.FindValidPath(buf
);
2124 // The default HTML file to go to is THIS file (so a no-op)
2125 SHGToMap((wxChar
*)f
.c_str(), currentFileName
);
2128 wxChar
*mapName
= GetArgData();
2129 TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/"));
2133 TexOutput(_T("unknown"));
2134 TexOutput(_T("\">"));
2135 TexOutput(_T("<img src=\""));
2136 TexOutput(ConvertCase(wxFileNameFromPath(imageFile
)));
2137 TexOutput(_T("\" ISMAP></A><P>"));
2157 descriptionItemArg
= GetArgChunk();
2163 case ltTWOCOLITEMRULED
:
2166 if (start && (arg_no == 1))
2167 TexOutput(_T("\n<DT> "));
2168 if (start && (arg_no == 2))
2169 TexOutput(_T("<DD> "));
2175 if (TwoColWidthA
> -1) {
2177 wxSprintf(buf
,_T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA
);
2180 TexOutput(_T("\n<TR><TD VALIGN=TOP>\n"));
2183 TexOutput(_T("\n</FONT></TD>\n"));
2189 if (TwoColWidthB
> -1) {
2191 wxSprintf(buf
,_T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB
);
2194 TexOutput(_T("\n<TD VALIGN=TOP>\n"));
2197 TexOutput(_T("\n</FONT></TD></TR>\n"));
2201 case ltNUMBEREDBIBITEM
:
2203 if (arg_no
== 1 && start
)
2205 TexOutput(_T("\n<DT> "));
2207 if (arg_no
== 2 && !start
)
2208 TexOutput(_T("<P>\n"));
2214 if (arg_no
== 1 && start
)
2216 wxChar
*citeKey
= GetArgData();
2217 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
2220 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
2221 wxSprintf(buf
, _T("[%d]"), citeCount
);
2222 ref
->sectionNumber
= copystring(buf
);
2225 wxSprintf(buf
, _T("\n<DT> [%d] "), citeCount
);
2230 if (arg_no
== 2 && !start
)
2231 TexOutput(_T("<P>\n"));
2235 case ltMARGINPARODD
:
2236 case ltMARGINPAREVEN
:
2242 TexOutput(_T("<HR>\n"));
2246 TexOutput(_T("<HR><P>\n"));
2250 case ltTWOCOLWIDTHA
:
2254 wxChar
*val
= GetArgData();
2255 float points
= ParseUnitArgument(val
);
2256 TwoColWidthA
= (int)((points
* 100.0) / 72.0);
2261 case ltTWOCOLWIDTHB
:
2265 wxChar
*val
= GetArgData();
2266 float points
= ParseUnitArgument(val
);
2267 TwoColWidthB
= (int)((points
* 100.0) / 72.0);
2275 case ltACCENT_GRAVE
:
2279 wxChar
*val
= GetArgData();
2285 TexOutput(_T("à"));
2288 TexOutput(_T("è"));
2291 TexOutput(_T("ì"));
2294 TexOutput(_T("ò"));
2297 TexOutput(_T("ù"));
2300 TexOutput(_T("À"));
2303 TexOutput(_T("È"));
2306 TexOutput(_T("Ì"));
2309 TexOutput(_T("Ò"));
2312 TexOutput(_T("Ì"));
2321 case ltACCENT_ACUTE
:
2325 wxChar
*val
= GetArgData();
2331 TexOutput(_T("á"));
2334 TexOutput(_T("é"));
2337 TexOutput(_T("í"));
2340 TexOutput(_T("ó"));
2343 TexOutput(_T("ú"));
2346 TexOutput(_T("ý"));
2349 TexOutput(_T("Á"));
2352 TexOutput(_T("É"));
2355 TexOutput(_T("Í"));
2358 TexOutput(_T("Ó"));
2361 TexOutput(_T("Ú"));
2364 TexOutput(_T("Ý"));
2373 case ltACCENT_CARET
:
2377 wxChar
*val
= GetArgData();
2383 TexOutput(_T("â"));
2386 TexOutput(_T("ê"));
2389 TexOutput(_T("î"));
2392 TexOutput(_T("ô"));
2395 TexOutput(_T("û"));
2398 TexOutput(_T("Â"));
2401 TexOutput(_T("Ê"));
2404 TexOutput(_T("Î"));
2407 TexOutput(_T("Ô"));
2410 TexOutput(_T("Î"));
2419 case ltACCENT_TILDE
:
2423 wxChar
*val
= GetArgData();
2432 TexOutput(_T("ã"));
2435 TexOutput(_T("ñ"));
2438 TexOutput(_T("õ"));
2441 TexOutput(_T("Ã"));
2444 TexOutput(_T("Ñ"));
2447 TexOutput(_T("Õ"));
2456 case ltACCENT_UMLAUT
:
2460 wxChar
*val
= GetArgData();
2466 TexOutput(_T("ä"));
2469 TexOutput(_T("ë"));
2472 TexOutput(_T("ï"));
2475 TexOutput(_T("ö"));
2478 TexOutput(_T("ü"));
2481 TexOutput(_T("ÿ"));
2484 TexOutput(_T("Ä"));
2487 TexOutput(_T("Ë"));
2490 TexOutput(_T("Ï"));
2493 TexOutput(_T("Ö"));
2496 TexOutput(_T("Ü"));
2499 TexOutput(_T("Ÿ"));
2512 wxChar
*val
= GetArgData();
2518 TexOutput(_T("å"));
2521 TexOutput(_T("Å"));
2534 wxChar
*val
= GetArgData();
2537 bool isPicture
= FALSE
;
2538 ParseColourString(val
, &isPicture
);
2541 if (backgroundImageString
)
2542 delete[] backgroundImageString
;
2543 backgroundImageString
= copystring(val
);
2547 if (backgroundColourString
)
2548 delete[] backgroundColourString
;
2549 backgroundColourString
= copystring(val
);
2555 case ltBACKGROUNDIMAGE
:
2559 wxChar
*val
= GetArgData();
2562 if (backgroundImageString
)
2563 delete[] backgroundImageString
;
2564 backgroundImageString
= copystring(val
);
2569 case ltBACKGROUNDCOLOUR
:
2573 wxChar
*val
= GetArgData();
2576 if (backgroundColourString
)
2577 delete[] backgroundColourString
;
2578 backgroundColourString
= copystring(val
);
2587 wxChar
*val
= GetArgData();
2590 if (textColourString
)
2591 delete[] textColourString
;
2592 textColourString
= copystring(val
);
2601 wxChar
*val
= GetArgData();
2604 if (linkColourString
)
2605 delete[] linkColourString
;
2606 linkColourString
= copystring(val
);
2611 case ltFOLLOWEDLINKCOLOUR
:
2615 wxChar
*val
= GetArgData();
2618 if (followedLinkColourString
)
2619 delete[] followedLinkColourString
;
2620 followedLinkColourString
= copystring(val
);
2625 case ltACCENT_CADILLA
:
2629 wxChar
*val
= GetArgData();
2635 TexOutput(_T("ç"));
2638 TexOutput(_T("Ç"));
2649 case ltFOOTNOTEPOPUP:
2659 case ltSUPERTABULAR
:
2665 currentRowNumber
= 0;
2668 tableVerticalLineLeft
= FALSE
;
2669 tableVerticalLineRight
= FALSE
;
2671 wxChar
*alignString
= copystring(GetArgData());
2672 ParseTableArgument(alignString
);
2674 TexOutput(_T("<TABLE BORDER>\n"));
2676 // Write the first row formatting for compatibility
2677 // with standard Latex
2678 if (compatibilityMode
)
2680 TexOutput(_T("<TR>\n<TD>"));
2683 for (int i = 0; i < noColumns; i++)
2685 currentWidth += TableData[i].width;
2686 wxSprintf(buf, _T("\\cellx%d"), currentWidth);
2689 TexOutput(_T("\\pard\\intbl\n"));
2692 delete[] alignString
;
2697 else if (arg_no
== 2 && !start
)
2699 TexOutput(_T("</TABLE>\n"));
2704 case ltTHEBIBLIOGRAPHY
:
2706 if (start
&& (arg_no
== 1))
2708 ReopenFile(&Chapters
, &ChaptersName
, _T("bibliography"));
2709 AddTexRef(_T("bibliography"), ChaptersName
, _T("bibliography"));
2710 SetCurrentSubsectionName(_T("bibliography"), ChaptersName
);
2714 SetCurrentOutput(Chapters
);
2716 wxChar titleBuf
[150];
2717 if (truncateFilenames
)
2718 wxSprintf(titleBuf
, _T("%s.htm"), wxFileNameFromPath(FileRoot
));
2720 wxSprintf(titleBuf
, _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
2723 TexOutput(_T("<title>"));
2724 TexOutput(ReferencesNameString
);
2725 TexOutput(_T("</title></head>\n"));
2728 wxFprintf(Chapters
, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString
);
2729 AddBrowseButtons(_T("contents"), titleBuf
, // Up
2730 lastTopic
, lastFileName
, // Last topic
2731 _T("bibliography"), ChaptersName
); // This topic
2733 SetCurrentOutputs(Contents
, Chapters
);
2734 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), "bibliography");
2736 wxFprintf(Contents
, _T("%s</A>\n"), ReferencesNameString
);
2737 wxFprintf(Chapters
, _T("</H2>\n</A>\n"));
2739 SetCurrentOutput(Chapters
);
2742 if (!start
&& (arg_no
== 2))
2749 /* Build up list of keywords associated with topics */
2752 // wxChar *entry = GetArgData();
2754 OutputChunkToString(GetArgChunk(), buf
);
2757 AddKeyWordForTopic(CurrentTopic
, buf
, currentFileName
);
2771 wxChar
*name
= GetArgData();
2773 if (!FindColourHTMLString(name
, buf2
))
2775 wxStrcpy(buf2
, _T("#000000"));
2777 wxSprintf(buf
, _T("Could not find colour name %s"), name
);
2780 TexOutput(_T("<FONT COLOR=\""));
2782 TexOutput(_T("\">"));
2795 if (arg_no
== 2) TexOutput(_T("</FONT>"));
2799 case ltINSERTATLEVEL
:
2801 // This macro allows you to insert text at a different level
2802 // from the current level, e.g. into the Sections from within a subsubsection.
2805 static int currentLevelNo
= 1;
2806 static FILE* oldLevelFile
= Chapters
;
2813 oldLevelFile
= CurrentOutput1
;
2815 wxChar
*str
= GetArgData();
2816 currentLevelNo
= wxAtoi(str
);
2818 // TODO: cope with article style (no chapters)
2819 switch (currentLevelNo
)
2823 outputFile
= Chapters
;
2828 outputFile
= Sections
;
2833 outputFile
= Subsections
;
2838 outputFile
= Subsubsections
;
2848 CurrentOutput1
= outputFile
;
2864 CurrentOutput1
= oldLevelFile
;
2870 return DefaultOnArgument(macroId
, arg_no
, start
);
2882 tableVerticalLineLeft
= FALSE
;
2883 tableVerticalLineRight
= FALSE
;
2886 if (InputFile
&& OutputFile
)
2888 // Do some HTML-specific transformations on all the strings,
2890 Text2HTML(GetTopLevelChunk());
2893 if (truncateFilenames
)
2894 wxSprintf(buf
, _T("%s.htm"), FileRoot
);
2896 wxSprintf(buf
, _T("%s_contents.html"), FileRoot
);
2897 if (TitlepageName
) delete[] TitlepageName
;
2898 TitlepageName
= copystring(buf
);
2899 Titlepage
= wxFopen(buf
, _T("w"));
2901 if (truncateFilenames
)
2902 wxSprintf(buf
, _T("%s_fc.htm"), FileRoot
);
2904 wxSprintf(buf
, _T("%s_fcontents.html"), FileRoot
);
2906 contentsFrameName
= copystring(buf
);
2908 Contents
= wxFopen(TmpContentsName
, _T("w"));
2910 if (htmlFrameContents
)
2912 // FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
2913 FrameContents
= wxFopen(contentsFrameName
, _T("w"));
2914 wxFprintf(FrameContents
, _T("<HTML>\n<UL>\n"));
2917 if (!Titlepage
|| !Contents
)
2919 OnError(_T("Cannot open output file!"));
2922 AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName
), ContentsNameString
);
2924 wxFprintf(Contents
, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString
);
2926 wxFprintf(Contents
, _T("<UL>\n"));
2928 SetCurrentOutput(Titlepage
);
2929 if (htmlWorkshopFiles
) HTMLWorkshopStartContents();
2930 OnInform(_T("Converting..."));
2933 wxFprintf(Contents
, _T("</UL>\n\n"));
2935 // SetCurrentOutput(Titlepage);
2940 // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
2947 wxFprintf(FrameContents
, _T("\n</UL>\n"));
2948 wxFprintf(FrameContents
, _T("</HTML>\n"));
2949 fclose(FrameContents
);
2950 FrameContents
= NULL
;
2955 wxFprintf(Chapters
, _T("\n</FONT></BODY></HTML>\n"));
2961 wxFprintf(Sections
, _T("\n</FONT></BODY></HTML>\n"));
2965 if (Subsections
&& !combineSubSections
)
2967 wxFprintf(Subsections
, _T("\n</FONT></BODY></HTML>\n"));
2968 fclose(Subsections
);
2971 if (Subsubsections
&& !combineSubSections
)
2973 wxFprintf(Subsubsections
, _T("\n</FONT></BODY></HTML>\n"));
2974 fclose(Subsubsections
);
2975 Subsubsections
= NULL
;
2977 if ( SectionContentsFD
)
2979 fclose(SectionContentsFD
);
2980 SectionContentsFD
= NULL
;
2983 // Create a temporary file for the title page header, add some info,
2984 // and concat the titlepage just generated.
2985 // This is necessary in order to put the title of the document
2986 // at the TOP of the file within <HEAD>, even though we only find out
2987 // what it is later on.
2988 FILE *tmpTitle
= wxFopen(_T("title.tmp"), _T("w"));
2993 SetCurrentOutput(tmpTitle
);
2995 TexOutput(_T("\n<HEAD><TITLE>"));
2996 TraverseChildrenFromChunk(DocumentTitle
);
2997 TexOutput(_T("</TITLE></HEAD>\n"));
3001 SetCurrentOutput(tmpTitle
);
3002 HTMLHeadTo(tmpTitle
);
3004 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString
);
3006 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot
));
3009 // Output frame information
3010 if (htmlFrameContents
)
3012 wxChar firstFileName
[300];
3013 if (truncateFilenames
)
3014 wxSprintf(firstFileName
, _T("%s1.htm"), FileRoot
);
3016 wxStrcpy(firstFileName
, gs_filenames
[1].c_str());
3018 wxFprintf(tmpTitle
, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
3020 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName
)));
3021 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName
)));
3022 wxFprintf(tmpTitle
, _T("</FRAMESET>\n"));
3024 wxFprintf(tmpTitle
, _T("<NOFRAMES>\n"));
3027 // Output <BODY...> to temporary title page
3031 FILE *fd
= wxFopen(TitlepageName
, _T("r"));
3043 wxFprintf(tmpTitle
, _T("\n</FONT></BODY>\n"));
3045 if (htmlFrameContents
)
3047 wxFprintf(tmpTitle
, _T("\n</NOFRAMES>\n"));
3049 wxFprintf(tmpTitle
, _T("\n</HTML>\n"));
3052 if (wxFileExists(TitlepageName
)) wxRemoveFile(TitlepageName
);
3053 if (!wxRenameFile(_T("title.tmp"), TitlepageName
))
3055 wxCopyFile(_T("title.tmp"), TitlepageName
);
3056 wxRemoveFile(_T("title.tmp"));
3060 if (lastFileName
) delete[] lastFileName
;
3061 lastFileName
= NULL
;
3062 if (lastTopic
) delete[] lastTopic
;
3065 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
3067 if (!wxRenameFile(TmpContentsName
, ContentsName
))
3069 wxCopyFile(TmpContentsName
, ContentsName
);
3070 wxRemoveFile(TmpContentsName
);
3073 // Generate .htx file if requested
3076 wxChar htmlIndexName
[300];
3077 wxSprintf(htmlIndexName
, _T("%s.htx"), FileRoot
);
3078 GenerateHTMLIndexFile(htmlIndexName
);
3081 // Generate HTML Help Workshop files if requested
3082 if (htmlWorkshopFiles
)
3084 HTMLWorkshopEndContents();
3085 GenerateHTMLWorkshopFiles(FileRoot
);
3095 // Output .htx index file
3096 void GenerateHTMLIndexFile(wxChar
*fname
)
3098 FILE *fd
= wxFopen(fname
, _T("w"));
3102 TopicTable
.BeginFind();
3103 wxNode
*node
= TopicTable
.Next();
3106 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3107 const wxChar
*topicName
= node
->GetKeyString();
3108 if (texTopic
->filename
&& texTopic
->keywords
)
3110 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3113 wxChar
*s
= (wxChar
*)node1
->GetData();
3114 wxFprintf(fd
, _T("%s|%s|%s\n"), topicName
, texTopic
->filename
, s
);
3115 node1
= node1
->GetNext();
3118 node
= TopicTable
.Next();
3129 // output .hpp, .hhc and .hhk files:
3132 void GenerateHTMLWorkshopFiles(wxChar
*fname
)
3137 /* Generate project file : */
3139 wxSprintf(buf
, _T("%s.hhp"), fname
);
3140 f
= wxFopen(buf
, _T("wt"));
3143 _T("Compatibility=1.1\n")
3144 _T("Full-text search=Yes\n")
3145 _T("Contents file=%s.hhc\n")
3146 _T("Compiled file=%s.chm\n")
3147 _T("Default Window=%sHelp\n")
3148 _T("Default topic=%s\n")
3149 _T("Index file=%s.hhk\n")
3151 wxFileNameFromPath(fname
),
3152 wxFileNameFromPath(fname
),
3153 wxFileNameFromPath(fname
),
3154 wxFileNameFromPath(TitlepageName
),
3155 wxFileNameFromPath(fname
)
3158 if (DocumentTitle
) {
3159 SetCurrentOutput(f
);
3160 TraverseChildrenFromChunk(DocumentTitle
);
3162 else wxFprintf(f
, _T("(unknown)"));
3164 wxFprintf(f
, _T("\n\n[WINDOWS]\n")
3165 _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"),
3166 wxFileNameFromPath(fname
),
3167 wxFileNameFromPath(fname
),
3168 wxFileNameFromPath(fname
),
3169 wxFileNameFromPath(TitlepageName
));
3172 wxFprintf(f
, _T("\n\n[FILES]\n"));
3173 wxFprintf(f
, _T("%s\n"), wxFileNameFromPath(TitlepageName
));
3174 for (int i
= 1; i
<= fileId
; i
++) {
3175 if (truncateFilenames
)
3176 wxSprintf(buf
, _T("%s%d.htm"), wxFileNameFromPath(FileRoot
), i
);
3178 wxStrcpy(buf
, wxFileNameFromPath(gs_filenames
[i
].c_str()));
3179 wxFprintf(f
, _T("%s\n"), buf
);
3183 /* Generate index file : */
3185 wxSprintf(buf
, _T("%s.hhk"), fname
);
3186 f
= wxFopen(buf
, _T("wt"));
3189 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3194 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3195 _T("<!-- Sitemap 1.0 -->\n")
3196 _T("</HEAD><BODY>\n")
3197 _T("<OBJECT type=\"text/site properties\">\n")
3198 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3202 TopicTable
.BeginFind();
3203 wxNode
*node
= TopicTable
.Next();
3206 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3207 const wxChar
*topicName
= node
->GetKeyString();
3208 if (texTopic
->filename
&& texTopic
->keywords
)
3210 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3213 wxChar
*s
= (wxChar
*)node1
->GetData();
3215 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3216 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3217 _T(" <param name=\"Name\" value=\"%s\">\n")
3219 texTopic
->filename
, topicName
, s
);
3220 node1
= node1
->GetNext();
3223 node
= TopicTable
.Next();
3226 wxFprintf(f
, _T("</UL>\n"));
3232 static FILE *HTMLWorkshopContents
= NULL
;
3233 static int HTMLWorkshopLastLevel
= 0;
3235 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
)
3239 if (level
> HTMLWorkshopLastLevel
)
3240 for (i
= HTMLWorkshopLastLevel
; i
< level
; i
++)
3241 wxFprintf(HTMLWorkshopContents
, _T("<UL>"));
3242 if (level
< HTMLWorkshopLastLevel
)
3243 for (i
= level
; i
< HTMLWorkshopLastLevel
; i
++)
3244 wxFprintf(HTMLWorkshopContents
, _T("</UL>"));
3246 SetCurrentOutput(HTMLWorkshopContents
);
3247 wxFprintf(HTMLWorkshopContents
,
3248 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3249 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3250 _T(" <param name=\"Name\" value=\""),
3252 OutputCurrentSection();
3253 wxFprintf(HTMLWorkshopContents
,
3255 _T(" </OBJECT>\n"));
3256 HTMLWorkshopLastLevel
= level
;
3260 void HTMLWorkshopStartContents()
3263 wxSprintf(buf
, _T("%s.hhc"), FileRoot
);
3264 HTMLWorkshopContents
= wxFopen(buf
, _T("wt"));
3265 HTMLWorkshopLastLevel
= 0;
3267 wxFprintf(HTMLWorkshopContents
,
3268 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3270 HTMLHeadTo(HTMLWorkshopContents
);
3271 wxFprintf(HTMLWorkshopContents
,
3273 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3274 _T("<!-- Sitemap 1.0 -->\n")
3275 _T("</HEAD><BODY>\n")
3276 _T("<OBJECT type=\"text/site properties\">\n")
3277 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3280 _T("<LI> <OBJECT type=\"text/sitemap\">\n")
3281 _T("<param name=\"Local\" value=\"%s\">\n")
3282 _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"),
3283 wxFileNameFromPath(TitlepageName
)
3289 void HTMLWorkshopEndContents()
3291 for (int i
= HTMLWorkshopLastLevel
; i
>= 0; i
--)
3292 wxFprintf(HTMLWorkshopContents
, _T("</UL>\n"));
3293 fclose(HTMLWorkshopContents
);