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
);
206 gs_filenames
.Add(wxEmptyString
);
207 wxSprintf(buf
, _T("%s_%s.html"), FileRoot
, label
);
208 gs_filenames
.Add(buf
);
210 if (*fileName
) delete[] *fileName
;
211 *fileName
= copystring(wxFileNameFromPath(buf
));
212 *fd
= wxFopen(buf
, _T("w"));
213 wxFprintf(*fd
, _T("<HTML>\n"));
217 * Reopen section contents file, i.e. the index appended to each section
218 * in subsectionCombine mode
221 static wxChar
*SectionContentsFilename
= NULL
;
222 static FILE *SectionContentsFD
= NULL
;
224 void ReopenSectionContentsFile(void)
226 if ( SectionContentsFD
)
228 fclose(SectionContentsFD
);
230 if ( SectionContentsFilename
)
231 delete[] SectionContentsFilename
;
232 SectionContentsFD
= NULL
;
233 SectionContentsFilename
= NULL
;
235 // Create the name from the current section filename
236 if ( CurrentSectionFile
)
239 wxStrcpy(buf
, CurrentSectionFile
);
240 wxStripExtension(buf
);
241 wxStrcat(buf
, _T(".con"));
242 SectionContentsFilename
= copystring(buf
);
244 SectionContentsFD
= wxFopen(SectionContentsFilename
, _T("w"));
250 * Given a TexChunk with a string value, scans through the string
251 * converting Latex-isms into HTML-isms, such as 2 newlines -> <P>.
255 void ProcessText2HTML(TexChunk
*chunk
)
257 bool changed
= FALSE
;
261 int len
= wxStrlen(chunk
->value
);
264 ch
= chunk
->value
[i
];
266 // 2 newlines means \par
267 if (!inVerbatim
&& chunk
->value
[i
] == 10 && ((len
> i
+1 && chunk
->value
[i
+1] == 10) ||
268 ((len
> i
+1 && chunk
->value
[i
+1] == 13) &&
269 (len
> i
+2 && chunk
->value
[i
+2] == 10))))
271 BigBuffer
[ptr
] = 0; wxStrcat(BigBuffer
, _T("<P>\n\n")); ptr
+= 5;
275 else if (!inVerbatim
&& ch
== '`' && (len
>= i
+1 && chunk
->value
[i
+1] == '`'))
277 BigBuffer
[ptr
] = '"'; ptr
++;
281 else if (!inVerbatim
&& ch
== '`') // Change ` to '
283 BigBuffer
[ptr
] = 39; ptr
++;
287 else if (ch
== '<') // Change < to <
290 wxStrcat(BigBuffer
, _T("<"));
295 else if (ch
== '>') // Change > to >
298 wxStrcat(BigBuffer
, _T(">"));
315 chunk
->value
= copystring(BigBuffer
);
320 * Scan through all chunks starting from the given one,
321 * calling ProcessText2HTML to convert Latex-isms to RTF-isms.
322 * This should be called after Tex2Any has parsed the file,
323 * and before TraverseDocument is called.
327 void Text2HTML(TexChunk
*chunk
)
330 if (stopRunning
) return;
334 case CHUNK_TYPE_MACRO
:
336 TexMacroDef
*def
= chunk
->def
;
338 if (def
&& def
->ignore
)
341 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
344 wxNode
*node
= chunk
->children
.GetFirst();
347 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
348 Text2HTML(child_chunk
);
349 node
= node
->GetNext();
352 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
359 wxNode
*node
= chunk
->children
.GetFirst();
362 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
363 Text2HTML(child_chunk
);
364 node
= node
->GetNext();
369 case CHUNK_TYPE_STRING
:
372 ProcessText2HTML(chunk
);
379 * Add appropriate browse buttons to this page.
383 void AddBrowseButtons(wxChar
*upLabel
, wxChar
*upFilename
,
384 wxChar
*previousLabel
, wxChar
*previousFilename
,
385 wxChar
*thisLabel
, wxChar
*thisFilename
)
387 wxChar contentsReferenceBuf
[80];
388 wxChar upReferenceBuf
[80];
389 wxChar backReferenceBuf
[80];
390 wxChar forwardReferenceBuf
[80];
391 if (htmlBrowseButtons
== HTML_BUTTONS_NONE
)
394 wxChar
*contentsReference
; // no need to initialize because always assigned below
395 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
396 contentsReference
= ContentsNameString
;
399 // contentsReference = "<img align=center src=\"contents.gif\" BORDER=0 ALT=\"Contents\">";
400 contentsReference
= contentsReferenceBuf
;
401 wxSprintf(contentsReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">"), ConvertCase(_T("contents.gif")));
404 wxChar
*upReference
; // no need to initialize because always assigned below
405 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
406 upReference
= UpNameString
;
409 // upReference = "<img align=center src=\"up.gif\" ALT=\"Up\">";
410 upReference
= upReferenceBuf
;
411 wxSprintf(upReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">"), ConvertCase(_T("up.gif")));
414 wxChar
*backReference
; // no need to initialize because always assigned below
415 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
416 backReference
= _T("<<");
419 // backReference = "<img align=center src=\"back.gif\" ALT=\"Previous\">";
420 backReference
= backReferenceBuf
;
421 wxSprintf(backReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">"), ConvertCase(_T("back.gif")));
424 wxChar
*forwardReference
; // no need to initialize because always assigned below
425 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
426 forwardReference
= _T(">>");
429 // forwardReference = "<img align=center src=\"forward.gif\" ALT=\"Next\">";
430 forwardReference
= forwardReferenceBuf
;
431 wxSprintf(forwardReference
, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">"), ConvertCase(_T("forward.gif")));
434 TexOutput(_T("<CENTER>"));
443 if (truncateFilenames
)
446 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
447 wxSprintf(buf
, _T("\n<A HREF=\"%s.%s\">%s</A> "), buf1
, ConvertCase(_T("htm")), contentsReference
);
452 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
453 wxSprintf(buf
, _T("\n<A HREF=\"%s%s\">%s</A> "), buf1
, ConvertCase(_T("_contents.html")), contentsReference
);
455 // TexOutput(_T("<NOFRAMES>"));
457 // TexOutput(_T("</NOFRAMES>"));
464 if (upLabel
&& upFilename
)
466 if (wxStrlen(upLabel
) > 0)
467 wxSprintf(buf
, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(upFilename
), upLabel
, upReference
);
469 wxSprintf(buf
, _T("<A HREF=\"%s\">%s</A> "), ConvertCase(upFilename
), upReference
);
470 if (wxStrcmp(upLabel
, _T("contents")) == 0)
472 // TexOutput(_T("<NOFRAMES>"));
474 // TexOutput(_T("</NOFRAMES>"));
485 if (previousLabel
&& previousFilename
)
487 wxSprintf(buf
, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(previousFilename
), previousLabel
, backReference
);
488 if (wxStrcmp(previousLabel
, _T("contents")) == 0)
490 // TexOutput(_T("<NOFRAMES>"));
492 // TexOutput(_T("</NOFRAMES>"));
499 // A placeholder so the buttons don't keep moving position
500 wxSprintf(buf
, _T("%s "), backReference
);
504 wxChar
*nextLabel
= NULL
;
505 wxChar
*nextFilename
= NULL
;
507 // Get the next page, and record the previous page's 'next' page
509 TexNextPage
*nextPage
= (TexNextPage
*)TexNextPages
.Get(thisLabel
);
512 nextLabel
= nextPage
->label
;
513 nextFilename
= nextPage
->filename
;
515 if (previousLabel
&& previousFilename
)
517 TexNextPage
*oldNextPage
= (TexNextPage
*)TexNextPages
.Get(previousLabel
);
521 TexNextPages
.Delete(previousLabel
);
523 TexNextPage
*newNextPage
= new TexNextPage(thisLabel
, thisFilename
);
524 TexNextPages
.Put(previousLabel
, newNextPage
);
532 if (nextLabel
&& nextFilename
)
534 wxSprintf(buf
, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(nextFilename
), nextLabel
, forwardReference
);
539 // A placeholder so the buttons don't keep moving position
540 wxSprintf(buf
, _T("%s "), forwardReference
);
545 * Horizontal rule to finish it off nicely.
548 TexOutput(_T("</CENTER>"));
549 TexOutput(_T("<HR>\n"));
551 // Update last topic/filename
553 delete[] lastFileName
;
554 lastFileName
= copystring(thisFilename
);
557 lastTopic
= copystring(thisLabel
);
560 // A colour string is either 3 numbers separated by semicolons (RGB),
561 // or a reference to a GIF. Return the filename or a hex string like #934CE8
562 wxChar
*ParseColourString(wxChar
*bkStr
, bool *isPicture
)
564 static wxChar resStr
[300];
565 wxStrcpy(resStr
, bkStr
);
566 wxStringTokenizer
tok(resStr
, _T(";"), wxTOKEN_STRTOK
);
567 if (tok
.HasMoreTokens())
569 wxString token1
= tok
.GetNextToken();
570 if (!tok
.HasMoreTokens())
577 wxString token2
= tok
.GetNextToken();
579 if (tok
.HasMoreTokens())
581 wxString token3
= tok
.GetNextToken();
583 // Now convert 3 strings into decimal numbers, and then hex numbers.
584 int red
= wxAtoi(token1
.c_str());
585 int green
= wxAtoi(token2
.c_str());
586 int blue
= wxAtoi(token3
.c_str());
588 wxStrcpy(resStr
, _T("#"));
592 wxStrcat(resStr
, buf
);
593 DecToHex(green
, buf
);
594 wxStrcat(resStr
, buf
);
596 wxStrcat(resStr
, buf
);
605 void OutputFont(void)
607 // Only output <font face> if explicitly requested by htmlFaceName= directive in
608 // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's
612 // Output <FONT FACE=...>
613 TexOutput(_T("<FONT FACE=\""));
614 TexOutput(htmlFaceName
);
615 TexOutput(_T("\">\n"));
619 // Output start of <BODY> block
620 void OutputBodyStart(void)
622 TexOutput(_T("\n<BODY"));
623 if (backgroundImageString
)
625 bool isPicture
= FALSE
;
626 wxChar
*s
= ParseColourString(backgroundImageString
, &isPicture
);
629 TexOutput(_T(" BACKGROUND=\""));
634 if (backgroundColourString
)
636 bool isPicture
= FALSE
;
637 wxChar
*s
= ParseColourString(backgroundColourString
, &isPicture
);
640 TexOutput(_T(" BGCOLOR="));
645 // Set foreground text colour, if one is specified
646 if (textColourString
)
648 bool isPicture
= FALSE
;
649 wxChar
*s
= ParseColourString(textColourString
, &isPicture
);
652 TexOutput(_T(" TEXT=")); TexOutput(s
);
655 // Set link text colour, if one is specified
656 if (linkColourString
)
658 bool isPicture
= FALSE
;
659 wxChar
*s
= ParseColourString(linkColourString
, &isPicture
);
662 TexOutput(_T(" LINK=")); TexOutput(s
);
665 // Set followed link text colour, if one is specified
666 if (followedLinkColourString
)
668 bool isPicture
= FALSE
;
669 wxChar
*s
= ParseColourString(followedLinkColourString
, &isPicture
);
672 TexOutput(_T(" VLINK=")); TexOutput(s
);
675 TexOutput(_T(">\n"));
682 TexOutput(_T("<head>"));
683 if (htmlStylesheet
) {
684 TexOutput(_T("<link rel=stylesheet type=\"text/css\" href=\""));
685 TexOutput(htmlStylesheet
);
686 TexOutput(_T("\">"));
690 void HTMLHeadTo(FILE* f
)
693 wxFprintf(f
,_T("<head><link rel=stylesheet type=\"text/css\" href=\"%s\">"),htmlStylesheet
);
695 wxFprintf(f
,_T("<head>"));
698 // Called on start/end of macro examination
699 void HTMLOnMacro(int macroId
, int no_args
, bool start
)
705 case ltCHAPTERHEADING
:
713 if (macroId
!= ltCHAPTERSTAR
)
716 SetCurrentOutput(NULL
);
717 startedSections
= TRUE
;
719 wxChar
*topicName
= FindTopicName(GetNextChunk());
720 ReopenFile(&Chapters
, &ChaptersName
, topicName
);
721 AddTexRef(topicName
, ChaptersName
, ChapterNameString
);
723 SetCurrentChapterName(topicName
, ChaptersName
);
724 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(0, topicName
, ChaptersName
);
726 SetCurrentOutput(Chapters
);
729 TexOutput(_T("<title>"));
730 OutputCurrentSection(); // Repeat section header
731 TexOutput(_T("</title></head>\n"));
734 wxChar titleBuf
[200];
735 if (truncateFilenames
)
736 wxSprintf(titleBuf
, _T("%s.htm"), wxFileNameFromPath(FileRoot
));
738 wxSprintf(titleBuf
, _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
740 wxFprintf(Chapters
, _T("<A NAME=\"%s\"></A>"), topicName
);
742 AddBrowseButtons(_T(""), titleBuf
, // Up
743 lastTopic
, lastFileName
, // Last topic
744 topicName
, ChaptersName
); // This topic
746 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), topicName
);
748 if (htmlFrameContents
&& FrameContents
)
750 SetCurrentOutput(FrameContents
);
751 wxFprintf(FrameContents
, _T("\n<LI><A HREF=\"%s#%s\" TARGET=\"mainwindow\">"), ConvertCase(ChaptersName
), topicName
);
752 OutputCurrentSection();
753 wxFprintf(FrameContents
, _T("</A>\n"));
756 SetCurrentOutputs(Contents
, Chapters
);
757 wxFprintf(Chapters
, _T("\n<H2>"));
758 OutputCurrentSection();
759 wxFprintf(Contents
, _T("</A>\n"));
760 wxFprintf(Chapters
, _T("</H2>\n"));
762 SetCurrentOutput(Chapters
);
764 // Add this section title to the list of keywords
767 OutputCurrentSectionToString(wxTex2RTFBuffer
);
768 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, ConvertCase(currentFileName
));
775 case ltSECTIONHEADING
:
782 subsectionStarted
= FALSE
;
784 if (macroId
!= ltSECTIONSTAR
)
787 SetCurrentOutput(NULL
);
788 startedSections
= TRUE
;
790 wxChar
*topicName
= FindTopicName(GetNextChunk());
791 ReopenFile(&Sections
, &SectionsName
, topicName
);
792 AddTexRef(topicName
, SectionsName
, SectionNameString
);
794 SetCurrentSectionName(topicName
, SectionsName
);
795 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(1, topicName
, SectionsName
);
797 SetCurrentOutput(Sections
);
799 TexOutput(_T("<title>"));
800 OutputCurrentSection();
801 TexOutput(_T("</title></head>\n"));
804 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
805 AddBrowseButtons(CurrentChapterName
, CurrentChapterFile
, // Up
806 lastTopic
, lastFileName
, // Last topic
807 topicName
, SectionsName
); // This topic
809 FILE *jumpFrom
= ((DocumentStyle
== LATEX_ARTICLE
) ? Contents
: Chapters
);
811 SetCurrentOutputs(jumpFrom
, Sections
);
812 if (DocumentStyle
== LATEX_ARTICLE
)
813 wxFprintf(jumpFrom
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(SectionsName
), topicName
);
815 wxFprintf(jumpFrom
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SectionsName
), topicName
);
817 wxFprintf(Sections
, _T("\n<H2>"));
818 OutputCurrentSection();
820 if (DocumentStyle
== LATEX_ARTICLE
)
821 wxFprintf(jumpFrom
, _T("</A>\n"));
823 wxFprintf(jumpFrom
, _T("</B></A><BR>\n"));
824 wxFprintf(Sections
, _T("</H2>\n"));
826 SetCurrentOutput(Sections
);
827 // Add this section title to the list of keywords
830 OutputCurrentSectionToString(wxTex2RTFBuffer
);
831 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
837 case ltSUBSECTIONSTAR
:
838 case ltMEMBERSECTION
:
839 case ltFUNCTIONSECTION
:
845 OnError(_T("You cannot have a subsection before a section!"));
851 if (macroId
!= ltSUBSECTIONSTAR
)
854 if ( combineSubSections
&& !subsectionStarted
)
856 // Read old .con file in at this point
858 wxStrcpy(buf
, CurrentSectionFile
);
859 wxStripExtension(buf
);
860 wxStrcat(buf
, _T(".con"));
861 FILE *fd
= wxFopen(buf
, _T("r"));
872 wxFprintf(Sections
, _T("<P>\n"));
874 // Close old file, create a new file for the sub(sub)section contents entries
875 ReopenSectionContentsFile();
878 startedSections
= TRUE
;
879 subsectionStarted
= TRUE
;
881 wxChar
*topicName
= FindTopicName(GetNextChunk());
883 if ( !combineSubSections
)
885 SetCurrentOutput(NULL
);
886 ReopenFile(&Subsections
, &SubsectionsName
, topicName
);
887 AddTexRef(topicName
, SubsectionsName
, SubsectionNameString
);
888 SetCurrentSubsectionName(topicName
, SubsectionsName
);
889 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SubsectionsName
);
890 SetCurrentOutput(Subsections
);
893 TexOutput(_T("<title>"));
894 OutputCurrentSection();
895 TexOutput(_T("</title></head>\n"));
898 wxFprintf(Subsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
899 AddBrowseButtons(CurrentSectionName
, CurrentSectionFile
, // Up
900 lastTopic
, lastFileName
, // Last topic
901 topicName
, SubsectionsName
); // This topic
903 SetCurrentOutputs(Sections
, Subsections
);
904 wxFprintf(Sections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName
), topicName
);
906 wxFprintf(Subsections
, _T("\n<H3>"));
907 OutputCurrentSection();
908 wxFprintf(Sections
, _T("</B></A><BR>\n"));
909 wxFprintf(Subsections
, _T("</H3>\n"));
911 SetCurrentOutput(Subsections
);
915 AddTexRef(topicName
, SectionsName
, SubsectionNameString
);
916 SetCurrentSubsectionName(topicName
, SectionsName
);
918 // if ( subsectionNo != 0 )
919 wxFprintf(Sections
, _T("\n<HR>\n"));
921 // We're putting everything into the section file
922 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
923 wxFprintf(Sections
, _T("\n<H3>"));
924 OutputCurrentSection();
925 wxFprintf(Sections
, _T("</H3>\n"));
927 SetCurrentOutput(SectionContentsFD
);
928 wxFprintf(SectionContentsFD
, _T("<A HREF=\"#%s\">"), topicName
);
929 OutputCurrentSection();
930 TexOutput(_T("</A><BR>\n"));
932 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
933 SetCurrentOutput(Sections
);
935 // Add this section title to the list of keywords
938 OutputCurrentSectionToString(wxTex2RTFBuffer
);
939 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
946 case ltSUBSUBSECTION
:
947 case ltSUBSUBSECTIONSTAR
:
951 if (!Subsections
&& !combineSubSections
)
953 OnError(_T("You cannot have a subsubsection before a subsection!"));
957 if (macroId
!= ltSUBSUBSECTIONSTAR
)
960 startedSections
= TRUE
;
962 wxChar
*topicName
= FindTopicName(GetNextChunk());
964 if ( !combineSubSections
)
966 SetCurrentOutput(NULL
);
967 ReopenFile(&Subsubsections
, &SubsubsectionsName
, topicName
);
968 AddTexRef(topicName
, SubsubsectionsName
, SubsubsectionNameString
);
969 SetCurrentSubsubsectionName(topicName
, SubsubsectionsName
);
970 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(3, topicName
, SubsubsectionsName
);
972 SetCurrentOutput(Subsubsections
);
974 TexOutput(_T("<title>"));
975 OutputCurrentSection();
976 TexOutput(_T("</title></head>\n"));
979 wxFprintf(Subsubsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
981 AddBrowseButtons(CurrentSubsectionName
, CurrentSubsectionFile
, // Up
982 lastTopic
, lastFileName
, // Last topic
983 topicName
, SubsubsectionsName
); // This topic
985 SetCurrentOutputs(Subsections
, Subsubsections
);
986 wxFprintf(Subsections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName
), topicName
);
988 wxFprintf(Subsubsections
, _T("\n<H3>"));
989 OutputCurrentSection();
990 wxFprintf(Subsections
, _T("</B></A><BR>\n"));
991 wxFprintf(Subsubsections
, _T("</H3>\n"));
995 AddTexRef(topicName
, SectionsName
, SubsubsectionNameString
);
996 SetCurrentSubsectionName(topicName
, SectionsName
);
997 wxFprintf(Sections
, _T("\n<HR>\n"));
999 // We're putting everything into the section file
1000 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1001 wxFprintf(Sections
, _T("\n<H3>"));
1002 OutputCurrentSection();
1003 wxFprintf(Sections
, _T("</H3>\n"));
1004 /* TODO: where do we put subsubsection contents entry - indented, with subsection entries?
1005 SetCurrentOutput(SectionContentsFD);
1006 wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName);
1007 OutputCurrentSection();
1008 TexOutput(_T("</A><BR>"));
1010 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
1011 SetCurrentOutput(Sections
);
1014 // Add this section title to the list of keywords
1017 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1018 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
1027 if ( !combineSubSections
)
1028 SetCurrentOutput(Subsections
);
1030 SetCurrentOutput(Sections
);
1041 if ( !combineSubSections
)
1042 SetCurrentOutput(Subsections
);
1044 SetCurrentOutput(Sections
);
1055 if ( !combineSubSections
)
1056 SetCurrentOutput(Subsections
);
1058 SetCurrentOutput(Sections
);
1069 // TexOutput(_T("<B>void</B>"));
1073 TexOutput(_T("HARDY"));
1077 TexOutput(_T("wxCLIPS"));
1081 TexOutput(_T("&"));
1083 case ltSPECIALAMPERSAND
:
1089 // End cell, start cell
1091 TexOutput(_T("</FONT></TD>"));
1093 // Start new row and cell, setting alignment for the first cell.
1094 if (currentColumn
< noColumns
)
1098 if (TableData
[currentColumn
].justification
== 'c')
1099 wxSprintf(buf
, _T("\n<TD ALIGN=CENTER>"));
1100 else if (TableData
[currentColumn
].justification
== 'r')
1101 wxSprintf(buf
, _T("\n<TD ALIGN=RIGHT>"));
1102 else if (TableData
[currentColumn
].absWidth
)
1104 // Convert from points * 20 into pixels.
1105 int points
= TableData
[currentColumn
].width
/ 20;
1107 // Say the display is 100 DPI (dots/pixels per inch).
1108 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1109 int pixels
= (int)(points
* 100.0 / 72.0);
1110 wxSprintf(buf
, _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1113 wxSprintf(buf
, _T("\n<TD ALIGN=LEFT>"));
1118 TexOutput(_T("&"));
1122 case ltBACKSLASHCHAR
:
1128 // End row. In fact, tables without use of \row or \ruledrow isn't supported for
1129 // HTML: the syntax is too different (e.g. how do we know where to put the first </TH>
1130 // if we've ended the last row?). So normally you wouldn't use \\ to end a row.
1131 TexOutput(_T("</TR>\n"));
1134 TexOutput(_T("<BR>\n"));
1145 // Start new row and cell, setting alignment for the first cell.
1147 if (TableData
[currentColumn
].justification
== 'c')
1148 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=CENTER>"));
1149 else if (TableData
[currentColumn
].justification
== 'r')
1150 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=RIGHT>"));
1151 else if (TableData
[currentColumn
].absWidth
)
1153 // Convert from points * 20 into pixels.
1154 int points
= TableData
[currentColumn
].width
/ 20;
1156 // Say the display is 100 DPI (dots/pixels per inch).
1157 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1158 int pixels
= (int)(points
* 100.0 / 72.0);
1159 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1162 wxSprintf(buf
, _T("<TR>\n<TD ALIGN=LEFT>"));
1169 // Start new row and cell
1170 TexOutput(_T("</FONT></TD>\n</TR>\n"));
1174 // HTML-only: break until the end of the picture (both margins are clear).
1178 TexOutput(_T("<BR CLEAR=ALL>"));
1181 case ltRTFSP
: // Explicit space, RTF only
1183 case ltSPECIALTILDE
:
1187 if (TRUE
) // (inVerbatim)
1197 TexOutput(_T("<UL><UL>\n"));
1199 TexOutput(_T("</UL></UL>\n"));
1205 // case ltTWOCOLLIST:
1212 if (macroId
== ltENUMERATE
)
1213 listType
= LATEX_ENUMERATE
;
1214 else if (macroId
== ltITEMIZE
)
1215 listType
= LATEX_ITEMIZE
;
1217 listType
= LATEX_DESCRIPTION
;
1219 itemizeStack
.Insert(new ItemizeStruc(listType
));
1223 TexOutput(_T("<UL>\n"));
1225 case LATEX_ENUMERATE
:
1226 TexOutput(_T("<OL>\n"));
1228 case LATEX_DESCRIPTION
:
1230 TexOutput(_T("<DL>\n"));
1237 if (itemizeStack
.GetFirst())
1239 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
1240 switch (struc
->listType
)
1243 TexOutput(_T("</UL>\n"));
1245 case LATEX_ENUMERATE
:
1246 TexOutput(_T("</OL>\n"));
1248 case LATEX_DESCRIPTION
:
1250 TexOutput(_T("</DL>\n"));
1255 delete itemizeStack
.GetFirst();
1263 TexOutput(_T("\n<TABLE>\n"));
1265 TexOutput(_T("\n</TABLE>\n"));
1275 TexOutput(_T("<P>\n"));
1278 /* For footnotes we need to output the text at the bottom of the page and
1279 * insert a reference to it. Is it worth the trouble...
1281 case ltFOOTNOTEPOPUP:
1285 TexOutput(_T("<FN>"));
1287 else TexOutput(_T("</FN>"));
1294 TexOutput(_T("<TT>"));
1295 else TexOutput(_T("</TT>"));
1303 wxSprintf(buf
, _T("<PRE>\n"));
1306 else TexOutput(_T("</PRE>\n"));
1314 TexOutput(_T("<CENTER>"));
1316 else TexOutput(_T("</CENTER>"));
1324 TexOutput(_T("{\\ql "));
1326 else TexOutput(_T("}\\par\\pard\n"));
1335 TexOutput(_T("{\\qr "));
1337 else TexOutput(_T("}\\par\\pard\n"));
1345 // Netscape extension
1346 TexOutput(_T("<FONT SIZE=2>"));
1348 else TexOutput(_T("</FONT>"));
1355 // Netscape extension
1356 TexOutput(_T("<FONT SIZE=1>"));
1358 else TexOutput(_T("</FONT>"));
1365 // Netscape extension
1366 TexOutput(_T("<FONT SIZE=3>"));
1368 else TexOutput(_T("</FONT>"));
1375 // Netscape extension
1376 TexOutput(_T("<FONT SIZE=4>"));
1378 else TexOutput(_T("</FONT>"));
1385 // Netscape extension
1386 TexOutput(_T("<FONT SIZE=5>"));
1388 else TexOutput(_T("</FONT>"));
1395 // Netscape extension
1396 TexOutput(_T("<FONT SIZE=6>"));
1398 else TexOutput(_T("</FONT>"));
1407 TexOutput(_T("<B>"));
1409 else TexOutput(_T("</B>"));
1418 TexOutput(_T("<I>"));
1420 else TexOutput(_T("</I>"));
1428 TexOutput(_T("<EM>"));
1430 else TexOutput(_T("</EM>"));
1437 TexOutput(_T("<UL>"));
1439 else TexOutput(_T("</UL>"));
1448 TexOutput(_T("<TT>"));
1450 else TexOutput(_T("</TT>"));
1456 TexOutput(_T("©"), TRUE
);
1462 TexOutput(_T("®"), TRUE
);
1468 if (start
) TexOutput(_T("<--"));
1473 if (start
) TexOutput(_T("<=="));
1478 if (start
) TexOutput(_T("-->"));
1483 if (start
) TexOutput(_T("==>"));
1486 case ltLEFTRIGHTARROW
:
1488 if (start
) TexOutput(_T("<-->"));
1491 case ltLEFTRIGHTARROW2
:
1493 if (start
) TexOutput(_T("<==>"));
1506 wxNode
*node
= itemizeStack
.GetFirst();
1509 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
1510 struc
->currentItem
+= 1;
1511 if (struc
->listType
== LATEX_DESCRIPTION
)
1513 if (descriptionItemArg
)
1515 TexOutput(_T("<DT> "));
1516 TraverseChildrenFromChunk(descriptionItemArg
);
1517 TexOutput(_T("\n"));
1518 descriptionItemArg
= NULL
;
1520 TexOutput(_T("<DD>"));
1523 TexOutput(_T("<LI>"));
1530 if (start
&& DocumentTitle
&& DocumentAuthor
)
1532 // Add a special label for the contents page.
1533 // TexOutput(_T("<CENTER>\n"));
1534 TexOutput(_T("<A NAME=\"contents\">"));
1535 TexOutput(_T("<H2 ALIGN=CENTER>\n"));
1536 TraverseChildrenFromChunk(DocumentTitle
);
1537 TexOutput(_T("</H2>"));
1538 TexOutput(_T("<P>"));
1539 TexOutput(_T("</A>\n"));
1540 TexOutput(_T("<P>\n\n"));
1541 TexOutput(_T("<H3 ALIGN=CENTER>"));
1542 TraverseChildrenFromChunk(DocumentAuthor
);
1543 TexOutput(_T("</H3><P>\n\n"));
1546 TexOutput(_T("<H3 ALIGN=CENTER>"));
1547 TraverseChildrenFromChunk(DocumentDate
);
1548 TexOutput(_T("</H3><P>\n\n"));
1550 // TexOutput(_T("\n</CENTER>\n"));
1551 TexOutput(_T("\n<P><HR><P>\n"));
1554 // Now do optional frame contents page
1555 if (htmlFrameContents && FrameContents)
1557 SetCurrentOutput(FrameContents);
1559 // Add a special label for the contents page.
1560 TexOutput(_T("<CENTER>\n"));
1561 TexOutput(_T("<H3>\n"));
1562 TraverseChildrenFromChunk(DocumentTitle);
1563 TexOutput(_T("</H3>"));
1564 TexOutput(_T("<P>"));
1565 TexOutput(_T("</A>\n"));
1566 TexOutput(_T("<P>\n\n"));
1567 TexOutput(_T("<H3>"));
1568 TraverseChildrenFromChunk(DocumentAuthor);
1569 TexOutput(_T("</H3><P>\n\n"));
1572 TexOutput(_T("<H4>"));
1573 TraverseChildrenFromChunk(DocumentDate);
1574 TexOutput(_T("</H4><P>\n\n"));
1576 TexOutput(_T("\n</CENTER>\n"));
1577 TexOutput(_T("<P><HR><P>\n"));
1579 SetCurrentOutput(Titlepage);
1592 helpRefFilename
= NULL
;
1597 case ltBIBLIOGRAPHY
:
1601 DefaultOnMacro(macroId
, no_args
, start
);
1605 DefaultOnMacro(macroId
, no_args
, start
);
1606 TexOutput(_T("</DL>\n"));
1614 TexOutput(_T("<HR>\n"));
1622 TexOutput(_T("<HR>\n"));
1626 case ltTABLEOFCONTENTS
:
1630 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1636 putc(ch
, Titlepage
);
1643 TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n"));
1644 OnInform(_T("Run Tex2RTF again to include contents page."));
1652 TexOutput(_T("<"));
1658 TexOutput(_T(">"));
1665 TexOutput(_T("<BLOCKQUOTE>"));
1667 TexOutput(_T("</BLOCKQUOTE>"));
1676 TexOutput(_T("\n<CAPTION>"));
1684 if (DocumentStyle
!= LATEX_ARTICLE
)
1685 wxSprintf(figBuf
, _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1687 wxSprintf(figBuf
, _T("%s %d: "), FigureNameString
, figureNo
);
1693 if (DocumentStyle
!= LATEX_ARTICLE
)
1694 wxSprintf(figBuf
, _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1696 wxSprintf(figBuf
, _T("%s %d: "), TableNameString
, tableNo
);
1704 TexOutput(_T("\n</CAPTION>\n"));
1706 wxChar
*topicName
= FindTopicName(GetNextChunk());
1708 int n
= inFigure
? figureNo
: tableNo
;
1710 AddTexRef(topicName
, NULL
, NULL
,
1711 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1712 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1718 if (start
) TexOutput(_T("ß"));
1723 if (start
) inFigure
= TRUE
;
1724 else inFigure
= FALSE
;
1729 if (start
) inTable
= TRUE
;
1730 else inTable
= FALSE
;
1734 DefaultOnMacro(macroId
, no_args
, start
);
1739 // Called on start/end of argument examination
1740 bool HTMLOnArgument(int macroId
, int arg_no
, bool start
)
1746 case ltCHAPTERHEADING
:
1749 case ltSECTIONHEADING
:
1751 case ltSUBSECTIONSTAR
:
1752 case ltSUBSUBSECTION
:
1753 case ltSUBSUBSECTIONSTAR
:
1755 case ltMEMBERSECTION
:
1756 case ltFUNCTIONSECTION
:
1758 if (!start
&& (arg_no
== 1))
1759 currentSection
= GetArgChunk();
1764 if (start
&& (arg_no
== 1))
1765 TexOutput(_T("<B>"));
1767 if (!start
&& (arg_no
== 1))
1768 TexOutput(_T("</B> "));
1770 if (start
&& (arg_no
== 2))
1772 if (!suppressNameDecoration
) TexOutput(_T("<B>"));
1773 currentMember
= GetArgChunk();
1775 if (!start
&& (arg_no
== 2))
1777 if (!suppressNameDecoration
) TexOutput(_T("</B>"));
1780 if (start
&& (arg_no
== 3))
1782 if (!start
&& (arg_no
== 3))
1788 if (start
&& (arg_no
== 1))
1789 TexOutput(_T("<B>"));
1790 if (!start
&& (arg_no
== 1))
1791 TexOutput(_T("</B> "));
1793 if (start
&& (arg_no
== 2))
1795 if (!suppressNameDecoration
) TexOutput(_T("( "));
1796 currentMember
= GetArgChunk();
1798 if (!start
&& (arg_no
== 2))
1802 if (!start
&& (arg_no
== 3))
1808 if (!start
&& (arg_no
== 1))
1811 if (start
&& (arg_no
== 2))
1812 TexOutput(_T("(*"));
1813 if (!start
&& (arg_no
== 2))
1816 if (start
&& (arg_no
== 2))
1817 currentMember
= GetArgChunk();
1819 if (start
&& (arg_no
== 3))
1821 if (!start
&& (arg_no
== 3))
1827 if (start
&& (arg_no
== 1))
1828 TexOutput(_T("<B>"));
1829 if (!start
&& (arg_no
== 1))
1830 TexOutput(_T("</B>"));
1831 if (start
&& (arg_no
== 2))
1833 TexOutput(_T("<I>"));
1835 if (!start
&& (arg_no
== 2))
1837 TexOutput(_T("</I>"));
1843 if (start
&& (arg_no
== 1))
1844 TexOutput(_T("<B>"));
1845 if (!start
&& (arg_no
== 1))
1846 TexOutput(_T("</B> ")); // This is the difference from param - one space!
1847 if (start
&& (arg_no
== 2))
1849 TexOutput(_T("<I>"));
1851 if (!start
&& (arg_no
== 2))
1853 TexOutput(_T("</I>"));
1859 if (!start
&& (arg_no
== 1))
1862 if (start
&& (arg_no
== 2))
1863 currentMember
= GetArgChunk();
1872 wxChar
*refName
= GetArgData();
1875 TexRef
*texRef
= FindReference(refName
);
1878 sec
= texRef
->sectionNumber
;
1891 if (IsArgOptional())
1893 else if ((GetNoArgs() - arg_no
) == 1)
1896 helpRefText
= GetArgChunk();
1899 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1903 TexChunk
*ref
= GetArgChunk();
1904 TexOutput(_T("<A HREF=\""));
1906 TraverseChildrenFromChunk(ref
);
1908 TexOutput(_T("\">"));
1910 TraverseChildrenFromChunk(helpRefText
);
1911 TexOutput(_T("</A>"));
1921 if (IsArgOptional())
1924 helpRefFilename
= GetArgChunk();
1927 if ((GetNoArgs() - arg_no
) == 1)
1930 helpRefText
= GetArgChunk();
1933 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1937 wxChar
*refName
= GetArgData();
1938 wxChar
*refFilename
= NULL
;
1942 TexRef
*texRef
= FindReference(refName
);
1945 if (texRef
->refFile
&& wxStrcmp(texRef
->refFile
, _T("??")) != 0)
1946 refFilename
= texRef
->refFile
;
1948 TexOutput(_T("<A HREF=\""));
1949 // If a filename is supplied, use it, otherwise try to
1950 // use the filename associated with the reference (from this document).
1951 if (helpRefFilename
)
1953 TraverseChildrenFromChunk(helpRefFilename
);
1956 else if (refFilename
)
1958 TexOutput(ConvertCase(refFilename
));
1962 TexOutput(_T("\">"));
1964 TraverseChildrenFromChunk(helpRefText
);
1965 TexOutput(_T("</A>"));
1970 TraverseChildrenFromChunk(helpRefText
);
1972 TexOutput(_T(" (REF NOT FOUND)"));
1974 errBuf
.Printf(_T("Warning: unresolved reference '%s'"), refName
);
1975 OnInform((wxChar
*)errBuf
.c_str());
1978 else TexOutput(_T("??"));
1993 wxChar
*alignment
= _T("");
1994 if (macroId
== ltIMAGEL
)
1995 alignment
= _T(" align=left");
1996 else if (macroId
== ltIMAGER
)
1997 alignment
= _T(" align=right");
1999 // Try to find an XBM or GIF image first.
2000 wxChar
*filename
= copystring(GetArgData());
2003 wxStrcpy(buf
, filename
);
2004 StripExtension(buf
);
2005 wxStrcat(buf
, _T(".xbm"));
2006 wxString f
= TexPathList
.FindValidPath(buf
);
2008 if (f
== _T("")) // Try for a GIF instead
2010 wxStrcpy(buf
, filename
);
2011 StripExtension(buf
);
2012 wxStrcat(buf
, _T(".gif"));
2013 f
= TexPathList
.FindValidPath(buf
);
2016 if (f
== _T("")) // Try for a JPEG instead
2018 wxStrcpy(buf
, filename
);
2019 StripExtension(buf
);
2020 wxStrcat(buf
, _T(".jpg"));
2021 f
= TexPathList
.FindValidPath(buf
);
2024 if (f
== _T("")) // Try for a PNG instead
2026 wxStrcpy(buf
, filename
);
2027 StripExtension(buf
);
2028 wxStrcat(buf
, _T(".png"));
2029 f
= TexPathList
.FindValidPath(buf
);
2034 wxChar
*inlineFilename
= copystring(f
);
2036 wxChar
*originalFilename
= TexPathList
.FindValidPath(filename
);
2037 // If we have found the existing filename, make the inline
2038 // image point to the original file (could be PS, for example)
2039 if (originalFilename
&& (wxStrcmp(inlineFilename
, originalFilename
) != 0))
2041 TexOutput(_T("<A HREF=\""));
2042 TexOutput(ConvertCase(originalFilename
));
2043 TexOutput(_T("\">"));
2044 TexOutput(_T("<img src=\""));
2045 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2046 TexOutput(_T("\""));
2047 TexOutput(alignment
);
2048 TexOutput(_T("></A>"));
2053 TexOutput(_T("<img src=\""));
2054 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2055 TexOutput(_T("\""));
2056 TexOutput(alignment
);
2058 delete[] inlineFilename
;
2063 // Last resort - a link to a PS file.
2064 TexOutput(_T("<A HREF=\""));
2065 TexOutput(ConvertCase(wxFileNameFromPath(filename
)));
2066 TexOutput(_T("\">Picture</A>\n"));
2067 wxSprintf(buf
, _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2074 // First arg is PSBOX spec (ignored), second is image file, third is map name.
2077 static wxChar
*imageFile
= NULL
;
2078 if (start
&& (arg_no
== 2))
2080 // Try to find an XBM or GIF image first.
2081 wxChar
*filename
= copystring(GetArgData());
2084 wxStrcpy(buf
, filename
);
2085 StripExtension(buf
);
2086 wxStrcat(buf
, _T(".xbm"));
2087 wxString f
= TexPathList
.FindValidPath(buf
);
2089 if (f
== _T("")) // Try for a GIF instead
2091 wxStrcpy(buf
, filename
);
2092 StripExtension(buf
);
2093 wxStrcat(buf
, _T(".gif"));
2094 f
= TexPathList
.FindValidPath(buf
);
2099 wxSprintf(buf
, _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2108 imageFile
= copystring(f
);
2111 else if (start
&& (arg_no
== 3))
2115 // First, try to find a .shg (segmented hypergraphics file)
2116 // that we can convert to a map file
2118 wxStrcpy(buf
, imageFile
);
2119 StripExtension(buf
);
2120 wxStrcat(buf
, _T(".shg"));
2121 wxString f
= TexPathList
.FindValidPath(buf
);
2125 // The default HTML file to go to is THIS file (so a no-op)
2126 SHGToMap((wxChar
*)f
.c_str(), currentFileName
);
2129 wxChar
*mapName
= GetArgData();
2130 TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/"));
2134 TexOutput(_T("unknown"));
2135 TexOutput(_T("\">"));
2136 TexOutput(_T("<img src=\""));
2137 TexOutput(ConvertCase(wxFileNameFromPath(imageFile
)));
2138 TexOutput(_T("\" ISMAP></A><P>"));
2158 descriptionItemArg
= GetArgChunk();
2164 case ltTWOCOLITEMRULED
:
2167 if (start && (arg_no == 1))
2168 TexOutput(_T("\n<DT> "));
2169 if (start && (arg_no == 2))
2170 TexOutput(_T("<DD> "));
2176 if (TwoColWidthA
> -1) {
2178 wxSprintf(buf
,_T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA
);
2181 TexOutput(_T("\n<TR><TD VALIGN=TOP>\n"));
2184 TexOutput(_T("\n</FONT></TD>\n"));
2190 if (TwoColWidthB
> -1) {
2192 wxSprintf(buf
,_T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB
);
2195 TexOutput(_T("\n<TD VALIGN=TOP>\n"));
2198 TexOutput(_T("\n</FONT></TD></TR>\n"));
2202 case ltNUMBEREDBIBITEM
:
2204 if (arg_no
== 1 && start
)
2206 TexOutput(_T("\n<DT> "));
2208 if (arg_no
== 2 && !start
)
2209 TexOutput(_T("<P>\n"));
2215 if (arg_no
== 1 && start
)
2217 wxChar
*citeKey
= GetArgData();
2218 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
2221 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
2222 wxSprintf(buf
, _T("[%d]"), citeCount
);
2223 ref
->sectionNumber
= copystring(buf
);
2226 wxSprintf(buf
, _T("\n<DT> [%d] "), citeCount
);
2231 if (arg_no
== 2 && !start
)
2232 TexOutput(_T("<P>\n"));
2236 case ltMARGINPARODD
:
2237 case ltMARGINPAREVEN
:
2243 TexOutput(_T("<HR>\n"));
2247 TexOutput(_T("<HR><P>\n"));
2251 case ltTWOCOLWIDTHA
:
2255 wxChar
*val
= GetArgData();
2256 float points
= ParseUnitArgument(val
);
2257 TwoColWidthA
= (int)((points
* 100.0) / 72.0);
2262 case ltTWOCOLWIDTHB
:
2266 wxChar
*val
= GetArgData();
2267 float points
= ParseUnitArgument(val
);
2268 TwoColWidthB
= (int)((points
* 100.0) / 72.0);
2276 case ltACCENT_GRAVE
:
2280 wxChar
*val
= GetArgData();
2286 TexOutput(_T("à"));
2289 TexOutput(_T("è"));
2292 TexOutput(_T("ì"));
2295 TexOutput(_T("ò"));
2298 TexOutput(_T("ù"));
2301 TexOutput(_T("À"));
2304 TexOutput(_T("È"));
2307 TexOutput(_T("Ì"));
2310 TexOutput(_T("Ò"));
2313 TexOutput(_T("Ì"));
2322 case ltACCENT_ACUTE
:
2326 wxChar
*val
= GetArgData();
2332 TexOutput(_T("á"));
2335 TexOutput(_T("é"));
2338 TexOutput(_T("í"));
2341 TexOutput(_T("ó"));
2344 TexOutput(_T("ú"));
2347 TexOutput(_T("ý"));
2350 TexOutput(_T("Á"));
2353 TexOutput(_T("É"));
2356 TexOutput(_T("Í"));
2359 TexOutput(_T("Ó"));
2362 TexOutput(_T("Ú"));
2365 TexOutput(_T("Ý"));
2374 case ltACCENT_CARET
:
2378 wxChar
*val
= GetArgData();
2384 TexOutput(_T("â"));
2387 TexOutput(_T("ê"));
2390 TexOutput(_T("î"));
2393 TexOutput(_T("ô"));
2396 TexOutput(_T("û"));
2399 TexOutput(_T("Â"));
2402 TexOutput(_T("Ê"));
2405 TexOutput(_T("Î"));
2408 TexOutput(_T("Ô"));
2411 TexOutput(_T("Î"));
2420 case ltACCENT_TILDE
:
2424 wxChar
*val
= GetArgData();
2433 TexOutput(_T("ã"));
2436 TexOutput(_T("ñ"));
2439 TexOutput(_T("õ"));
2442 TexOutput(_T("Ã"));
2445 TexOutput(_T("Ñ"));
2448 TexOutput(_T("Õ"));
2457 case ltACCENT_UMLAUT
:
2461 wxChar
*val
= GetArgData();
2467 TexOutput(_T("ä"));
2470 TexOutput(_T("ë"));
2473 TexOutput(_T("ï"));
2476 TexOutput(_T("ö"));
2479 TexOutput(_T("ü"));
2482 TexOutput(_T("ÿ"));
2485 TexOutput(_T("Ä"));
2488 TexOutput(_T("Ë"));
2491 TexOutput(_T("Ï"));
2494 TexOutput(_T("Ö"));
2497 TexOutput(_T("Ü"));
2500 TexOutput(_T("Ÿ"));
2513 wxChar
*val
= GetArgData();
2519 TexOutput(_T("å"));
2522 TexOutput(_T("Å"));
2535 wxChar
*val
= GetArgData();
2538 bool isPicture
= FALSE
;
2539 ParseColourString(val
, &isPicture
);
2542 if (backgroundImageString
)
2543 delete[] backgroundImageString
;
2544 backgroundImageString
= copystring(val
);
2548 if (backgroundColourString
)
2549 delete[] backgroundColourString
;
2550 backgroundColourString
= copystring(val
);
2556 case ltBACKGROUNDIMAGE
:
2560 wxChar
*val
= GetArgData();
2563 if (backgroundImageString
)
2564 delete[] backgroundImageString
;
2565 backgroundImageString
= copystring(val
);
2570 case ltBACKGROUNDCOLOUR
:
2574 wxChar
*val
= GetArgData();
2577 if (backgroundColourString
)
2578 delete[] backgroundColourString
;
2579 backgroundColourString
= copystring(val
);
2588 wxChar
*val
= GetArgData();
2591 if (textColourString
)
2592 delete[] textColourString
;
2593 textColourString
= copystring(val
);
2602 wxChar
*val
= GetArgData();
2605 if (linkColourString
)
2606 delete[] linkColourString
;
2607 linkColourString
= copystring(val
);
2612 case ltFOLLOWEDLINKCOLOUR
:
2616 wxChar
*val
= GetArgData();
2619 if (followedLinkColourString
)
2620 delete[] followedLinkColourString
;
2621 followedLinkColourString
= copystring(val
);
2626 case ltACCENT_CADILLA
:
2630 wxChar
*val
= GetArgData();
2636 TexOutput(_T("ç"));
2639 TexOutput(_T("Ç"));
2650 case ltFOOTNOTEPOPUP:
2660 case ltSUPERTABULAR
:
2666 currentRowNumber
= 0;
2669 tableVerticalLineLeft
= FALSE
;
2670 tableVerticalLineRight
= FALSE
;
2672 wxChar
*alignString
= copystring(GetArgData());
2673 ParseTableArgument(alignString
);
2675 TexOutput(_T("<TABLE BORDER>\n"));
2677 // Write the first row formatting for compatibility
2678 // with standard Latex
2679 if (compatibilityMode
)
2681 TexOutput(_T("<TR>\n<TD>"));
2684 for (int i = 0; i < noColumns; i++)
2686 currentWidth += TableData[i].width;
2687 wxSprintf(buf, _T("\\cellx%d"), currentWidth);
2690 TexOutput(_T("\\pard\\intbl\n"));
2693 delete[] alignString
;
2698 else if (arg_no
== 2 && !start
)
2700 TexOutput(_T("</TABLE>\n"));
2705 case ltTHEBIBLIOGRAPHY
:
2707 if (start
&& (arg_no
== 1))
2709 ReopenFile(&Chapters
, &ChaptersName
, _T("bibliography"));
2710 AddTexRef(_T("bibliography"), ChaptersName
, _T("bibliography"));
2711 SetCurrentSubsectionName(_T("bibliography"), ChaptersName
);
2715 SetCurrentOutput(Chapters
);
2717 wxChar titleBuf
[150];
2718 if (truncateFilenames
)
2719 wxSprintf(titleBuf
, _T("%s.htm"), wxFileNameFromPath(FileRoot
));
2721 wxSprintf(titleBuf
, _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
2724 TexOutput(_T("<title>"));
2725 TexOutput(ReferencesNameString
);
2726 TexOutput(_T("</title></head>\n"));
2729 wxFprintf(Chapters
, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString
);
2730 AddBrowseButtons(_T("contents"), titleBuf
, // Up
2731 lastTopic
, lastFileName
, // Last topic
2732 _T("bibliography"), ChaptersName
); // This topic
2734 SetCurrentOutputs(Contents
, Chapters
);
2735 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), "bibliography");
2737 wxFprintf(Contents
, _T("%s</A>\n"), ReferencesNameString
);
2738 wxFprintf(Chapters
, _T("</H2>\n</A>\n"));
2740 SetCurrentOutput(Chapters
);
2743 if (!start
&& (arg_no
== 2))
2750 /* Build up list of keywords associated with topics */
2753 // wxChar *entry = GetArgData();
2755 OutputChunkToString(GetArgChunk(), buf
);
2758 AddKeyWordForTopic(CurrentTopic
, buf
, currentFileName
);
2772 wxChar
*name
= GetArgData();
2774 if (!FindColourHTMLString(name
, buf2
))
2776 wxStrcpy(buf2
, _T("#000000"));
2778 wxSprintf(buf
, _T("Could not find colour name %s"), name
);
2781 TexOutput(_T("<FONT COLOR=\""));
2783 TexOutput(_T("\">"));
2796 if (arg_no
== 2) TexOutput(_T("</FONT>"));
2800 case ltINSERTATLEVEL
:
2802 // This macro allows you to insert text at a different level
2803 // from the current level, e.g. into the Sections from within a subsubsection.
2806 static int currentLevelNo
= 1;
2807 static FILE* oldLevelFile
= Chapters
;
2814 oldLevelFile
= CurrentOutput1
;
2816 wxChar
*str
= GetArgData();
2817 currentLevelNo
= wxAtoi(str
);
2819 // TODO: cope with article style (no chapters)
2820 switch (currentLevelNo
)
2824 outputFile
= Chapters
;
2829 outputFile
= Sections
;
2834 outputFile
= Subsections
;
2839 outputFile
= Subsubsections
;
2849 CurrentOutput1
= outputFile
;
2865 CurrentOutput1
= oldLevelFile
;
2871 return DefaultOnArgument(macroId
, arg_no
, start
);
2883 tableVerticalLineLeft
= FALSE
;
2884 tableVerticalLineRight
= FALSE
;
2887 if (InputFile
&& OutputFile
)
2889 // Do some HTML-specific transformations on all the strings,
2891 Text2HTML(GetTopLevelChunk());
2894 if (truncateFilenames
)
2895 wxSprintf(buf
, _T("%s.htm"), FileRoot
);
2897 wxSprintf(buf
, _T("%s_contents.html"), FileRoot
);
2898 if (TitlepageName
) delete[] TitlepageName
;
2899 TitlepageName
= copystring(buf
);
2900 Titlepage
= wxFopen(buf
, _T("w"));
2902 if (truncateFilenames
)
2903 wxSprintf(buf
, _T("%s_fc.htm"), FileRoot
);
2905 wxSprintf(buf
, _T("%s_fcontents.html"), FileRoot
);
2907 contentsFrameName
= copystring(buf
);
2909 Contents
= wxFopen(TmpContentsName
, _T("w"));
2911 if (htmlFrameContents
)
2913 // FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
2914 FrameContents
= wxFopen(contentsFrameName
, _T("w"));
2915 wxFprintf(FrameContents
, _T("<HTML>\n<UL>\n"));
2918 if (!Titlepage
|| !Contents
)
2920 OnError(_T("Cannot open output file!"));
2923 AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName
), ContentsNameString
);
2925 wxFprintf(Contents
, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString
);
2927 wxFprintf(Contents
, _T("<UL>\n"));
2929 SetCurrentOutput(Titlepage
);
2930 if (htmlWorkshopFiles
) HTMLWorkshopStartContents();
2931 OnInform(_T("Converting..."));
2934 wxFprintf(Contents
, _T("</UL>\n\n"));
2936 // SetCurrentOutput(Titlepage);
2941 // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
2948 wxFprintf(FrameContents
, _T("\n</UL>\n"));
2949 wxFprintf(FrameContents
, _T("</HTML>\n"));
2950 fclose(FrameContents
);
2951 FrameContents
= NULL
;
2956 wxFprintf(Chapters
, _T("\n</FONT></BODY></HTML>\n"));
2962 wxFprintf(Sections
, _T("\n</FONT></BODY></HTML>\n"));
2966 if (Subsections
&& !combineSubSections
)
2968 wxFprintf(Subsections
, _T("\n</FONT></BODY></HTML>\n"));
2969 fclose(Subsections
);
2972 if (Subsubsections
&& !combineSubSections
)
2974 wxFprintf(Subsubsections
, _T("\n</FONT></BODY></HTML>\n"));
2975 fclose(Subsubsections
);
2976 Subsubsections
= NULL
;
2978 if ( SectionContentsFD
)
2980 fclose(SectionContentsFD
);
2981 SectionContentsFD
= NULL
;
2984 // Create a temporary file for the title page header, add some info,
2985 // and concat the titlepage just generated.
2986 // This is necessary in order to put the title of the document
2987 // at the TOP of the file within <HEAD>, even though we only find out
2988 // what it is later on.
2989 FILE *tmpTitle
= wxFopen(_T("title.tmp"), _T("w"));
2994 SetCurrentOutput(tmpTitle
);
2996 TexOutput(_T("\n<HEAD><TITLE>"));
2997 TraverseChildrenFromChunk(DocumentTitle
);
2998 TexOutput(_T("</TITLE></HEAD>\n"));
3002 SetCurrentOutput(tmpTitle
);
3003 HTMLHeadTo(tmpTitle
);
3005 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString
);
3007 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot
));
3010 // Output frame information
3011 if (htmlFrameContents
)
3013 wxChar firstFileName
[300];
3014 if (truncateFilenames
)
3015 wxSprintf(firstFileName
, _T("%s1.htm"), FileRoot
);
3017 wxStrcpy(firstFileName
, gs_filenames
[1].c_str());
3019 wxFprintf(tmpTitle
, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
3021 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName
)));
3022 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName
)));
3023 wxFprintf(tmpTitle
, _T("</FRAMESET>\n"));
3025 wxFprintf(tmpTitle
, _T("<NOFRAMES>\n"));
3028 // Output <BODY...> to temporary title page
3032 FILE *fd
= wxFopen(TitlepageName
, _T("r"));
3044 wxFprintf(tmpTitle
, _T("\n</FONT></BODY>\n"));
3046 if (htmlFrameContents
)
3048 wxFprintf(tmpTitle
, _T("\n</NOFRAMES>\n"));
3050 wxFprintf(tmpTitle
, _T("\n</HTML>\n"));
3053 if (wxFileExists(TitlepageName
)) wxRemoveFile(TitlepageName
);
3054 if (!wxRenameFile(_T("title.tmp"), TitlepageName
))
3056 wxCopyFile(_T("title.tmp"), TitlepageName
);
3057 wxRemoveFile(_T("title.tmp"));
3061 if (lastFileName
) delete[] lastFileName
;
3062 lastFileName
= NULL
;
3063 if (lastTopic
) delete[] lastTopic
;
3066 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
3068 if (!wxRenameFile(TmpContentsName
, ContentsName
))
3070 wxCopyFile(TmpContentsName
, ContentsName
);
3071 wxRemoveFile(TmpContentsName
);
3074 // Generate .htx file if requested
3077 wxChar htmlIndexName
[300];
3078 wxSprintf(htmlIndexName
, _T("%s.htx"), FileRoot
);
3079 GenerateHTMLIndexFile(htmlIndexName
);
3082 // Generate HTML Help Workshop files if requested
3083 if (htmlWorkshopFiles
)
3085 HTMLWorkshopEndContents();
3086 GenerateHTMLWorkshopFiles(FileRoot
);
3096 // Output .htx index file
3097 void GenerateHTMLIndexFile(wxChar
*fname
)
3099 FILE *fd
= wxFopen(fname
, _T("w"));
3103 TopicTable
.BeginFind();
3104 wxNode
*node
= TopicTable
.Next();
3107 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3108 const wxChar
*topicName
= node
->GetKeyString();
3109 if (texTopic
->filename
&& texTopic
->keywords
)
3111 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3114 wxChar
*s
= (wxChar
*)node1
->GetData();
3115 wxFprintf(fd
, _T("%s|%s|%s\n"), topicName
, texTopic
->filename
, s
);
3116 node1
= node1
->GetNext();
3119 node
= TopicTable
.Next();
3130 // output .hpp, .hhc and .hhk files:
3133 void GenerateHTMLWorkshopFiles(wxChar
*fname
)
3138 /* Generate project file : */
3140 wxSprintf(buf
, _T("%s.hhp"), fname
);
3141 f
= wxFopen(buf
, _T("wt"));
3144 _T("Compatibility=1.1\n")
3145 _T("Full-text search=Yes\n")
3146 _T("Contents file=%s.hhc\n")
3147 _T("Compiled file=%s.chm\n")
3148 _T("Default Window=%sHelp\n")
3149 _T("Default topic=%s\n")
3150 _T("Index file=%s.hhk\n")
3152 wxFileNameFromPath(fname
),
3153 wxFileNameFromPath(fname
),
3154 wxFileNameFromPath(fname
),
3155 wxFileNameFromPath(TitlepageName
),
3156 wxFileNameFromPath(fname
)
3159 if (DocumentTitle
) {
3160 SetCurrentOutput(f
);
3161 TraverseChildrenFromChunk(DocumentTitle
);
3163 else wxFprintf(f
, _T("(unknown)"));
3165 wxFprintf(f
, _T("\n\n[WINDOWS]\n")
3166 _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"),
3167 wxFileNameFromPath(fname
),
3168 wxFileNameFromPath(fname
),
3169 wxFileNameFromPath(fname
),
3170 wxFileNameFromPath(TitlepageName
));
3173 wxFprintf(f
, _T("\n\n[FILES]\n"));
3174 wxFprintf(f
, _T("%s\n"), wxFileNameFromPath(TitlepageName
));
3175 for (int i
= 1; i
<= fileId
; i
++) {
3176 if (truncateFilenames
)
3177 wxSprintf(buf
, _T("%s%d.htm"), wxFileNameFromPath(FileRoot
), i
);
3179 wxStrcpy(buf
, wxFileNameFromPath(gs_filenames
[i
].c_str()));
3180 wxFprintf(f
, _T("%s\n"), buf
);
3184 /* Generate index file : */
3186 wxSprintf(buf
, _T("%s.hhk"), fname
);
3187 f
= wxFopen(buf
, _T("wt"));
3190 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3195 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3196 _T("<!-- Sitemap 1.0 -->\n")
3197 _T("</HEAD><BODY>\n")
3198 _T("<OBJECT type=\"text/site properties\">\n")
3199 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3203 TopicTable
.BeginFind();
3204 wxNode
*node
= TopicTable
.Next();
3207 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3208 const wxChar
*topicName
= node
->GetKeyString();
3209 if (texTopic
->filename
&& texTopic
->keywords
)
3211 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3214 wxChar
*s
= (wxChar
*)node1
->GetData();
3216 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3217 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3218 _T(" <param name=\"Name\" value=\"%s\">\n")
3220 texTopic
->filename
, topicName
, s
);
3221 node1
= node1
->GetNext();
3224 node
= TopicTable
.Next();
3227 wxFprintf(f
, _T("</UL>\n"));
3233 static FILE *HTMLWorkshopContents
= NULL
;
3234 static int HTMLWorkshopLastLevel
= 0;
3236 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
)
3240 if (level
> HTMLWorkshopLastLevel
)
3241 for (i
= HTMLWorkshopLastLevel
; i
< level
; i
++)
3242 wxFprintf(HTMLWorkshopContents
, _T("<UL>"));
3243 if (level
< HTMLWorkshopLastLevel
)
3244 for (i
= level
; i
< HTMLWorkshopLastLevel
; i
++)
3245 wxFprintf(HTMLWorkshopContents
, _T("</UL>"));
3247 SetCurrentOutput(HTMLWorkshopContents
);
3248 wxFprintf(HTMLWorkshopContents
,
3249 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3250 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3251 _T(" <param name=\"Name\" value=\""),
3253 OutputCurrentSection();
3254 wxFprintf(HTMLWorkshopContents
,
3256 _T(" </OBJECT>\n"));
3257 HTMLWorkshopLastLevel
= level
;
3261 void HTMLWorkshopStartContents()
3264 wxSprintf(buf
, _T("%s.hhc"), FileRoot
);
3265 HTMLWorkshopContents
= wxFopen(buf
, _T("wt"));
3266 HTMLWorkshopLastLevel
= 0;
3268 wxFprintf(HTMLWorkshopContents
,
3269 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3271 HTMLHeadTo(HTMLWorkshopContents
);
3272 wxFprintf(HTMLWorkshopContents
,
3274 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3275 _T("<!-- Sitemap 1.0 -->\n")
3276 _T("</HEAD><BODY>\n")
3277 _T("<OBJECT type=\"text/site properties\">\n")
3278 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3281 _T("<LI> <OBJECT type=\"text/sitemap\">\n")
3282 _T("<param name=\"Local\" value=\"%s\">\n")
3283 _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"),
3284 wxFileNameFromPath(TitlepageName
)
3290 void HTMLWorkshopEndContents()
3292 for (int i
= HTMLWorkshopLastLevel
; i
>= 0; i
--)
3293 wxFprintf(HTMLWorkshopContents
, _T("</UL>\n"));
3294 fclose(HTMLWorkshopContents
);