1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Converts Latex to HTML
4 // Author: Julian Smart
5 // Modified by: Wlodzimiez ABX Skiba 2003/2004 Unicode support
9 // Copyright: (c) Julian Smart
10 // Licence: wxWindows licence
11 /////////////////////////////////////////////////////////////////////////////
14 #pragma implementation
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
27 #include "wx/arrstr.h"
33 #if !WXWIN_COMPATIBILITY_2_4
34 static inline wxChar
* copystring(const wxChar
* s
)
35 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
38 extern wxHashTable TexReferences
;
41 extern void DecToHex(int, wxChar
*);
42 void GenerateHTMLIndexFile(wxChar
*fname
);
44 void GenerateHTMLWorkshopFiles(wxChar
*fname
);
45 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
);
46 void HTMLWorkshopStartContents();
47 void HTMLWorkshopEndContents();
49 void OutputContentsFrame(void);
51 #include "readshg.h" // Segmented hypergraphics parsing
53 wxChar
*ChaptersName
= NULL
;
54 wxChar
*SectionsName
= NULL
;
55 wxChar
*SubsectionsName
= NULL
;
56 wxChar
*SubsubsectionsName
= NULL
;
57 wxChar
*TitlepageName
= NULL
;
58 wxChar
*lastFileName
= NULL
;
59 wxChar
*lastTopic
= NULL
;
60 wxChar
*currentFileName
= NULL
;
61 wxChar
*contentsFrameName
= NULL
;
63 static TexChunk
*descriptionItemArg
= NULL
;
64 static TexChunk
*helpRefFilename
= NULL
;
65 static TexChunk
*helpRefText
= NULL
;
66 static int indentLevel
= 0;
67 static int citeCount
= 1;
68 extern FILE *Contents
;
69 FILE *FrameContents
= NULL
;
70 FILE *Titlepage
= NULL
;
71 // FILE *FrameTitlepage = NULL;
73 bool subsectionStarted
= false;
75 // Which column of a row are we in? (Assumes no nested tables, of course)
76 int currentColumn
= 0;
78 // Are we in verbatim mode? If so, format differently.
79 static bool inVerbatim
= false;
81 // Need to know whether we're in a table or figure for benefit
82 // of listoffigures/listoftables
83 static bool inFigure
= false;
84 static bool inTable
= false;
86 // This is defined in the Tex2Any library.
87 extern wxChar
*BigBuffer
;
89 // DHS Two-column table dimensions.
90 static int TwoColWidthA
= -1;
91 static int TwoColWidthB
= -1;
94 class HyperReference
: public wxObject
99 HyperReference(wxChar
*name
, wxChar
*file
)
101 if (name
) refName
= copystring(name
);
102 if (file
) refFile
= copystring(file
);
106 class TexNextPage
: public wxObject
111 TexNextPage(wxChar
*theLabel
, wxChar
*theFile
)
113 label
= copystring(theLabel
);
114 filename
= copystring(theFile
);
123 wxHashTable
TexNextPages(wxKEY_STRING
);
125 static wxChar
*CurrentChapterName
= NULL
;
126 static wxChar
*CurrentChapterFile
= NULL
;
127 static wxChar
*CurrentSectionName
= NULL
;
128 static wxChar
*CurrentSectionFile
= NULL
;
129 static wxChar
*CurrentSubsectionName
= NULL
;
130 static wxChar
*CurrentSubsectionFile
= NULL
;
131 static wxChar
*CurrentSubsubsectionName
= NULL
;
132 static wxChar
*CurrentSubsubsectionFile
= NULL
;
133 static wxChar
*CurrentTopic
= NULL
;
135 static void SetCurrentTopic(wxChar
*s
)
137 if (CurrentTopic
) delete[] CurrentTopic
;
138 CurrentTopic
= copystring(s
);
141 void SetCurrentChapterName(wxChar
*s
, wxChar
*file
)
143 if (CurrentChapterName
) delete[] CurrentChapterName
;
144 CurrentChapterName
= copystring(s
);
145 if (CurrentChapterFile
) delete[] CurrentChapterFile
;
146 CurrentChapterFile
= copystring(file
);
148 currentFileName
= CurrentChapterFile
;
152 void SetCurrentSectionName(wxChar
*s
, wxChar
*file
)
154 if (CurrentSectionName
) delete[] CurrentSectionName
;
155 CurrentSectionName
= copystring(s
);
156 if (CurrentSectionFile
) delete[] CurrentSectionFile
;
157 CurrentSectionFile
= copystring(file
);
159 currentFileName
= CurrentSectionFile
;
162 void SetCurrentSubsectionName(wxChar
*s
, wxChar
*file
)
164 if (CurrentSubsectionName
) delete[] CurrentSubsectionName
;
165 CurrentSubsectionName
= copystring(s
);
166 if (CurrentSubsectionFile
) delete[] CurrentSubsectionFile
;
167 CurrentSubsectionFile
= copystring(file
);
168 currentFileName
= CurrentSubsectionFile
;
171 void SetCurrentSubsubsectionName(wxChar
*s
, wxChar
*file
)
173 if (CurrentSubsubsectionName
) delete[] CurrentSubsubsectionName
;
174 CurrentSubsubsectionName
= copystring(s
);
175 if (CurrentSubsubsectionFile
) delete[] CurrentSubsubsectionFile
;
176 CurrentSubsubsectionFile
= copystring(file
);
177 currentFileName
= CurrentSubsubsectionFile
;
182 // mapping between fileId and filenames if truncateFilenames=false:
183 static wxArrayString gs_filenames
;
187 * Close former filedescriptor and reopen using another filename.
191 void ReopenFile(FILE **fd
, wxChar
**fileName
, const wxChar
*label
)
195 wxFprintf(*fd
, _T("\n</FONT></BODY></HTML>\n"));
200 if (truncateFilenames
)
202 wxSnprintf(buf
, sizeof(buf
), _T("%s%d.htm"), FileRoot
, fileId
);
207 gs_filenames
.Add(wxEmptyString
);
208 wxSnprintf(buf
, sizeof(buf
), _T("%s_%s.html"), FileRoot
, label
);
209 gs_filenames
.Add(buf
);
211 if (*fileName
) delete[] *fileName
;
212 *fileName
= copystring(wxFileNameFromPath(buf
));
213 *fd
= wxFopen(buf
, _T("w"));
214 wxFprintf(*fd
, _T("<HTML>\n"));
218 * Reopen section contents file, i.e. the index appended to each section
219 * in subsectionCombine mode
222 static wxChar
*SectionContentsFilename
= NULL
;
223 static FILE *SectionContentsFD
= NULL
;
225 void ReopenSectionContentsFile(void)
227 if ( SectionContentsFD
)
229 fclose(SectionContentsFD
);
231 if ( SectionContentsFilename
)
232 delete[] SectionContentsFilename
;
233 SectionContentsFD
= NULL
;
234 SectionContentsFilename
= NULL
;
236 // Create the name from the current section filename
237 if ( CurrentSectionFile
)
240 wxStrcpy(buf
, CurrentSectionFile
);
241 wxStripExtension(buf
);
242 wxStrcat(buf
, _T(".con"));
243 SectionContentsFilename
= copystring(buf
);
245 SectionContentsFD
= wxFopen(SectionContentsFilename
, _T("w"));
251 * Given a TexChunk with a string value, scans through the string
252 * converting Latex-isms into HTML-isms, such as 2 newlines -> <P>.
256 void ProcessText2HTML(TexChunk
*chunk
)
258 bool changed
= false;
262 int len
= wxStrlen(chunk
->value
);
265 ch
= chunk
->value
[i
];
267 // 2 newlines means \par
268 if (!inVerbatim
&& chunk
->value
[i
] == 10 && ((len
> i
+1 && chunk
->value
[i
+1] == 10) ||
269 ((len
> i
+1 && chunk
->value
[i
+1] == 13) &&
270 (len
> i
+2 && chunk
->value
[i
+2] == 10))))
272 BigBuffer
[ptr
] = 0; wxStrcat(BigBuffer
, _T("<P>\n\n")); ptr
+= 5;
276 else if (!inVerbatim
&& ch
== '`' && (len
>= i
+1 && chunk
->value
[i
+1] == '`'))
278 BigBuffer
[ptr
] = '"'; ptr
++;
282 else if (!inVerbatim
&& ch
== '`') // Change ` to '
284 BigBuffer
[ptr
] = 39; ptr
++;
288 else if (ch
== '<') // Change < to <
291 wxStrcat(BigBuffer
, _T("<"));
296 else if (ch
== '>') // Change > to >
299 wxStrcat(BigBuffer
, _T(">"));
316 chunk
->value
= copystring(BigBuffer
);
321 * Scan through all chunks starting from the given one,
322 * calling ProcessText2HTML to convert Latex-isms to RTF-isms.
323 * This should be called after Tex2Any has parsed the file,
324 * and before TraverseDocument is called.
328 void Text2HTML(TexChunk
*chunk
)
331 if (stopRunning
) return;
335 case CHUNK_TYPE_MACRO
:
337 TexMacroDef
*def
= chunk
->def
;
339 if (def
&& def
->ignore
)
342 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
345 wxNode
*node
= chunk
->children
.GetFirst();
348 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
349 Text2HTML(child_chunk
);
350 node
= node
->GetNext();
353 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
360 wxNode
*node
= chunk
->children
.GetFirst();
363 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
364 Text2HTML(child_chunk
);
365 node
= node
->GetNext();
370 case CHUNK_TYPE_STRING
:
373 ProcessText2HTML(chunk
);
380 * Add appropriate browse buttons to this page.
384 void AddBrowseButtons(wxChar
*upLabel
, wxChar
*upFilename
,
385 wxChar
*previousLabel
, wxChar
*previousFilename
,
386 wxChar
*thisLabel
, wxChar
*thisFilename
)
388 wxChar contentsReferenceBuf
[80];
389 wxChar upReferenceBuf
[80];
390 wxChar backReferenceBuf
[80];
391 wxChar forwardReferenceBuf
[80];
392 if (htmlBrowseButtons
== HTML_BUTTONS_NONE
)
395 wxChar
*contentsReference
; // no need to initialize because always assigned below
396 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
397 contentsReference
= ContentsNameString
;
400 // contentsReference = "<img align=center src=\"contents.gif\" BORDER=0 ALT=\"Contents\">";
401 contentsReference
= contentsReferenceBuf
;
402 wxSnprintf(contentsReference
, sizeof(contentsReferenceBuf
),
403 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">"),
404 ConvertCase(_T("contents.gif")));
407 wxChar
*upReference
; // no need to initialize because always assigned below
408 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
409 upReference
= UpNameString
;
412 // upReference = "<img align=center src=\"up.gif\" ALT=\"Up\">";
413 upReference
= upReferenceBuf
;
414 wxSnprintf(upReference
, sizeof(upReferenceBuf
),
415 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">"),
416 ConvertCase(_T("up.gif")));
419 wxChar
*backReference
; // no need to initialize because always assigned below
420 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
421 backReference
= _T("<<");
424 // backReference = "<img align=center src=\"back.gif\" ALT=\"Previous\">";
425 backReference
= backReferenceBuf
;
426 wxSnprintf(backReference
, sizeof(backReferenceBuf
),
427 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">"),
428 ConvertCase(_T("back.gif")));
431 wxChar
*forwardReference
; // no need to initialize because always assigned below
432 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
433 forwardReference
= _T(">>");
436 // forwardReference = "<img align=center src=\"forward.gif\" ALT=\"Next\">";
437 forwardReference
= forwardReferenceBuf
;
438 wxSnprintf(forwardReference
, sizeof(forwardReferenceBuf
),
439 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">"),
440 ConvertCase(_T("forward.gif")));
443 TexOutput(_T("<CENTER>"));
452 if (truncateFilenames
)
455 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
456 wxSnprintf(buf
, sizeof(buf
),
457 _T("\n<A HREF=\"%s.%s\">%s</A> "),
458 buf1
, ConvertCase(_T("htm")), contentsReference
);
463 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
464 wxSnprintf(buf
, sizeof(buf
),
465 _T("\n<A HREF=\"%s%s\">%s</A> "),
466 buf1
, ConvertCase(_T("_contents.html")), contentsReference
);
468 // TexOutput(_T("<NOFRAMES>"));
470 // TexOutput(_T("</NOFRAMES>"));
477 if (upLabel
&& upFilename
)
479 if (wxStrlen(upLabel
) > 0)
480 wxSnprintf(buf
, sizeof(buf
),
481 _T("<A HREF=\"%s#%s\">%s</A> "),
482 ConvertCase(upFilename
), upLabel
, upReference
);
484 wxSnprintf(buf
, sizeof(buf
),
485 _T("<A HREF=\"%s\">%s</A> "),
486 ConvertCase(upFilename
), upReference
);
487 if (wxStrcmp(upLabel
, _T("contents")) == 0)
489 // TexOutput(_T("<NOFRAMES>"));
491 // TexOutput(_T("</NOFRAMES>"));
502 if (previousLabel
&& previousFilename
)
504 wxSnprintf(buf
, sizeof(buf
),
505 _T("<A HREF=\"%s#%s\">%s</A> "),
506 ConvertCase(previousFilename
), previousLabel
, backReference
);
507 if (wxStrcmp(previousLabel
, _T("contents")) == 0)
509 // TexOutput(_T("<NOFRAMES>"));
511 // TexOutput(_T("</NOFRAMES>"));
518 // A placeholder so the buttons don't keep moving position
519 wxSnprintf(buf
, sizeof(buf
), _T("%s "), backReference
);
523 wxChar
*nextLabel
= NULL
;
524 wxChar
*nextFilename
= NULL
;
526 // Get the next page, and record the previous page's 'next' page
528 TexNextPage
*nextPage
= (TexNextPage
*)TexNextPages
.Get(thisLabel
);
531 nextLabel
= nextPage
->label
;
532 nextFilename
= nextPage
->filename
;
534 if (previousLabel
&& previousFilename
)
536 TexNextPage
*oldNextPage
= (TexNextPage
*)TexNextPages
.Get(previousLabel
);
540 TexNextPages
.Delete(previousLabel
);
542 TexNextPage
*newNextPage
= new TexNextPage(thisLabel
, thisFilename
);
543 TexNextPages
.Put(previousLabel
, newNextPage
);
551 if (nextLabel
&& nextFilename
)
553 wxSnprintf(buf
, sizeof(buf
),
554 _T("<A HREF=\"%s#%s\">%s</A> "),
555 ConvertCase(nextFilename
), nextLabel
, forwardReference
);
560 // A placeholder so the buttons don't keep moving position
561 wxSnprintf(buf
, sizeof(buf
), _T("%s "), forwardReference
);
566 * Horizontal rule to finish it off nicely.
569 TexOutput(_T("</CENTER>"));
570 TexOutput(_T("<HR>\n"));
572 // Update last topic/filename
574 delete[] lastFileName
;
575 lastFileName
= copystring(thisFilename
);
578 lastTopic
= copystring(thisLabel
);
581 // A colour string is either 3 numbers separated by semicolons (RGB),
582 // or a reference to a GIF. Return the filename or a hex string like #934CE8
583 wxChar
*ParseColourString(wxChar
*bkStr
, bool *isPicture
)
585 static wxChar resStr
[300];
586 wxStrcpy(resStr
, bkStr
);
587 wxStringTokenizer
tok(resStr
, _T(";"), wxTOKEN_STRTOK
);
588 if (tok
.HasMoreTokens())
590 wxString token1
= tok
.GetNextToken();
591 if (!tok
.HasMoreTokens())
598 wxString token2
= tok
.GetNextToken();
600 if (tok
.HasMoreTokens())
602 wxString token3
= tok
.GetNextToken();
604 // Now convert 3 strings into decimal numbers, and then hex numbers.
605 int red
= wxAtoi(token1
.c_str());
606 int green
= wxAtoi(token2
.c_str());
607 int blue
= wxAtoi(token3
.c_str());
609 wxStrcpy(resStr
, _T("#"));
613 wxStrcat(resStr
, buf
);
614 DecToHex(green
, buf
);
615 wxStrcat(resStr
, buf
);
617 wxStrcat(resStr
, buf
);
626 void OutputFont(void)
628 // Only output <font face> if explicitly requested by htmlFaceName= directive in
629 // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's
633 // Output <FONT FACE=...>
634 TexOutput(_T("<FONT FACE=\""));
635 TexOutput(htmlFaceName
);
636 TexOutput(_T("\">\n"));
640 // Output start of <BODY> block
641 void OutputBodyStart(void)
643 TexOutput(_T("\n<BODY"));
644 if (backgroundImageString
)
646 bool isPicture
= false;
647 wxChar
*s
= ParseColourString(backgroundImageString
, &isPicture
);
650 TexOutput(_T(" BACKGROUND=\""));
655 if (backgroundColourString
)
657 bool isPicture
= false;
658 wxChar
*s
= ParseColourString(backgroundColourString
, &isPicture
);
661 TexOutput(_T(" BGCOLOR="));
666 // Set foreground text colour, if one is specified
667 if (textColourString
)
669 bool isPicture
= false;
670 wxChar
*s
= ParseColourString(textColourString
, &isPicture
);
673 TexOutput(_T(" TEXT=")); TexOutput(s
);
676 // Set link text colour, if one is specified
677 if (linkColourString
)
679 bool isPicture
= false;
680 wxChar
*s
= ParseColourString(linkColourString
, &isPicture
);
683 TexOutput(_T(" LINK=")); TexOutput(s
);
686 // Set followed link text colour, if one is specified
687 if (followedLinkColourString
)
689 bool isPicture
= false;
690 wxChar
*s
= ParseColourString(followedLinkColourString
, &isPicture
);
693 TexOutput(_T(" VLINK=")); TexOutput(s
);
696 TexOutput(_T(">\n"));
703 TexOutput(_T("<head>"));
704 if (htmlStylesheet
) {
705 TexOutput(_T("<link rel=stylesheet type=\"text/css\" href=\""));
706 TexOutput(htmlStylesheet
);
707 TexOutput(_T("\">"));
711 void HTMLHeadTo(FILE* f
)
714 wxFprintf(f
,_T("<head><link rel=stylesheet type=\"text/css\" href=\"%s\">"),htmlStylesheet
);
716 wxFprintf(f
,_T("<head>"));
719 // Called on start/end of macro examination
720 void HTMLOnMacro(int macroId
, int no_args
, bool start
)
726 case ltCHAPTERHEADING
:
734 if (macroId
!= ltCHAPTERSTAR
)
737 SetCurrentOutput(NULL
);
738 startedSections
= true;
740 wxChar
*topicName
= FindTopicName(GetNextChunk());
741 ReopenFile(&Chapters
, &ChaptersName
, topicName
);
742 AddTexRef(topicName
, ChaptersName
, ChapterNameString
);
744 SetCurrentChapterName(topicName
, ChaptersName
);
745 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(0, topicName
, ChaptersName
);
747 SetCurrentOutput(Chapters
);
750 TexOutput(_T("<title>"));
751 OutputCurrentSection(); // Repeat section header
752 TexOutput(_T("</title></head>\n"));
755 wxChar titleBuf
[200];
756 if (truncateFilenames
)
757 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s.htm"), wxFileNameFromPath(FileRoot
));
759 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
761 wxFprintf(Chapters
, _T("<A NAME=\"%s\"></A>"), topicName
);
763 AddBrowseButtons(_T(""), titleBuf
, // Up
764 lastTopic
, lastFileName
, // Last topic
765 topicName
, ChaptersName
); // This topic
767 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), topicName
);
769 if (htmlFrameContents
&& FrameContents
)
771 SetCurrentOutput(FrameContents
);
772 wxFprintf(FrameContents
, _T("\n<LI><A HREF=\"%s#%s\" TARGET=\"mainwindow\">"), ConvertCase(ChaptersName
), topicName
);
773 OutputCurrentSection();
774 wxFprintf(FrameContents
, _T("</A>\n"));
777 SetCurrentOutputs(Contents
, Chapters
);
778 wxFprintf(Chapters
, _T("\n<H2>"));
779 OutputCurrentSection();
780 wxFprintf(Contents
, _T("</A>\n"));
781 wxFprintf(Chapters
, _T("</H2>\n"));
783 SetCurrentOutput(Chapters
);
785 // Add this section title to the list of keywords
788 OutputCurrentSectionToString(wxTex2RTFBuffer
);
789 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, ConvertCase(currentFileName
));
796 case ltSECTIONHEADING
:
803 subsectionStarted
= false;
805 if (macroId
!= ltSECTIONSTAR
)
808 SetCurrentOutput(NULL
);
809 startedSections
= true;
811 wxChar
*topicName
= FindTopicName(GetNextChunk());
812 ReopenFile(&Sections
, &SectionsName
, topicName
);
813 AddTexRef(topicName
, SectionsName
, SectionNameString
);
815 SetCurrentSectionName(topicName
, SectionsName
);
816 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(1, topicName
, SectionsName
);
818 SetCurrentOutput(Sections
);
820 TexOutput(_T("<title>"));
821 OutputCurrentSection();
822 TexOutput(_T("</title></head>\n"));
825 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
826 AddBrowseButtons(CurrentChapterName
, CurrentChapterFile
, // Up
827 lastTopic
, lastFileName
, // Last topic
828 topicName
, SectionsName
); // This topic
830 FILE *jumpFrom
= ((DocumentStyle
== LATEX_ARTICLE
) ? Contents
: Chapters
);
832 SetCurrentOutputs(jumpFrom
, Sections
);
833 if (DocumentStyle
== LATEX_ARTICLE
)
834 wxFprintf(jumpFrom
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(SectionsName
), topicName
);
836 wxFprintf(jumpFrom
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SectionsName
), topicName
);
838 wxFprintf(Sections
, _T("\n<H2>"));
839 OutputCurrentSection();
841 if (DocumentStyle
== LATEX_ARTICLE
)
842 wxFprintf(jumpFrom
, _T("</A>\n"));
844 wxFprintf(jumpFrom
, _T("</B></A><BR>\n"));
845 wxFprintf(Sections
, _T("</H2>\n"));
847 SetCurrentOutput(Sections
);
848 // Add this section title to the list of keywords
851 OutputCurrentSectionToString(wxTex2RTFBuffer
);
852 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
858 case ltSUBSECTIONSTAR
:
859 case ltMEMBERSECTION
:
860 case ltFUNCTIONSECTION
:
866 OnError(_T("You cannot have a subsection before a section!"));
872 if (macroId
!= ltSUBSECTIONSTAR
)
875 if ( combineSubSections
&& !subsectionStarted
)
879 // Read old .con file in at this point
881 wxStrcpy(buf
, CurrentSectionFile
);
882 wxStripExtension(buf
);
883 wxStrcat(buf
, _T(".con"));
884 FILE *fd
= wxFopen(buf
, _T("r"));
890 wxPutc(ch
, Sections
);
895 wxFprintf(Sections
, _T("<P>\n"));
897 // Close old file, create a new file for the sub(sub)section contents entries
898 ReopenSectionContentsFile();
901 startedSections
= true;
902 subsectionStarted
= true;
904 wxChar
*topicName
= FindTopicName(GetNextChunk());
906 if ( !combineSubSections
)
908 SetCurrentOutput(NULL
);
909 ReopenFile(&Subsections
, &SubsectionsName
, topicName
);
910 AddTexRef(topicName
, SubsectionsName
, SubsectionNameString
);
911 SetCurrentSubsectionName(topicName
, SubsectionsName
);
912 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SubsectionsName
);
913 SetCurrentOutput(Subsections
);
916 TexOutput(_T("<title>"));
917 OutputCurrentSection();
918 TexOutput(_T("</title></head>\n"));
921 wxFprintf(Subsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
922 AddBrowseButtons(CurrentSectionName
, CurrentSectionFile
, // Up
923 lastTopic
, lastFileName
, // Last topic
924 topicName
, SubsectionsName
); // This topic
926 SetCurrentOutputs(Sections
, Subsections
);
927 wxFprintf(Sections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName
), topicName
);
929 wxFprintf(Subsections
, _T("\n<H3>"));
930 OutputCurrentSection();
931 wxFprintf(Sections
, _T("</B></A><BR>\n"));
932 wxFprintf(Subsections
, _T("</H3>\n"));
934 SetCurrentOutput(Subsections
);
938 AddTexRef(topicName
, SectionsName
, SubsectionNameString
);
939 SetCurrentSubsectionName(topicName
, SectionsName
);
941 // if ( subsectionNo != 0 )
942 wxFprintf(Sections
, _T("\n<HR>\n"));
944 // We're putting everything into the section file
945 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
946 wxFprintf(Sections
, _T("\n<H3>"));
947 OutputCurrentSection();
948 wxFprintf(Sections
, _T("</H3>\n"));
950 SetCurrentOutput(SectionContentsFD
);
951 wxFprintf(SectionContentsFD
, _T("<A HREF=\"#%s\">"), topicName
);
952 OutputCurrentSection();
953 TexOutput(_T("</A><BR>\n"));
955 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
956 SetCurrentOutput(Sections
);
958 // Add this section title to the list of keywords
961 OutputCurrentSectionToString(wxTex2RTFBuffer
);
962 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
969 case ltSUBSUBSECTION
:
970 case ltSUBSUBSECTIONSTAR
:
974 if (!Subsections
&& !combineSubSections
)
976 OnError(_T("You cannot have a subsubsection before a subsection!"));
980 if (macroId
!= ltSUBSUBSECTIONSTAR
)
983 startedSections
= true;
985 wxChar
*topicName
= FindTopicName(GetNextChunk());
987 if ( !combineSubSections
)
989 SetCurrentOutput(NULL
);
990 ReopenFile(&Subsubsections
, &SubsubsectionsName
, topicName
);
991 AddTexRef(topicName
, SubsubsectionsName
, SubsubsectionNameString
);
992 SetCurrentSubsubsectionName(topicName
, SubsubsectionsName
);
993 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(3, topicName
, SubsubsectionsName
);
995 SetCurrentOutput(Subsubsections
);
997 TexOutput(_T("<title>"));
998 OutputCurrentSection();
999 TexOutput(_T("</title></head>\n"));
1002 wxFprintf(Subsubsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1004 AddBrowseButtons(CurrentSubsectionName
, CurrentSubsectionFile
, // Up
1005 lastTopic
, lastFileName
, // Last topic
1006 topicName
, SubsubsectionsName
); // This topic
1008 SetCurrentOutputs(Subsections
, Subsubsections
);
1009 wxFprintf(Subsections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName
), topicName
);
1011 wxFprintf(Subsubsections
, _T("\n<H3>"));
1012 OutputCurrentSection();
1013 wxFprintf(Subsections
, _T("</B></A><BR>\n"));
1014 wxFprintf(Subsubsections
, _T("</H3>\n"));
1018 AddTexRef(topicName
, SectionsName
, SubsubsectionNameString
);
1019 SetCurrentSubsectionName(topicName
, SectionsName
);
1020 wxFprintf(Sections
, _T("\n<HR>\n"));
1022 // We're putting everything into the section file
1023 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1024 wxFprintf(Sections
, _T("\n<H3>"));
1025 OutputCurrentSection();
1026 wxFprintf(Sections
, _T("</H3>\n"));
1027 /* TODO: where do we put subsubsection contents entry - indented, with subsection entries?
1028 SetCurrentOutput(SectionContentsFD);
1029 wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName);
1030 OutputCurrentSection();
1031 TexOutput(_T("</A><BR>"));
1033 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
1034 SetCurrentOutput(Sections
);
1037 // Add this section title to the list of keywords
1040 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1041 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
1050 if ( !combineSubSections
)
1051 SetCurrentOutput(Subsections
);
1053 SetCurrentOutput(Sections
);
1064 if ( !combineSubSections
)
1065 SetCurrentOutput(Subsections
);
1067 SetCurrentOutput(Sections
);
1078 if ( !combineSubSections
)
1079 SetCurrentOutput(Subsections
);
1081 SetCurrentOutput(Sections
);
1092 // TexOutput(_T("<B>void</B>"));
1096 TexOutput(_T("HARDY"));
1100 TexOutput(_T("wxCLIPS"));
1104 TexOutput(_T("&"));
1106 case ltSPECIALAMPERSAND
:
1112 // End cell, start cell
1114 TexOutput(_T("</FONT></TD>"));
1116 // Start new row and cell, setting alignment for the first cell.
1117 if (currentColumn
< noColumns
)
1121 if (TableData
[currentColumn
].justification
== 'c')
1122 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=CENTER>"));
1123 else if (TableData
[currentColumn
].justification
== 'r')
1124 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=RIGHT>"));
1125 else if (TableData
[currentColumn
].absWidth
)
1127 // Convert from points * 20 into pixels.
1128 int points
= TableData
[currentColumn
].width
/ 20;
1130 // Say the display is 100 DPI (dots/pixels per inch).
1131 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1132 int pixels
= (int)(points
* 100.0 / 72.0);
1133 wxSnprintf(buf
, sizeof(buf
), _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1136 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=LEFT>"));
1141 TexOutput(_T("&"));
1145 case ltBACKSLASHCHAR
:
1151 // End row. In fact, tables without use of \row or \ruledrow isn't supported for
1152 // HTML: the syntax is too different (e.g. how do we know where to put the first </TH>
1153 // if we've ended the last row?). So normally you wouldn't use \\ to end a row.
1154 TexOutput(_T("</TR>\n"));
1157 TexOutput(_T("<BR>\n"));
1168 // Start new row and cell, setting alignment for the first cell.
1170 if (TableData
[currentColumn
].justification
== 'c')
1171 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=CENTER>"));
1172 else if (TableData
[currentColumn
].justification
== 'r')
1173 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=RIGHT>"));
1174 else if (TableData
[currentColumn
].absWidth
)
1176 // Convert from points * 20 into pixels.
1177 int points
= TableData
[currentColumn
].width
/ 20;
1179 // Say the display is 100 DPI (dots/pixels per inch).
1180 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1181 int pixels
= (int)(points
* 100.0 / 72.0);
1182 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1185 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=LEFT>"));
1192 // Start new row and cell
1193 TexOutput(_T("</FONT></TD>\n</TR>\n"));
1197 // HTML-only: break until the end of the picture (both margins are clear).
1201 TexOutput(_T("<BR CLEAR=ALL>"));
1204 case ltRTFSP
: // Explicit space, RTF only
1206 case ltSPECIALTILDE
:
1210 #if (1) // if(inVerbatim)
1221 TexOutput(_T("<UL><UL>\n"));
1223 TexOutput(_T("</UL></UL>\n"));
1229 // case ltTWOCOLLIST:
1236 if (macroId
== ltENUMERATE
)
1237 listType
= LATEX_ENUMERATE
;
1238 else if (macroId
== ltITEMIZE
)
1239 listType
= LATEX_ITEMIZE
;
1241 listType
= LATEX_DESCRIPTION
;
1243 itemizeStack
.Insert(new ItemizeStruc(listType
));
1247 TexOutput(_T("<UL>\n"));
1249 case LATEX_ENUMERATE
:
1250 TexOutput(_T("<OL>\n"));
1252 case LATEX_DESCRIPTION
:
1254 TexOutput(_T("<DL>\n"));
1261 if (itemizeStack
.GetFirst())
1263 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
1264 switch (struc
->listType
)
1267 TexOutput(_T("</UL>\n"));
1269 case LATEX_ENUMERATE
:
1270 TexOutput(_T("</OL>\n"));
1272 case LATEX_DESCRIPTION
:
1274 TexOutput(_T("</DL>\n"));
1279 delete itemizeStack
.GetFirst();
1287 TexOutput(_T("\n<TABLE>\n"));
1289 TexOutput(_T("\n</TABLE>\n"));
1299 TexOutput(_T("<P>\n"));
1302 /* For footnotes we need to output the text at the bottom of the page and
1303 * insert a reference to it. Is it worth the trouble...
1305 case ltFOOTNOTEPOPUP:
1309 TexOutput(_T("<FN>"));
1311 else TexOutput(_T("</FN>"));
1318 TexOutput(_T("<TT>"));
1319 else TexOutput(_T("</TT>"));
1327 wxSnprintf(buf
, sizeof(buf
), _T("<PRE>\n"));
1330 else TexOutput(_T("</PRE>\n"));
1338 TexOutput(_T("<CENTER>"));
1340 else TexOutput(_T("</CENTER>"));
1348 TexOutput(_T("{\\ql "));
1350 else TexOutput(_T("}\\par\\pard\n"));
1359 TexOutput(_T("{\\qr "));
1361 else TexOutput(_T("}\\par\\pard\n"));
1369 // Netscape extension
1370 TexOutput(_T("<FONT SIZE=2>"));
1372 else TexOutput(_T("</FONT>"));
1379 // Netscape extension
1380 TexOutput(_T("<FONT SIZE=1>"));
1382 else TexOutput(_T("</FONT>"));
1389 // Netscape extension
1390 TexOutput(_T("<FONT SIZE=3>"));
1392 else TexOutput(_T("</FONT>"));
1399 // Netscape extension
1400 TexOutput(_T("<FONT SIZE=4>"));
1402 else TexOutput(_T("</FONT>"));
1409 // Netscape extension
1410 TexOutput(_T("<FONT SIZE=5>"));
1412 else TexOutput(_T("</FONT>"));
1419 // Netscape extension
1420 TexOutput(_T("<FONT SIZE=6>"));
1422 else TexOutput(_T("</FONT>"));
1431 TexOutput(_T("<B>"));
1433 else TexOutput(_T("</B>"));
1442 TexOutput(_T("<I>"));
1444 else TexOutput(_T("</I>"));
1452 TexOutput(_T("<EM>"));
1454 else TexOutput(_T("</EM>"));
1461 TexOutput(_T("<UL>"));
1463 else TexOutput(_T("</UL>"));
1472 TexOutput(_T("<TT>"));
1474 else TexOutput(_T("</TT>"));
1480 TexOutput(_T("©"), true);
1486 TexOutput(_T("®"), true);
1492 if (start
) TexOutput(_T("<--"));
1497 if (start
) TexOutput(_T("<=="));
1502 if (start
) TexOutput(_T("-->"));
1507 if (start
) TexOutput(_T("==>"));
1510 case ltLEFTRIGHTARROW
:
1512 if (start
) TexOutput(_T("<-->"));
1515 case ltLEFTRIGHTARROW2
:
1517 if (start
) TexOutput(_T("<==>"));
1530 wxNode
*node
= itemizeStack
.GetFirst();
1533 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
1534 struc
->currentItem
+= 1;
1535 if (struc
->listType
== LATEX_DESCRIPTION
)
1537 if (descriptionItemArg
)
1539 TexOutput(_T("<DT> "));
1540 TraverseChildrenFromChunk(descriptionItemArg
);
1541 TexOutput(_T("\n"));
1542 descriptionItemArg
= NULL
;
1544 TexOutput(_T("<DD>"));
1547 TexOutput(_T("<LI>"));
1554 if (start
&& DocumentTitle
&& DocumentAuthor
)
1556 // Add a special label for the contents page.
1557 // TexOutput(_T("<CENTER>\n"));
1558 TexOutput(_T("<A NAME=\"contents\">"));
1559 TexOutput(_T("<H2 ALIGN=CENTER>\n"));
1560 TraverseChildrenFromChunk(DocumentTitle
);
1561 TexOutput(_T("</H2>"));
1562 TexOutput(_T("<P>"));
1563 TexOutput(_T("</A>\n"));
1564 TexOutput(_T("<P>\n\n"));
1565 TexOutput(_T("<H3 ALIGN=CENTER>"));
1566 TraverseChildrenFromChunk(DocumentAuthor
);
1567 TexOutput(_T("</H3><P>\n\n"));
1570 TexOutput(_T("<H3 ALIGN=CENTER>"));
1571 TraverseChildrenFromChunk(DocumentDate
);
1572 TexOutput(_T("</H3><P>\n\n"));
1574 // TexOutput(_T("\n</CENTER>\n"));
1575 TexOutput(_T("\n<P><HR><P>\n"));
1578 // Now do optional frame contents page
1579 if (htmlFrameContents && FrameContents)
1581 SetCurrentOutput(FrameContents);
1583 // Add a special label for the contents page.
1584 TexOutput(_T("<CENTER>\n"));
1585 TexOutput(_T("<H3>\n"));
1586 TraverseChildrenFromChunk(DocumentTitle);
1587 TexOutput(_T("</H3>"));
1588 TexOutput(_T("<P>"));
1589 TexOutput(_T("</A>\n"));
1590 TexOutput(_T("<P>\n\n"));
1591 TexOutput(_T("<H3>"));
1592 TraverseChildrenFromChunk(DocumentAuthor);
1593 TexOutput(_T("</H3><P>\n\n"));
1596 TexOutput(_T("<H4>"));
1597 TraverseChildrenFromChunk(DocumentDate);
1598 TexOutput(_T("</H4><P>\n\n"));
1600 TexOutput(_T("\n</CENTER>\n"));
1601 TexOutput(_T("<P><HR><P>\n"));
1603 SetCurrentOutput(Titlepage);
1616 helpRefFilename
= NULL
;
1621 case ltBIBLIOGRAPHY
:
1625 DefaultOnMacro(macroId
, no_args
, start
);
1629 DefaultOnMacro(macroId
, no_args
, start
);
1630 TexOutput(_T("</DL>\n"));
1638 TexOutput(_T("<HR>\n"));
1646 TexOutput(_T("<HR>\n"));
1650 case ltTABLEOFCONTENTS
:
1654 // NB: if this is uncommented, the table of contents
1655 // completely disappears. If left commented, it's in the wrong
1657 //fflush(Titlepage);
1659 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1665 wxPutc(ch
, Titlepage
);
1673 TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n"));
1674 OnInform(_T("Run Tex2RTF again to include contents page."));
1682 TexOutput(_T("<"));
1688 TexOutput(_T(">"));
1695 TexOutput(_T("<BLOCKQUOTE>"));
1697 TexOutput(_T("</BLOCKQUOTE>"));
1706 TexOutput(_T("\n<CAPTION>"));
1714 if (DocumentStyle
!= LATEX_ARTICLE
)
1715 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1717 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d: "), FigureNameString
, figureNo
);
1723 if (DocumentStyle
!= LATEX_ARTICLE
)
1724 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1726 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d: "), TableNameString
, tableNo
);
1734 TexOutput(_T("\n</CAPTION>\n"));
1736 wxChar
*topicName
= FindTopicName(GetNextChunk());
1738 int n
= inFigure
? figureNo
: tableNo
;
1740 AddTexRef(topicName
, NULL
, NULL
,
1741 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1742 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1748 if (start
) TexOutput(_T("ß"));
1753 if (start
) inFigure
= true;
1754 else inFigure
= false;
1759 if (start
) inTable
= true;
1760 else inTable
= false;
1764 DefaultOnMacro(macroId
, no_args
, start
);
1769 // Called on start/end of argument examination
1770 bool HTMLOnArgument(int macroId
, int arg_no
, bool start
)
1776 case ltCHAPTERHEADING
:
1779 case ltSECTIONHEADING
:
1781 case ltSUBSECTIONSTAR
:
1782 case ltSUBSUBSECTION
:
1783 case ltSUBSUBSECTIONSTAR
:
1785 case ltMEMBERSECTION
:
1786 case ltFUNCTIONSECTION
:
1788 if (!start
&& (arg_no
== 1))
1789 currentSection
= GetArgChunk();
1794 if (start
&& (arg_no
== 1))
1795 TexOutput(_T("<B>"));
1797 if (!start
&& (arg_no
== 1))
1798 TexOutput(_T("</B> "));
1800 if (start
&& (arg_no
== 2))
1802 if (!suppressNameDecoration
) TexOutput(_T("<B>"));
1803 currentMember
= GetArgChunk();
1805 if (!start
&& (arg_no
== 2))
1807 if (!suppressNameDecoration
) TexOutput(_T("</B>"));
1810 if (start
&& (arg_no
== 3))
1812 if (!start
&& (arg_no
== 3))
1818 if (start
&& (arg_no
== 1))
1819 TexOutput(_T("<B>"));
1820 if (!start
&& (arg_no
== 1))
1821 TexOutput(_T("</B> "));
1823 if (start
&& (arg_no
== 2))
1825 if (!suppressNameDecoration
) TexOutput(_T("( "));
1826 currentMember
= GetArgChunk();
1828 if (!start
&& (arg_no
== 2))
1832 if (!start
&& (arg_no
== 3))
1838 if (!start
&& (arg_no
== 1))
1841 if (start
&& (arg_no
== 2))
1842 TexOutput(_T("(*"));
1843 if (!start
&& (arg_no
== 2))
1846 if (start
&& (arg_no
== 2))
1847 currentMember
= GetArgChunk();
1849 if (start
&& (arg_no
== 3))
1851 if (!start
&& (arg_no
== 3))
1857 if (start
&& (arg_no
== 1))
1858 TexOutput(_T("<B>"));
1859 if (!start
&& (arg_no
== 1))
1860 TexOutput(_T("</B>"));
1861 if (start
&& (arg_no
== 2))
1863 TexOutput(_T("<I>"));
1865 if (!start
&& (arg_no
== 2))
1867 TexOutput(_T("</I>"));
1873 if (start
&& (arg_no
== 1))
1874 TexOutput(_T("<B>"));
1875 if (!start
&& (arg_no
== 1))
1876 TexOutput(_T("</B> ")); // This is the difference from param - one space!
1877 if (start
&& (arg_no
== 2))
1879 TexOutput(_T("<I>"));
1881 if (!start
&& (arg_no
== 2))
1883 TexOutput(_T("</I>"));
1889 if (!start
&& (arg_no
== 1))
1892 if (start
&& (arg_no
== 2))
1893 currentMember
= GetArgChunk();
1902 wxChar
*refName
= GetArgData();
1905 TexRef
*texRef
= FindReference(refName
);
1908 sec
= texRef
->sectionNumber
;
1921 if (IsArgOptional())
1923 else if ((GetNoArgs() - arg_no
) == 1)
1926 helpRefText
= GetArgChunk();
1929 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1933 TexChunk
*ref
= GetArgChunk();
1934 TexOutput(_T("<A HREF=\""));
1936 TraverseChildrenFromChunk(ref
);
1938 TexOutput(_T("\">"));
1940 TraverseChildrenFromChunk(helpRefText
);
1941 TexOutput(_T("</A>"));
1951 if (IsArgOptional())
1954 helpRefFilename
= GetArgChunk();
1957 if ((GetNoArgs() - arg_no
) == 1)
1960 helpRefText
= GetArgChunk();
1963 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1967 wxChar
*refName
= GetArgData();
1968 wxChar
*refFilename
= NULL
;
1972 TexRef
*texRef
= FindReference(refName
);
1975 if (texRef
->refFile
&& wxStrcmp(texRef
->refFile
, _T("??")) != 0)
1976 refFilename
= texRef
->refFile
;
1978 TexOutput(_T("<A HREF=\""));
1979 // If a filename is supplied, use it, otherwise try to
1980 // use the filename associated with the reference (from this document).
1981 if (helpRefFilename
)
1983 TraverseChildrenFromChunk(helpRefFilename
);
1986 else if (refFilename
)
1988 TexOutput(ConvertCase(refFilename
));
1992 TexOutput(_T("\">"));
1994 TraverseChildrenFromChunk(helpRefText
);
1995 TexOutput(_T("</A>"));
2000 TraverseChildrenFromChunk(helpRefText
);
2002 TexOutput(_T(" (REF NOT FOUND)"));
2004 errBuf
.Printf(_T("Warning: unresolved reference '%s'"), refName
);
2005 OnInform((wxChar
*)errBuf
.c_str());
2008 else TexOutput(_T("??"));
2023 wxChar
*alignment
= _T("");
2024 if (macroId
== ltIMAGEL
)
2025 alignment
= _T(" align=left");
2026 else if (macroId
== ltIMAGER
)
2027 alignment
= _T(" align=right");
2029 // Try to find an XBM or GIF image first.
2030 wxChar
*filename
= copystring(GetArgData());
2033 wxStrcpy(buf
, filename
);
2034 StripExtension(buf
);
2035 wxStrcat(buf
, _T(".xbm"));
2036 wxString f
= TexPathList
.FindValidPath(buf
);
2038 if (f
== _T("")) // Try for a GIF instead
2040 wxStrcpy(buf
, filename
);
2041 StripExtension(buf
);
2042 wxStrcat(buf
, _T(".gif"));
2043 f
= TexPathList
.FindValidPath(buf
);
2046 if (f
== _T("")) // Try for a JPEG instead
2048 wxStrcpy(buf
, filename
);
2049 StripExtension(buf
);
2050 wxStrcat(buf
, _T(".jpg"));
2051 f
= TexPathList
.FindValidPath(buf
);
2054 if (f
== _T("")) // Try for a PNG instead
2056 wxStrcpy(buf
, filename
);
2057 StripExtension(buf
);
2058 wxStrcat(buf
, _T(".png"));
2059 f
= TexPathList
.FindValidPath(buf
);
2064 wxChar
*inlineFilename
= copystring(f
);
2066 wxChar
*originalFilename
= TexPathList
.FindValidPath(filename
);
2067 // If we have found the existing filename, make the inline
2068 // image point to the original file (could be PS, for example)
2069 if (originalFilename
&& (wxStrcmp(inlineFilename
, originalFilename
) != 0))
2071 TexOutput(_T("<A HREF=\""));
2072 TexOutput(ConvertCase(originalFilename
));
2073 TexOutput(_T("\">"));
2074 TexOutput(_T("<img src=\""));
2075 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2076 TexOutput(_T("\""));
2077 TexOutput(alignment
);
2078 TexOutput(_T("></A>"));
2083 TexOutput(_T("<img src=\""));
2084 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2085 TexOutput(_T("\""));
2086 TexOutput(alignment
);
2088 delete[] inlineFilename
;
2093 // Last resort - a link to a PS file.
2094 TexOutput(_T("<A HREF=\""));
2095 TexOutput(ConvertCase(wxFileNameFromPath(filename
)));
2096 TexOutput(_T("\">Picture</A>\n"));
2097 wxSnprintf(buf
, sizeof(buf
), _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2104 // First arg is PSBOX spec (ignored), second is image file, third is map name.
2107 static wxChar
*imageFile
= NULL
;
2108 if (start
&& (arg_no
== 2))
2110 // Try to find an XBM or GIF image first.
2111 wxChar
*filename
= copystring(GetArgData());
2114 wxStrcpy(buf
, filename
);
2115 StripExtension(buf
);
2116 wxStrcat(buf
, _T(".xbm"));
2117 wxString f
= TexPathList
.FindValidPath(buf
);
2119 if (f
== _T("")) // Try for a GIF instead
2121 wxStrcpy(buf
, filename
);
2122 StripExtension(buf
);
2123 wxStrcat(buf
, _T(".gif"));
2124 f
= TexPathList
.FindValidPath(buf
);
2129 wxSnprintf(buf
, sizeof(buf
), _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2138 imageFile
= copystring(f
);
2141 else if (start
&& (arg_no
== 3))
2145 // First, try to find a .shg (segmented hypergraphics file)
2146 // that we can convert to a map file
2148 wxStrcpy(buf
, imageFile
);
2149 StripExtension(buf
);
2150 wxStrcat(buf
, _T(".shg"));
2151 wxString f
= TexPathList
.FindValidPath(buf
);
2155 // The default HTML file to go to is THIS file (so a no-op)
2156 SHGToMap((wxChar
*)f
.c_str(), currentFileName
);
2159 wxChar
*mapName
= GetArgData();
2160 TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/"));
2164 TexOutput(_T("unknown"));
2165 TexOutput(_T("\">"));
2166 TexOutput(_T("<img src=\""));
2167 TexOutput(ConvertCase(wxFileNameFromPath(imageFile
)));
2168 TexOutput(_T("\" ISMAP></A><P>"));
2188 descriptionItemArg
= GetArgChunk();
2194 case ltTWOCOLITEMRULED
:
2197 if (start && (arg_no == 1))
2198 TexOutput(_T("\n<DT> "));
2199 if (start && (arg_no == 2))
2200 TexOutput(_T("<DD> "));
2206 if (TwoColWidthA
> -1)
2209 wxSnprintf(buf
, sizeof(buf
), _T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA
);
2214 TexOutput(_T("\n<TR><TD VALIGN=TOP>\n"));
2218 TexOutput(_T("\n</FONT></TD>\n"));
2225 if (TwoColWidthB
> -1)
2228 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB
);
2233 TexOutput(_T("\n<TD VALIGN=TOP>\n"));
2237 TexOutput(_T("\n</FONT></TD></TR>\n"));
2241 case ltNUMBEREDBIBITEM
:
2243 if (arg_no
== 1 && start
)
2245 TexOutput(_T("\n<DT> "));
2247 if (arg_no
== 2 && !start
)
2248 TexOutput(_T("<P>\n"));
2254 if (arg_no
== 1 && start
)
2256 wxChar
*citeKey
= GetArgData();
2257 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
2260 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
2261 wxSnprintf(buf
, sizeof(buf
), _T("[%d]"), citeCount
);
2262 ref
->sectionNumber
= copystring(buf
);
2265 wxSnprintf(buf
, sizeof(buf
), _T("\n<DT> [%d] "), citeCount
);
2270 if (arg_no
== 2 && !start
)
2271 TexOutput(_T("<P>\n"));
2275 case ltMARGINPARODD
:
2276 case ltMARGINPAREVEN
:
2282 TexOutput(_T("<HR>\n"));
2286 TexOutput(_T("<HR><P>\n"));
2290 case ltTWOCOLWIDTHA
:
2294 wxChar
*val
= GetArgData();
2295 float points
= ParseUnitArgument(val
);
2296 TwoColWidthA
= (int)((points
* 100.0) / 72.0);
2301 case ltTWOCOLWIDTHB
:
2305 wxChar
*val
= GetArgData();
2306 float points
= ParseUnitArgument(val
);
2307 TwoColWidthB
= (int)((points
* 100.0) / 72.0);
2315 case ltACCENT_GRAVE
:
2319 wxChar
*val
= GetArgData();
2325 TexOutput(_T("à"));
2328 TexOutput(_T("è"));
2331 TexOutput(_T("ì"));
2334 TexOutput(_T("ò"));
2337 TexOutput(_T("ù"));
2340 TexOutput(_T("À"));
2343 TexOutput(_T("È"));
2346 TexOutput(_T("Ì"));
2349 TexOutput(_T("Ò"));
2352 TexOutput(_T("Ì"));
2361 case ltACCENT_ACUTE
:
2365 wxChar
*val
= GetArgData();
2371 TexOutput(_T("á"));
2374 TexOutput(_T("é"));
2377 TexOutput(_T("í"));
2380 TexOutput(_T("ó"));
2383 TexOutput(_T("ú"));
2386 TexOutput(_T("ý"));
2389 TexOutput(_T("Á"));
2392 TexOutput(_T("É"));
2395 TexOutput(_T("Í"));
2398 TexOutput(_T("Ó"));
2401 TexOutput(_T("Ú"));
2404 TexOutput(_T("Ý"));
2413 case ltACCENT_CARET
:
2417 wxChar
*val
= GetArgData();
2423 TexOutput(_T("â"));
2426 TexOutput(_T("ê"));
2429 TexOutput(_T("î"));
2432 TexOutput(_T("ô"));
2435 TexOutput(_T("û"));
2438 TexOutput(_T("Â"));
2441 TexOutput(_T("Ê"));
2444 TexOutput(_T("Î"));
2447 TexOutput(_T("Ô"));
2450 TexOutput(_T("Î"));
2459 case ltACCENT_TILDE
:
2463 wxChar
*val
= GetArgData();
2472 TexOutput(_T("ã"));
2475 TexOutput(_T("ñ"));
2478 TexOutput(_T("õ"));
2481 TexOutput(_T("Ã"));
2484 TexOutput(_T("Ñ"));
2487 TexOutput(_T("Õ"));
2496 case ltACCENT_UMLAUT
:
2500 wxChar
*val
= GetArgData();
2506 TexOutput(_T("ä"));
2509 TexOutput(_T("ë"));
2512 TexOutput(_T("ï"));
2515 TexOutput(_T("ö"));
2518 TexOutput(_T("ü"));
2521 TexOutput(_T("ÿ"));
2524 TexOutput(_T("Ä"));
2527 TexOutput(_T("Ë"));
2530 TexOutput(_T("Ï"));
2533 TexOutput(_T("Ö"));
2536 TexOutput(_T("Ü"));
2539 TexOutput(_T("Ÿ"));
2552 wxChar
*val
= GetArgData();
2558 TexOutput(_T("å"));
2561 TexOutput(_T("Å"));
2574 wxChar
*val
= GetArgData();
2577 bool isPicture
= false;
2578 ParseColourString(val
, &isPicture
);
2581 if (backgroundImageString
)
2582 delete[] backgroundImageString
;
2583 backgroundImageString
= copystring(val
);
2587 if (backgroundColourString
)
2588 delete[] backgroundColourString
;
2589 backgroundColourString
= copystring(val
);
2595 case ltBACKGROUNDIMAGE
:
2599 wxChar
*val
= GetArgData();
2602 if (backgroundImageString
)
2603 delete[] backgroundImageString
;
2604 backgroundImageString
= copystring(val
);
2609 case ltBACKGROUNDCOLOUR
:
2613 wxChar
*val
= GetArgData();
2616 if (backgroundColourString
)
2617 delete[] backgroundColourString
;
2618 backgroundColourString
= copystring(val
);
2627 wxChar
*val
= GetArgData();
2630 if (textColourString
)
2631 delete[] textColourString
;
2632 textColourString
= copystring(val
);
2641 wxChar
*val
= GetArgData();
2644 if (linkColourString
)
2645 delete[] linkColourString
;
2646 linkColourString
= copystring(val
);
2651 case ltFOLLOWEDLINKCOLOUR
:
2655 wxChar
*val
= GetArgData();
2658 if (followedLinkColourString
)
2659 delete[] followedLinkColourString
;
2660 followedLinkColourString
= copystring(val
);
2665 case ltACCENT_CADILLA
:
2669 wxChar
*val
= GetArgData();
2675 TexOutput(_T("ç"));
2678 TexOutput(_T("Ç"));
2689 case ltFOOTNOTEPOPUP:
2699 case ltSUPERTABULAR
:
2705 currentRowNumber
= 0;
2708 tableVerticalLineLeft
= false;
2709 tableVerticalLineRight
= false;
2711 wxChar
*alignString
= copystring(GetArgData());
2712 ParseTableArgument(alignString
);
2714 TexOutput(_T("<TABLE BORDER>\n"));
2716 // Write the first row formatting for compatibility
2717 // with standard Latex
2718 if (compatibilityMode
)
2720 TexOutput(_T("<TR>\n<TD>"));
2723 for (int i = 0; i < noColumns; i++)
2725 currentWidth += TableData[i].width;
2726 wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth);
2729 TexOutput(_T("\\pard\\intbl\n"));
2732 delete[] alignString
;
2737 else if (arg_no
== 2 && !start
)
2739 TexOutput(_T("</TABLE>\n"));
2744 case ltTHEBIBLIOGRAPHY
:
2746 if (start
&& (arg_no
== 1))
2748 ReopenFile(&Chapters
, &ChaptersName
, _T("bibliography"));
2749 AddTexRef(_T("bibliography"), ChaptersName
, _T("bibliography"));
2750 SetCurrentSubsectionName(_T("bibliography"), ChaptersName
);
2754 SetCurrentOutput(Chapters
);
2756 wxChar titleBuf
[150];
2757 if (truncateFilenames
)
2758 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s.htm"), wxFileNameFromPath(FileRoot
));
2760 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
2763 TexOutput(_T("<title>"));
2764 TexOutput(ReferencesNameString
);
2765 TexOutput(_T("</title></head>\n"));
2768 wxFprintf(Chapters
, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString
);
2769 AddBrowseButtons(_T("contents"), titleBuf
, // Up
2770 lastTopic
, lastFileName
, // Last topic
2771 _T("bibliography"), ChaptersName
); // This topic
2773 SetCurrentOutputs(Contents
, Chapters
);
2774 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), "bibliography");
2776 wxFprintf(Contents
, _T("%s</A>\n"), ReferencesNameString
);
2777 wxFprintf(Chapters
, _T("</H2>\n</A>\n"));
2779 SetCurrentOutput(Chapters
);
2782 if (!start
&& (arg_no
== 2))
2789 /* Build up list of keywords associated with topics */
2792 // wxChar *entry = GetArgData();
2794 OutputChunkToString(GetArgChunk(), buf
);
2797 AddKeyWordForTopic(CurrentTopic
, buf
, currentFileName
);
2811 wxChar
*name
= GetArgData();
2813 if (!FindColourHTMLString(name
, buf2
))
2815 wxStrcpy(buf2
, _T("#000000"));
2817 wxSnprintf(buf
, sizeof(buf
), _T("Could not find colour name %s"), name
);
2820 TexOutput(_T("<FONT COLOR=\""));
2822 TexOutput(_T("\">"));
2835 if (arg_no
== 2) TexOutput(_T("</FONT>"));
2839 case ltINSERTATLEVEL
:
2841 // This macro allows you to insert text at a different level
2842 // from the current level, e.g. into the Sections from within a subsubsection.
2845 static int currentLevelNo
= 1;
2846 static FILE* oldLevelFile
= Chapters
;
2853 oldLevelFile
= CurrentOutput1
;
2855 wxChar
*str
= GetArgData();
2856 currentLevelNo
= wxAtoi(str
);
2858 // TODO: cope with article style (no chapters)
2859 switch (currentLevelNo
)
2863 outputFile
= Chapters
;
2868 outputFile
= Sections
;
2873 outputFile
= Subsections
;
2878 outputFile
= Subsubsections
;
2888 CurrentOutput1
= outputFile
;
2904 CurrentOutput1
= oldLevelFile
;
2910 return DefaultOnArgument(macroId
, arg_no
, start
);
2922 tableVerticalLineLeft
= false;
2923 tableVerticalLineRight
= false;
2926 if (InputFile
&& OutputFile
)
2928 // Do some HTML-specific transformations on all the strings,
2930 Text2HTML(GetTopLevelChunk());
2933 if (truncateFilenames
)
2934 wxSnprintf(buf
, sizeof(buf
), _T("%s.htm"), FileRoot
);
2936 wxSnprintf(buf
, sizeof(buf
), _T("%s_contents.html"), FileRoot
);
2937 if (TitlepageName
) delete[] TitlepageName
;
2938 TitlepageName
= copystring(buf
);
2939 Titlepage
= wxFopen(buf
, _T("w"));
2941 if (truncateFilenames
)
2942 wxSnprintf(buf
, sizeof(buf
), _T("%s_fc.htm"), FileRoot
);
2944 wxSnprintf(buf
, sizeof(buf
), _T("%s_fcontents.html"), FileRoot
);
2946 contentsFrameName
= copystring(buf
);
2948 Contents
= wxFopen(TmpContentsName
, _T("w"));
2950 if (htmlFrameContents
)
2952 // FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
2953 FrameContents
= wxFopen(contentsFrameName
, _T("w"));
2954 wxFprintf(FrameContents
, _T("<HTML>\n<UL>\n"));
2957 if (!Titlepage
|| !Contents
)
2959 OnError(_T("Cannot open output file!"));
2962 AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName
), ContentsNameString
);
2964 wxFprintf(Contents
, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString
);
2966 wxFprintf(Contents
, _T("<UL>\n"));
2968 SetCurrentOutput(Titlepage
);
2969 if (htmlWorkshopFiles
) HTMLWorkshopStartContents();
2970 OnInform(_T("Converting..."));
2973 wxFprintf(Contents
, _T("</UL>\n\n"));
2975 // SetCurrentOutput(Titlepage);
2980 // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
2987 wxFprintf(FrameContents
, _T("\n</UL>\n"));
2988 wxFprintf(FrameContents
, _T("</HTML>\n"));
2989 fclose(FrameContents
);
2990 FrameContents
= NULL
;
2995 wxFprintf(Chapters
, _T("\n</FONT></BODY></HTML>\n"));
3001 wxFprintf(Sections
, _T("\n</FONT></BODY></HTML>\n"));
3005 if (Subsections
&& !combineSubSections
)
3007 wxFprintf(Subsections
, _T("\n</FONT></BODY></HTML>\n"));
3008 fclose(Subsections
);
3011 if (Subsubsections
&& !combineSubSections
)
3013 wxFprintf(Subsubsections
, _T("\n</FONT></BODY></HTML>\n"));
3014 fclose(Subsubsections
);
3015 Subsubsections
= NULL
;
3017 if ( SectionContentsFD
)
3019 fclose(SectionContentsFD
);
3020 SectionContentsFD
= NULL
;
3023 // Create a temporary file for the title page header, add some info,
3024 // and concat the titlepage just generated.
3025 // This is necessary in order to put the title of the document
3026 // at the TOP of the file within <HEAD>, even though we only find out
3027 // what it is later on.
3028 FILE *tmpTitle
= wxFopen(_T("title.tmp"), _T("w"));
3033 SetCurrentOutput(tmpTitle
);
3035 TexOutput(_T("\n<TITLE>"));
3036 TraverseChildrenFromChunk(DocumentTitle
);
3037 TexOutput(_T("</TITLE></HEAD>\n"));
3041 SetCurrentOutput(tmpTitle
);
3042 HTMLHeadTo(tmpTitle
);
3044 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString
);
3046 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot
));
3049 // Output frame information
3050 if (htmlFrameContents
)
3052 wxChar firstFileName
[300];
3053 if (truncateFilenames
)
3054 wxSnprintf(firstFileName
, sizeof(firstFileName
), _T("%s1.htm"), FileRoot
);
3056 wxStrcpy(firstFileName
, gs_filenames
[1].c_str());
3058 wxFprintf(tmpTitle
, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
3060 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName
)));
3061 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName
)));
3062 wxFprintf(tmpTitle
, _T("</FRAMESET>\n"));
3064 wxFprintf(tmpTitle
, _T("<NOFRAMES>\n"));
3067 // Output <BODY...> to temporary title page
3072 FILE *fd
= wxFopen(TitlepageName
, _T("r"));
3078 wxPutc(ch
, tmpTitle
);
3084 wxFprintf(tmpTitle
, _T("\n</FONT></BODY>\n"));
3086 if (htmlFrameContents
)
3088 wxFprintf(tmpTitle
, _T("\n</NOFRAMES>\n"));
3090 wxFprintf(tmpTitle
, _T("\n</HTML>\n"));
3093 if (wxFileExists(TitlepageName
)) wxRemoveFile(TitlepageName
);
3094 if (!wxRenameFile(_T("title.tmp"), TitlepageName
))
3096 wxCopyFile(_T("title.tmp"), TitlepageName
);
3097 wxRemoveFile(_T("title.tmp"));
3101 if (lastFileName
) delete[] lastFileName
;
3102 lastFileName
= NULL
;
3103 if (lastTopic
) delete[] lastTopic
;
3106 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
3108 if (!wxRenameFile(TmpContentsName
, ContentsName
))
3110 wxCopyFile(TmpContentsName
, ContentsName
);
3111 wxRemoveFile(TmpContentsName
);
3114 // Generate .htx file if requested
3117 wxChar htmlIndexName
[300];
3118 wxSnprintf(htmlIndexName
, sizeof(htmlIndexName
), _T("%s.htx"), FileRoot
);
3119 GenerateHTMLIndexFile(htmlIndexName
);
3122 // Generate HTML Help Workshop files if requested
3123 if (htmlWorkshopFiles
)
3125 HTMLWorkshopEndContents();
3126 GenerateHTMLWorkshopFiles(FileRoot
);
3136 // Output .htx index file
3137 void GenerateHTMLIndexFile(wxChar
*fname
)
3139 FILE *fd
= wxFopen(fname
, _T("w"));
3143 TopicTable
.BeginFind();
3144 wxHashTable::Node
*node
= TopicTable
.Next();
3147 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3148 const wxChar
*topicName
= node
->GetKeyString();
3149 if (texTopic
->filename
&& texTopic
->keywords
)
3151 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3154 wxChar
*s
= (wxChar
*)node1
->GetData();
3155 wxFprintf(fd
, _T("%s|%s|%s\n"), topicName
, texTopic
->filename
, s
);
3156 node1
= node1
->GetNext();
3159 node
= TopicTable
.Next();
3170 // output .hpp, .hhc and .hhk files:
3173 void GenerateHTMLWorkshopFiles(wxChar
*fname
)
3178 /* Generate project file : */
3180 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhp"), fname
);
3181 f
= wxFopen(buf
, _T("wt"));
3184 _T("Compatibility=1.1\n")
3185 _T("Full-text search=Yes\n")
3186 _T("Contents file=%s.hhc\n")
3187 _T("Compiled file=%s.chm\n")
3188 _T("Default Window=%sHelp\n")
3189 _T("Default topic=%s\n")
3190 _T("Index file=%s.hhk\n")
3192 wxFileNameFromPath(fname
),
3193 wxFileNameFromPath(fname
),
3194 wxFileNameFromPath(fname
),
3195 wxFileNameFromPath(TitlepageName
),
3196 wxFileNameFromPath(fname
)
3199 if (DocumentTitle
) {
3200 SetCurrentOutput(f
);
3201 TraverseChildrenFromChunk(DocumentTitle
);
3203 else wxFprintf(f
, _T("(unknown)"));
3205 wxFprintf(f
, _T("\n\n[WINDOWS]\n")
3206 _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"),
3207 wxFileNameFromPath(fname
),
3208 wxFileNameFromPath(fname
),
3209 wxFileNameFromPath(fname
),
3210 wxFileNameFromPath(TitlepageName
));
3213 wxFprintf(f
, _T("\n\n[FILES]\n"));
3214 wxFprintf(f
, _T("%s\n"), wxFileNameFromPath(TitlepageName
));
3215 for (int i
= 1; i
<= fileId
; i
++) {
3216 if (truncateFilenames
)
3217 wxSnprintf(buf
, sizeof(buf
), _T("%s%d.htm"), wxFileNameFromPath(FileRoot
), i
);
3219 wxStrcpy(buf
, wxFileNameFromPath(gs_filenames
[i
].c_str()));
3220 wxFprintf(f
, _T("%s\n"), buf
);
3224 /* Generate index file : */
3226 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhk"), fname
);
3227 f
= wxFopen(buf
, _T("wt"));
3230 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3235 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3236 _T("<!-- Sitemap 1.0 -->\n")
3237 _T("</HEAD><BODY>\n")
3238 _T("<OBJECT type=\"text/site properties\">\n")
3239 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3243 TopicTable
.BeginFind();
3244 wxHashTable::Node
*node
= TopicTable
.Next();
3247 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3248 const wxChar
*topicName
= node
->GetKeyString();
3249 if (texTopic
->filename
&& texTopic
->keywords
)
3251 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3254 wxChar
*s
= (wxChar
*)node1
->GetData();
3256 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3257 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3258 _T(" <param name=\"Name\" value=\"%s\">\n")
3260 texTopic
->filename
, topicName
, s
);
3261 node1
= node1
->GetNext();
3264 node
= TopicTable
.Next();
3267 wxFprintf(f
, _T("</UL>\n"));
3273 static FILE *HTMLWorkshopContents
= NULL
;
3274 static int HTMLWorkshopLastLevel
= 0;
3276 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
)
3280 if (level
> HTMLWorkshopLastLevel
)
3281 for (i
= HTMLWorkshopLastLevel
; i
< level
; i
++)
3282 wxFprintf(HTMLWorkshopContents
, _T("<UL>"));
3283 if (level
< HTMLWorkshopLastLevel
)
3284 for (i
= level
; i
< HTMLWorkshopLastLevel
; i
++)
3285 wxFprintf(HTMLWorkshopContents
, _T("</UL>"));
3287 SetCurrentOutput(HTMLWorkshopContents
);
3288 wxFprintf(HTMLWorkshopContents
,
3289 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3290 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3291 _T(" <param name=\"Name\" value=\""),
3293 OutputCurrentSection();
3294 wxFprintf(HTMLWorkshopContents
,
3296 _T(" </OBJECT>\n"));
3297 HTMLWorkshopLastLevel
= level
;
3301 void HTMLWorkshopStartContents()
3304 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhc"), FileRoot
);
3305 HTMLWorkshopContents
= wxFopen(buf
, _T("wt"));
3306 HTMLWorkshopLastLevel
= 0;
3308 wxFprintf(HTMLWorkshopContents
,
3309 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3311 HTMLHeadTo(HTMLWorkshopContents
);
3312 wxFprintf(HTMLWorkshopContents
,
3314 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3315 _T("<!-- Sitemap 1.0 -->\n")
3316 _T("</HEAD><BODY>\n")
3317 _T("<OBJECT type=\"text/site properties\">\n")
3318 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3321 _T("<LI> <OBJECT type=\"text/sitemap\">\n")
3322 _T("<param name=\"Local\" value=\"%s\">\n")
3323 _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"),
3324 wxFileNameFromPath(TitlepageName
)
3330 void HTMLWorkshopEndContents()
3332 for (int i
= HTMLWorkshopLastLevel
; i
>= 0; i
--)
3333 wxFprintf(HTMLWorkshopContents
, _T("</UL>\n"));
3334 fclose(HTMLWorkshopContents
);