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
)
877 // Read old .con file in at this point
879 wxStrcpy(buf
, CurrentSectionFile
);
880 wxStripExtension(buf
);
881 wxStrcat(buf
, _T(".con"));
882 FILE *fd
= wxFopen(buf
, _T("r"));
893 wxFprintf(Sections
, _T("<P>\n"));
895 // Close old file, create a new file for the sub(sub)section contents entries
896 ReopenSectionContentsFile();
899 startedSections
= true;
900 subsectionStarted
= true;
902 wxChar
*topicName
= FindTopicName(GetNextChunk());
904 if ( !combineSubSections
)
906 SetCurrentOutput(NULL
);
907 ReopenFile(&Subsections
, &SubsectionsName
, topicName
);
908 AddTexRef(topicName
, SubsectionsName
, SubsectionNameString
);
909 SetCurrentSubsectionName(topicName
, SubsectionsName
);
910 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SubsectionsName
);
911 SetCurrentOutput(Subsections
);
914 TexOutput(_T("<title>"));
915 OutputCurrentSection();
916 TexOutput(_T("</title></head>\n"));
919 wxFprintf(Subsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
920 AddBrowseButtons(CurrentSectionName
, CurrentSectionFile
, // Up
921 lastTopic
, lastFileName
, // Last topic
922 topicName
, SubsectionsName
); // This topic
924 SetCurrentOutputs(Sections
, Subsections
);
925 wxFprintf(Sections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName
), topicName
);
927 wxFprintf(Subsections
, _T("\n<H3>"));
928 OutputCurrentSection();
929 wxFprintf(Sections
, _T("</B></A><BR>\n"));
930 wxFprintf(Subsections
, _T("</H3>\n"));
932 SetCurrentOutput(Subsections
);
936 AddTexRef(topicName
, SectionsName
, SubsectionNameString
);
937 SetCurrentSubsectionName(topicName
, SectionsName
);
939 // if ( subsectionNo != 0 )
940 wxFprintf(Sections
, _T("\n<HR>\n"));
942 // We're putting everything into the section file
943 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
944 wxFprintf(Sections
, _T("\n<H3>"));
945 OutputCurrentSection();
946 wxFprintf(Sections
, _T("</H3>\n"));
948 SetCurrentOutput(SectionContentsFD
);
949 wxFprintf(SectionContentsFD
, _T("<A HREF=\"#%s\">"), topicName
);
950 OutputCurrentSection();
951 TexOutput(_T("</A><BR>\n"));
953 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
954 SetCurrentOutput(Sections
);
956 // Add this section title to the list of keywords
959 OutputCurrentSectionToString(wxTex2RTFBuffer
);
960 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
967 case ltSUBSUBSECTION
:
968 case ltSUBSUBSECTIONSTAR
:
972 if (!Subsections
&& !combineSubSections
)
974 OnError(_T("You cannot have a subsubsection before a subsection!"));
978 if (macroId
!= ltSUBSUBSECTIONSTAR
)
981 startedSections
= true;
983 wxChar
*topicName
= FindTopicName(GetNextChunk());
985 if ( !combineSubSections
)
987 SetCurrentOutput(NULL
);
988 ReopenFile(&Subsubsections
, &SubsubsectionsName
, topicName
);
989 AddTexRef(topicName
, SubsubsectionsName
, SubsubsectionNameString
);
990 SetCurrentSubsubsectionName(topicName
, SubsubsectionsName
);
991 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(3, topicName
, SubsubsectionsName
);
993 SetCurrentOutput(Subsubsections
);
995 TexOutput(_T("<title>"));
996 OutputCurrentSection();
997 TexOutput(_T("</title></head>\n"));
1000 wxFprintf(Subsubsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1002 AddBrowseButtons(CurrentSubsectionName
, CurrentSubsectionFile
, // Up
1003 lastTopic
, lastFileName
, // Last topic
1004 topicName
, SubsubsectionsName
); // This topic
1006 SetCurrentOutputs(Subsections
, Subsubsections
);
1007 wxFprintf(Subsections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName
), topicName
);
1009 wxFprintf(Subsubsections
, _T("\n<H3>"));
1010 OutputCurrentSection();
1011 wxFprintf(Subsections
, _T("</B></A><BR>\n"));
1012 wxFprintf(Subsubsections
, _T("</H3>\n"));
1016 AddTexRef(topicName
, SectionsName
, SubsubsectionNameString
);
1017 SetCurrentSubsectionName(topicName
, SectionsName
);
1018 wxFprintf(Sections
, _T("\n<HR>\n"));
1020 // We're putting everything into the section file
1021 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1022 wxFprintf(Sections
, _T("\n<H3>"));
1023 OutputCurrentSection();
1024 wxFprintf(Sections
, _T("</H3>\n"));
1025 /* TODO: where do we put subsubsection contents entry - indented, with subsection entries?
1026 SetCurrentOutput(SectionContentsFD);
1027 wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName);
1028 OutputCurrentSection();
1029 TexOutput(_T("</A><BR>"));
1031 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
1032 SetCurrentOutput(Sections
);
1035 // Add this section title to the list of keywords
1038 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1039 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
1048 if ( !combineSubSections
)
1049 SetCurrentOutput(Subsections
);
1051 SetCurrentOutput(Sections
);
1062 if ( !combineSubSections
)
1063 SetCurrentOutput(Subsections
);
1065 SetCurrentOutput(Sections
);
1076 if ( !combineSubSections
)
1077 SetCurrentOutput(Subsections
);
1079 SetCurrentOutput(Sections
);
1090 // TexOutput(_T("<B>void</B>"));
1094 TexOutput(_T("HARDY"));
1098 TexOutput(_T("wxCLIPS"));
1102 TexOutput(_T("&"));
1104 case ltSPECIALAMPERSAND
:
1110 // End cell, start cell
1112 TexOutput(_T("</FONT></TD>"));
1114 // Start new row and cell, setting alignment for the first cell.
1115 if (currentColumn
< noColumns
)
1119 if (TableData
[currentColumn
].justification
== 'c')
1120 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=CENTER>"));
1121 else if (TableData
[currentColumn
].justification
== 'r')
1122 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=RIGHT>"));
1123 else if (TableData
[currentColumn
].absWidth
)
1125 // Convert from points * 20 into pixels.
1126 int points
= TableData
[currentColumn
].width
/ 20;
1128 // Say the display is 100 DPI (dots/pixels per inch).
1129 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1130 int pixels
= (int)(points
* 100.0 / 72.0);
1131 wxSnprintf(buf
, sizeof(buf
), _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1134 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=LEFT>"));
1139 TexOutput(_T("&"));
1143 case ltBACKSLASHCHAR
:
1149 // End row. In fact, tables without use of \row or \ruledrow isn't supported for
1150 // HTML: the syntax is too different (e.g. how do we know where to put the first </TH>
1151 // if we've ended the last row?). So normally you wouldn't use \\ to end a row.
1152 TexOutput(_T("</TR>\n"));
1155 TexOutput(_T("<BR>\n"));
1166 // Start new row and cell, setting alignment for the first cell.
1168 if (TableData
[currentColumn
].justification
== 'c')
1169 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=CENTER>"));
1170 else if (TableData
[currentColumn
].justification
== 'r')
1171 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=RIGHT>"));
1172 else if (TableData
[currentColumn
].absWidth
)
1174 // Convert from points * 20 into pixels.
1175 int points
= TableData
[currentColumn
].width
/ 20;
1177 // Say the display is 100 DPI (dots/pixels per inch).
1178 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1179 int pixels
= (int)(points
* 100.0 / 72.0);
1180 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1183 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=LEFT>"));
1190 // Start new row and cell
1191 TexOutput(_T("</FONT></TD>\n</TR>\n"));
1195 // HTML-only: break until the end of the picture (both margins are clear).
1199 TexOutput(_T("<BR CLEAR=ALL>"));
1202 case ltRTFSP
: // Explicit space, RTF only
1204 case ltSPECIALTILDE
:
1208 #if (1) // if(inVerbatim)
1219 TexOutput(_T("<UL><UL>\n"));
1221 TexOutput(_T("</UL></UL>\n"));
1227 // case ltTWOCOLLIST:
1234 if (macroId
== ltENUMERATE
)
1235 listType
= LATEX_ENUMERATE
;
1236 else if (macroId
== ltITEMIZE
)
1237 listType
= LATEX_ITEMIZE
;
1239 listType
= LATEX_DESCRIPTION
;
1241 itemizeStack
.Insert(new ItemizeStruc(listType
));
1245 TexOutput(_T("<UL>\n"));
1247 case LATEX_ENUMERATE
:
1248 TexOutput(_T("<OL>\n"));
1250 case LATEX_DESCRIPTION
:
1252 TexOutput(_T("<DL>\n"));
1259 if (itemizeStack
.GetFirst())
1261 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
1262 switch (struc
->listType
)
1265 TexOutput(_T("</UL>\n"));
1267 case LATEX_ENUMERATE
:
1268 TexOutput(_T("</OL>\n"));
1270 case LATEX_DESCRIPTION
:
1272 TexOutput(_T("</DL>\n"));
1277 delete itemizeStack
.GetFirst();
1285 TexOutput(_T("\n<TABLE>\n"));
1287 TexOutput(_T("\n</TABLE>\n"));
1297 TexOutput(_T("<P>\n"));
1300 /* For footnotes we need to output the text at the bottom of the page and
1301 * insert a reference to it. Is it worth the trouble...
1303 case ltFOOTNOTEPOPUP:
1307 TexOutput(_T("<FN>"));
1309 else TexOutput(_T("</FN>"));
1316 TexOutput(_T("<TT>"));
1317 else TexOutput(_T("</TT>"));
1325 wxSnprintf(buf
, sizeof(buf
), _T("<PRE>\n"));
1328 else TexOutput(_T("</PRE>\n"));
1336 TexOutput(_T("<CENTER>"));
1338 else TexOutput(_T("</CENTER>"));
1346 TexOutput(_T("{\\ql "));
1348 else TexOutput(_T("}\\par\\pard\n"));
1357 TexOutput(_T("{\\qr "));
1359 else TexOutput(_T("}\\par\\pard\n"));
1367 // Netscape extension
1368 TexOutput(_T("<FONT SIZE=2>"));
1370 else TexOutput(_T("</FONT>"));
1377 // Netscape extension
1378 TexOutput(_T("<FONT SIZE=1>"));
1380 else TexOutput(_T("</FONT>"));
1387 // Netscape extension
1388 TexOutput(_T("<FONT SIZE=3>"));
1390 else TexOutput(_T("</FONT>"));
1397 // Netscape extension
1398 TexOutput(_T("<FONT SIZE=4>"));
1400 else TexOutput(_T("</FONT>"));
1407 // Netscape extension
1408 TexOutput(_T("<FONT SIZE=5>"));
1410 else TexOutput(_T("</FONT>"));
1417 // Netscape extension
1418 TexOutput(_T("<FONT SIZE=6>"));
1420 else TexOutput(_T("</FONT>"));
1429 TexOutput(_T("<B>"));
1431 else TexOutput(_T("</B>"));
1440 TexOutput(_T("<I>"));
1442 else TexOutput(_T("</I>"));
1450 TexOutput(_T("<EM>"));
1452 else TexOutput(_T("</EM>"));
1459 TexOutput(_T("<UL>"));
1461 else TexOutput(_T("</UL>"));
1470 TexOutput(_T("<TT>"));
1472 else TexOutput(_T("</TT>"));
1478 TexOutput(_T("©"), true);
1484 TexOutput(_T("®"), true);
1490 if (start
) TexOutput(_T("<--"));
1495 if (start
) TexOutput(_T("<=="));
1500 if (start
) TexOutput(_T("-->"));
1505 if (start
) TexOutput(_T("==>"));
1508 case ltLEFTRIGHTARROW
:
1510 if (start
) TexOutput(_T("<-->"));
1513 case ltLEFTRIGHTARROW2
:
1515 if (start
) TexOutput(_T("<==>"));
1528 wxNode
*node
= itemizeStack
.GetFirst();
1531 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
1532 struc
->currentItem
+= 1;
1533 if (struc
->listType
== LATEX_DESCRIPTION
)
1535 if (descriptionItemArg
)
1537 TexOutput(_T("<DT> "));
1538 TraverseChildrenFromChunk(descriptionItemArg
);
1539 TexOutput(_T("\n"));
1540 descriptionItemArg
= NULL
;
1542 TexOutput(_T("<DD>"));
1545 TexOutput(_T("<LI>"));
1552 if (start
&& DocumentTitle
&& DocumentAuthor
)
1554 // Add a special label for the contents page.
1555 // TexOutput(_T("<CENTER>\n"));
1556 TexOutput(_T("<A NAME=\"contents\">"));
1557 TexOutput(_T("<H2 ALIGN=CENTER>\n"));
1558 TraverseChildrenFromChunk(DocumentTitle
);
1559 TexOutput(_T("</H2>"));
1560 TexOutput(_T("<P>"));
1561 TexOutput(_T("</A>\n"));
1562 TexOutput(_T("<P>\n\n"));
1563 TexOutput(_T("<H3 ALIGN=CENTER>"));
1564 TraverseChildrenFromChunk(DocumentAuthor
);
1565 TexOutput(_T("</H3><P>\n\n"));
1568 TexOutput(_T("<H3 ALIGN=CENTER>"));
1569 TraverseChildrenFromChunk(DocumentDate
);
1570 TexOutput(_T("</H3><P>\n\n"));
1572 // TexOutput(_T("\n</CENTER>\n"));
1573 TexOutput(_T("\n<P><HR><P>\n"));
1576 // Now do optional frame contents page
1577 if (htmlFrameContents && FrameContents)
1579 SetCurrentOutput(FrameContents);
1581 // Add a special label for the contents page.
1582 TexOutput(_T("<CENTER>\n"));
1583 TexOutput(_T("<H3>\n"));
1584 TraverseChildrenFromChunk(DocumentTitle);
1585 TexOutput(_T("</H3>"));
1586 TexOutput(_T("<P>"));
1587 TexOutput(_T("</A>\n"));
1588 TexOutput(_T("<P>\n\n"));
1589 TexOutput(_T("<H3>"));
1590 TraverseChildrenFromChunk(DocumentAuthor);
1591 TexOutput(_T("</H3><P>\n\n"));
1594 TexOutput(_T("<H4>"));
1595 TraverseChildrenFromChunk(DocumentDate);
1596 TexOutput(_T("</H4><P>\n\n"));
1598 TexOutput(_T("\n</CENTER>\n"));
1599 TexOutput(_T("<P><HR><P>\n"));
1601 SetCurrentOutput(Titlepage);
1614 helpRefFilename
= NULL
;
1619 case ltBIBLIOGRAPHY
:
1623 DefaultOnMacro(macroId
, no_args
, start
);
1627 DefaultOnMacro(macroId
, no_args
, start
);
1628 TexOutput(_T("</DL>\n"));
1636 TexOutput(_T("<HR>\n"));
1644 TexOutput(_T("<HR>\n"));
1648 case ltTABLEOFCONTENTS
:
1652 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1658 putc(ch
, Titlepage
);
1665 TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n"));
1666 OnInform(_T("Run Tex2RTF again to include contents page."));
1674 TexOutput(_T("<"));
1680 TexOutput(_T(">"));
1687 TexOutput(_T("<BLOCKQUOTE>"));
1689 TexOutput(_T("</BLOCKQUOTE>"));
1698 TexOutput(_T("\n<CAPTION>"));
1706 if (DocumentStyle
!= LATEX_ARTICLE
)
1707 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1709 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d: "), FigureNameString
, figureNo
);
1715 if (DocumentStyle
!= LATEX_ARTICLE
)
1716 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1718 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d: "), TableNameString
, tableNo
);
1726 TexOutput(_T("\n</CAPTION>\n"));
1728 wxChar
*topicName
= FindTopicName(GetNextChunk());
1730 int n
= inFigure
? figureNo
: tableNo
;
1732 AddTexRef(topicName
, NULL
, NULL
,
1733 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1734 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1740 if (start
) TexOutput(_T("ß"));
1745 if (start
) inFigure
= true;
1746 else inFigure
= false;
1751 if (start
) inTable
= true;
1752 else inTable
= false;
1756 DefaultOnMacro(macroId
, no_args
, start
);
1761 // Called on start/end of argument examination
1762 bool HTMLOnArgument(int macroId
, int arg_no
, bool start
)
1768 case ltCHAPTERHEADING
:
1771 case ltSECTIONHEADING
:
1773 case ltSUBSECTIONSTAR
:
1774 case ltSUBSUBSECTION
:
1775 case ltSUBSUBSECTIONSTAR
:
1777 case ltMEMBERSECTION
:
1778 case ltFUNCTIONSECTION
:
1780 if (!start
&& (arg_no
== 1))
1781 currentSection
= GetArgChunk();
1786 if (start
&& (arg_no
== 1))
1787 TexOutput(_T("<B>"));
1789 if (!start
&& (arg_no
== 1))
1790 TexOutput(_T("</B> "));
1792 if (start
&& (arg_no
== 2))
1794 if (!suppressNameDecoration
) TexOutput(_T("<B>"));
1795 currentMember
= GetArgChunk();
1797 if (!start
&& (arg_no
== 2))
1799 if (!suppressNameDecoration
) TexOutput(_T("</B>"));
1802 if (start
&& (arg_no
== 3))
1804 if (!start
&& (arg_no
== 3))
1810 if (start
&& (arg_no
== 1))
1811 TexOutput(_T("<B>"));
1812 if (!start
&& (arg_no
== 1))
1813 TexOutput(_T("</B> "));
1815 if (start
&& (arg_no
== 2))
1817 if (!suppressNameDecoration
) TexOutput(_T("( "));
1818 currentMember
= GetArgChunk();
1820 if (!start
&& (arg_no
== 2))
1824 if (!start
&& (arg_no
== 3))
1830 if (!start
&& (arg_no
== 1))
1833 if (start
&& (arg_no
== 2))
1834 TexOutput(_T("(*"));
1835 if (!start
&& (arg_no
== 2))
1838 if (start
&& (arg_no
== 2))
1839 currentMember
= GetArgChunk();
1841 if (start
&& (arg_no
== 3))
1843 if (!start
&& (arg_no
== 3))
1849 if (start
&& (arg_no
== 1))
1850 TexOutput(_T("<B>"));
1851 if (!start
&& (arg_no
== 1))
1852 TexOutput(_T("</B>"));
1853 if (start
&& (arg_no
== 2))
1855 TexOutput(_T("<I>"));
1857 if (!start
&& (arg_no
== 2))
1859 TexOutput(_T("</I>"));
1865 if (start
&& (arg_no
== 1))
1866 TexOutput(_T("<B>"));
1867 if (!start
&& (arg_no
== 1))
1868 TexOutput(_T("</B> ")); // This is the difference from param - one space!
1869 if (start
&& (arg_no
== 2))
1871 TexOutput(_T("<I>"));
1873 if (!start
&& (arg_no
== 2))
1875 TexOutput(_T("</I>"));
1881 if (!start
&& (arg_no
== 1))
1884 if (start
&& (arg_no
== 2))
1885 currentMember
= GetArgChunk();
1894 wxChar
*refName
= GetArgData();
1897 TexRef
*texRef
= FindReference(refName
);
1900 sec
= texRef
->sectionNumber
;
1913 if (IsArgOptional())
1915 else if ((GetNoArgs() - arg_no
) == 1)
1918 helpRefText
= GetArgChunk();
1921 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1925 TexChunk
*ref
= GetArgChunk();
1926 TexOutput(_T("<A HREF=\""));
1928 TraverseChildrenFromChunk(ref
);
1930 TexOutput(_T("\">"));
1932 TraverseChildrenFromChunk(helpRefText
);
1933 TexOutput(_T("</A>"));
1943 if (IsArgOptional())
1946 helpRefFilename
= GetArgChunk();
1949 if ((GetNoArgs() - arg_no
) == 1)
1952 helpRefText
= GetArgChunk();
1955 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1959 wxChar
*refName
= GetArgData();
1960 wxChar
*refFilename
= NULL
;
1964 TexRef
*texRef
= FindReference(refName
);
1967 if (texRef
->refFile
&& wxStrcmp(texRef
->refFile
, _T("??")) != 0)
1968 refFilename
= texRef
->refFile
;
1970 TexOutput(_T("<A HREF=\""));
1971 // If a filename is supplied, use it, otherwise try to
1972 // use the filename associated with the reference (from this document).
1973 if (helpRefFilename
)
1975 TraverseChildrenFromChunk(helpRefFilename
);
1978 else if (refFilename
)
1980 TexOutput(ConvertCase(refFilename
));
1984 TexOutput(_T("\">"));
1986 TraverseChildrenFromChunk(helpRefText
);
1987 TexOutput(_T("</A>"));
1992 TraverseChildrenFromChunk(helpRefText
);
1994 TexOutput(_T(" (REF NOT FOUND)"));
1996 errBuf
.Printf(_T("Warning: unresolved reference '%s'"), refName
);
1997 OnInform((wxChar
*)errBuf
.c_str());
2000 else TexOutput(_T("??"));
2015 wxChar
*alignment
= _T("");
2016 if (macroId
== ltIMAGEL
)
2017 alignment
= _T(" align=left");
2018 else if (macroId
== ltIMAGER
)
2019 alignment
= _T(" align=right");
2021 // Try to find an XBM or GIF image first.
2022 wxChar
*filename
= copystring(GetArgData());
2025 wxStrcpy(buf
, filename
);
2026 StripExtension(buf
);
2027 wxStrcat(buf
, _T(".xbm"));
2028 wxString f
= TexPathList
.FindValidPath(buf
);
2030 if (f
== _T("")) // Try for a GIF instead
2032 wxStrcpy(buf
, filename
);
2033 StripExtension(buf
);
2034 wxStrcat(buf
, _T(".gif"));
2035 f
= TexPathList
.FindValidPath(buf
);
2038 if (f
== _T("")) // Try for a JPEG instead
2040 wxStrcpy(buf
, filename
);
2041 StripExtension(buf
);
2042 wxStrcat(buf
, _T(".jpg"));
2043 f
= TexPathList
.FindValidPath(buf
);
2046 if (f
== _T("")) // Try for a PNG instead
2048 wxStrcpy(buf
, filename
);
2049 StripExtension(buf
);
2050 wxStrcat(buf
, _T(".png"));
2051 f
= TexPathList
.FindValidPath(buf
);
2056 wxChar
*inlineFilename
= copystring(f
);
2058 wxChar
*originalFilename
= TexPathList
.FindValidPath(filename
);
2059 // If we have found the existing filename, make the inline
2060 // image point to the original file (could be PS, for example)
2061 if (originalFilename
&& (wxStrcmp(inlineFilename
, originalFilename
) != 0))
2063 TexOutput(_T("<A HREF=\""));
2064 TexOutput(ConvertCase(originalFilename
));
2065 TexOutput(_T("\">"));
2066 TexOutput(_T("<img src=\""));
2067 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2068 TexOutput(_T("\""));
2069 TexOutput(alignment
);
2070 TexOutput(_T("></A>"));
2075 TexOutput(_T("<img src=\""));
2076 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2077 TexOutput(_T("\""));
2078 TexOutput(alignment
);
2080 delete[] inlineFilename
;
2085 // Last resort - a link to a PS file.
2086 TexOutput(_T("<A HREF=\""));
2087 TexOutput(ConvertCase(wxFileNameFromPath(filename
)));
2088 TexOutput(_T("\">Picture</A>\n"));
2089 wxSnprintf(buf
, sizeof(buf
), _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2096 // First arg is PSBOX spec (ignored), second is image file, third is map name.
2099 static wxChar
*imageFile
= NULL
;
2100 if (start
&& (arg_no
== 2))
2102 // Try to find an XBM or GIF image first.
2103 wxChar
*filename
= copystring(GetArgData());
2106 wxStrcpy(buf
, filename
);
2107 StripExtension(buf
);
2108 wxStrcat(buf
, _T(".xbm"));
2109 wxString f
= TexPathList
.FindValidPath(buf
);
2111 if (f
== _T("")) // Try for a GIF instead
2113 wxStrcpy(buf
, filename
);
2114 StripExtension(buf
);
2115 wxStrcat(buf
, _T(".gif"));
2116 f
= TexPathList
.FindValidPath(buf
);
2121 wxSnprintf(buf
, sizeof(buf
), _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2130 imageFile
= copystring(f
);
2133 else if (start
&& (arg_no
== 3))
2137 // First, try to find a .shg (segmented hypergraphics file)
2138 // that we can convert to a map file
2140 wxStrcpy(buf
, imageFile
);
2141 StripExtension(buf
);
2142 wxStrcat(buf
, _T(".shg"));
2143 wxString f
= TexPathList
.FindValidPath(buf
);
2147 // The default HTML file to go to is THIS file (so a no-op)
2148 SHGToMap((wxChar
*)f
.c_str(), currentFileName
);
2151 wxChar
*mapName
= GetArgData();
2152 TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/"));
2156 TexOutput(_T("unknown"));
2157 TexOutput(_T("\">"));
2158 TexOutput(_T("<img src=\""));
2159 TexOutput(ConvertCase(wxFileNameFromPath(imageFile
)));
2160 TexOutput(_T("\" ISMAP></A><P>"));
2180 descriptionItemArg
= GetArgChunk();
2186 case ltTWOCOLITEMRULED
:
2189 if (start && (arg_no == 1))
2190 TexOutput(_T("\n<DT> "));
2191 if (start && (arg_no == 2))
2192 TexOutput(_T("<DD> "));
2198 if (TwoColWidthA
> -1) {
2200 wxSnprintf(buf
, sizeof(buf
), _T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA
);
2203 TexOutput(_T("\n<TR><TD VALIGN=TOP>\n"));
2206 TexOutput(_T("\n</FONT></TD>\n"));
2212 if (TwoColWidthB
> -1) {
2214 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB
);
2217 TexOutput(_T("\n<TD VALIGN=TOP>\n"));
2220 TexOutput(_T("\n</FONT></TD></TR>\n"));
2224 case ltNUMBEREDBIBITEM
:
2226 if (arg_no
== 1 && start
)
2228 TexOutput(_T("\n<DT> "));
2230 if (arg_no
== 2 && !start
)
2231 TexOutput(_T("<P>\n"));
2237 if (arg_no
== 1 && start
)
2239 wxChar
*citeKey
= GetArgData();
2240 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
2243 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
2244 wxSnprintf(buf
, sizeof(buf
), _T("[%d]"), citeCount
);
2245 ref
->sectionNumber
= copystring(buf
);
2248 wxSnprintf(buf
, sizeof(buf
), _T("\n<DT> [%d] "), citeCount
);
2253 if (arg_no
== 2 && !start
)
2254 TexOutput(_T("<P>\n"));
2258 case ltMARGINPARODD
:
2259 case ltMARGINPAREVEN
:
2265 TexOutput(_T("<HR>\n"));
2269 TexOutput(_T("<HR><P>\n"));
2273 case ltTWOCOLWIDTHA
:
2277 wxChar
*val
= GetArgData();
2278 float points
= ParseUnitArgument(val
);
2279 TwoColWidthA
= (int)((points
* 100.0) / 72.0);
2284 case ltTWOCOLWIDTHB
:
2288 wxChar
*val
= GetArgData();
2289 float points
= ParseUnitArgument(val
);
2290 TwoColWidthB
= (int)((points
* 100.0) / 72.0);
2298 case ltACCENT_GRAVE
:
2302 wxChar
*val
= GetArgData();
2308 TexOutput(_T("à"));
2311 TexOutput(_T("è"));
2314 TexOutput(_T("ì"));
2317 TexOutput(_T("ò"));
2320 TexOutput(_T("ù"));
2323 TexOutput(_T("À"));
2326 TexOutput(_T("È"));
2329 TexOutput(_T("Ì"));
2332 TexOutput(_T("Ò"));
2335 TexOutput(_T("Ì"));
2344 case ltACCENT_ACUTE
:
2348 wxChar
*val
= GetArgData();
2354 TexOutput(_T("á"));
2357 TexOutput(_T("é"));
2360 TexOutput(_T("í"));
2363 TexOutput(_T("ó"));
2366 TexOutput(_T("ú"));
2369 TexOutput(_T("ý"));
2372 TexOutput(_T("Á"));
2375 TexOutput(_T("É"));
2378 TexOutput(_T("Í"));
2381 TexOutput(_T("Ó"));
2384 TexOutput(_T("Ú"));
2387 TexOutput(_T("Ý"));
2396 case ltACCENT_CARET
:
2400 wxChar
*val
= GetArgData();
2406 TexOutput(_T("â"));
2409 TexOutput(_T("ê"));
2412 TexOutput(_T("î"));
2415 TexOutput(_T("ô"));
2418 TexOutput(_T("û"));
2421 TexOutput(_T("Â"));
2424 TexOutput(_T("Ê"));
2427 TexOutput(_T("Î"));
2430 TexOutput(_T("Ô"));
2433 TexOutput(_T("Î"));
2442 case ltACCENT_TILDE
:
2446 wxChar
*val
= GetArgData();
2455 TexOutput(_T("ã"));
2458 TexOutput(_T("ñ"));
2461 TexOutput(_T("õ"));
2464 TexOutput(_T("Ã"));
2467 TexOutput(_T("Ñ"));
2470 TexOutput(_T("Õ"));
2479 case ltACCENT_UMLAUT
:
2483 wxChar
*val
= GetArgData();
2489 TexOutput(_T("ä"));
2492 TexOutput(_T("ë"));
2495 TexOutput(_T("ï"));
2498 TexOutput(_T("ö"));
2501 TexOutput(_T("ü"));
2504 TexOutput(_T("ÿ"));
2507 TexOutput(_T("Ä"));
2510 TexOutput(_T("Ë"));
2513 TexOutput(_T("Ï"));
2516 TexOutput(_T("Ö"));
2519 TexOutput(_T("Ü"));
2522 TexOutput(_T("Ÿ"));
2535 wxChar
*val
= GetArgData();
2541 TexOutput(_T("å"));
2544 TexOutput(_T("Å"));
2557 wxChar
*val
= GetArgData();
2560 bool isPicture
= false;
2561 ParseColourString(val
, &isPicture
);
2564 if (backgroundImageString
)
2565 delete[] backgroundImageString
;
2566 backgroundImageString
= copystring(val
);
2570 if (backgroundColourString
)
2571 delete[] backgroundColourString
;
2572 backgroundColourString
= copystring(val
);
2578 case ltBACKGROUNDIMAGE
:
2582 wxChar
*val
= GetArgData();
2585 if (backgroundImageString
)
2586 delete[] backgroundImageString
;
2587 backgroundImageString
= copystring(val
);
2592 case ltBACKGROUNDCOLOUR
:
2596 wxChar
*val
= GetArgData();
2599 if (backgroundColourString
)
2600 delete[] backgroundColourString
;
2601 backgroundColourString
= copystring(val
);
2610 wxChar
*val
= GetArgData();
2613 if (textColourString
)
2614 delete[] textColourString
;
2615 textColourString
= copystring(val
);
2624 wxChar
*val
= GetArgData();
2627 if (linkColourString
)
2628 delete[] linkColourString
;
2629 linkColourString
= copystring(val
);
2634 case ltFOLLOWEDLINKCOLOUR
:
2638 wxChar
*val
= GetArgData();
2641 if (followedLinkColourString
)
2642 delete[] followedLinkColourString
;
2643 followedLinkColourString
= copystring(val
);
2648 case ltACCENT_CADILLA
:
2652 wxChar
*val
= GetArgData();
2658 TexOutput(_T("ç"));
2661 TexOutput(_T("Ç"));
2672 case ltFOOTNOTEPOPUP:
2682 case ltSUPERTABULAR
:
2688 currentRowNumber
= 0;
2691 tableVerticalLineLeft
= false;
2692 tableVerticalLineRight
= false;
2694 wxChar
*alignString
= copystring(GetArgData());
2695 ParseTableArgument(alignString
);
2697 TexOutput(_T("<TABLE BORDER>\n"));
2699 // Write the first row formatting for compatibility
2700 // with standard Latex
2701 if (compatibilityMode
)
2703 TexOutput(_T("<TR>\n<TD>"));
2706 for (int i = 0; i < noColumns; i++)
2708 currentWidth += TableData[i].width;
2709 wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth);
2712 TexOutput(_T("\\pard\\intbl\n"));
2715 delete[] alignString
;
2720 else if (arg_no
== 2 && !start
)
2722 TexOutput(_T("</TABLE>\n"));
2727 case ltTHEBIBLIOGRAPHY
:
2729 if (start
&& (arg_no
== 1))
2731 ReopenFile(&Chapters
, &ChaptersName
, _T("bibliography"));
2732 AddTexRef(_T("bibliography"), ChaptersName
, _T("bibliography"));
2733 SetCurrentSubsectionName(_T("bibliography"), ChaptersName
);
2737 SetCurrentOutput(Chapters
);
2739 wxChar titleBuf
[150];
2740 if (truncateFilenames
)
2741 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s.htm"), wxFileNameFromPath(FileRoot
));
2743 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
2746 TexOutput(_T("<title>"));
2747 TexOutput(ReferencesNameString
);
2748 TexOutput(_T("</title></head>\n"));
2751 wxFprintf(Chapters
, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString
);
2752 AddBrowseButtons(_T("contents"), titleBuf
, // Up
2753 lastTopic
, lastFileName
, // Last topic
2754 _T("bibliography"), ChaptersName
); // This topic
2756 SetCurrentOutputs(Contents
, Chapters
);
2757 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), "bibliography");
2759 wxFprintf(Contents
, _T("%s</A>\n"), ReferencesNameString
);
2760 wxFprintf(Chapters
, _T("</H2>\n</A>\n"));
2762 SetCurrentOutput(Chapters
);
2765 if (!start
&& (arg_no
== 2))
2772 /* Build up list of keywords associated with topics */
2775 // wxChar *entry = GetArgData();
2777 OutputChunkToString(GetArgChunk(), buf
);
2780 AddKeyWordForTopic(CurrentTopic
, buf
, currentFileName
);
2794 wxChar
*name
= GetArgData();
2796 if (!FindColourHTMLString(name
, buf2
))
2798 wxStrcpy(buf2
, _T("#000000"));
2800 wxSnprintf(buf
, sizeof(buf
), _T("Could not find colour name %s"), name
);
2803 TexOutput(_T("<FONT COLOR=\""));
2805 TexOutput(_T("\">"));
2818 if (arg_no
== 2) TexOutput(_T("</FONT>"));
2822 case ltINSERTATLEVEL
:
2824 // This macro allows you to insert text at a different level
2825 // from the current level, e.g. into the Sections from within a subsubsection.
2828 static int currentLevelNo
= 1;
2829 static FILE* oldLevelFile
= Chapters
;
2836 oldLevelFile
= CurrentOutput1
;
2838 wxChar
*str
= GetArgData();
2839 currentLevelNo
= wxAtoi(str
);
2841 // TODO: cope with article style (no chapters)
2842 switch (currentLevelNo
)
2846 outputFile
= Chapters
;
2851 outputFile
= Sections
;
2856 outputFile
= Subsections
;
2861 outputFile
= Subsubsections
;
2871 CurrentOutput1
= outputFile
;
2887 CurrentOutput1
= oldLevelFile
;
2893 return DefaultOnArgument(macroId
, arg_no
, start
);
2905 tableVerticalLineLeft
= false;
2906 tableVerticalLineRight
= false;
2909 if (InputFile
&& OutputFile
)
2911 // Do some HTML-specific transformations on all the strings,
2913 Text2HTML(GetTopLevelChunk());
2916 if (truncateFilenames
)
2917 wxSnprintf(buf
, sizeof(buf
), _T("%s.htm"), FileRoot
);
2919 wxSnprintf(buf
, sizeof(buf
), _T("%s_contents.html"), FileRoot
);
2920 if (TitlepageName
) delete[] TitlepageName
;
2921 TitlepageName
= copystring(buf
);
2922 Titlepage
= wxFopen(buf
, _T("w"));
2924 if (truncateFilenames
)
2925 wxSnprintf(buf
, sizeof(buf
), _T("%s_fc.htm"), FileRoot
);
2927 wxSnprintf(buf
, sizeof(buf
), _T("%s_fcontents.html"), FileRoot
);
2929 contentsFrameName
= copystring(buf
);
2931 Contents
= wxFopen(TmpContentsName
, _T("w"));
2933 if (htmlFrameContents
)
2935 // FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
2936 FrameContents
= wxFopen(contentsFrameName
, _T("w"));
2937 wxFprintf(FrameContents
, _T("<HTML>\n<UL>\n"));
2940 if (!Titlepage
|| !Contents
)
2942 OnError(_T("Cannot open output file!"));
2945 AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName
), ContentsNameString
);
2947 wxFprintf(Contents
, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString
);
2949 wxFprintf(Contents
, _T("<UL>\n"));
2951 SetCurrentOutput(Titlepage
);
2952 if (htmlWorkshopFiles
) HTMLWorkshopStartContents();
2953 OnInform(_T("Converting..."));
2956 wxFprintf(Contents
, _T("</UL>\n\n"));
2958 // SetCurrentOutput(Titlepage);
2963 // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
2970 wxFprintf(FrameContents
, _T("\n</UL>\n"));
2971 wxFprintf(FrameContents
, _T("</HTML>\n"));
2972 fclose(FrameContents
);
2973 FrameContents
= NULL
;
2978 wxFprintf(Chapters
, _T("\n</FONT></BODY></HTML>\n"));
2984 wxFprintf(Sections
, _T("\n</FONT></BODY></HTML>\n"));
2988 if (Subsections
&& !combineSubSections
)
2990 wxFprintf(Subsections
, _T("\n</FONT></BODY></HTML>\n"));
2991 fclose(Subsections
);
2994 if (Subsubsections
&& !combineSubSections
)
2996 wxFprintf(Subsubsections
, _T("\n</FONT></BODY></HTML>\n"));
2997 fclose(Subsubsections
);
2998 Subsubsections
= NULL
;
3000 if ( SectionContentsFD
)
3002 fclose(SectionContentsFD
);
3003 SectionContentsFD
= NULL
;
3006 // Create a temporary file for the title page header, add some info,
3007 // and concat the titlepage just generated.
3008 // This is necessary in order to put the title of the document
3009 // at the TOP of the file within <HEAD>, even though we only find out
3010 // what it is later on.
3011 FILE *tmpTitle
= wxFopen(_T("title.tmp"), _T("w"));
3016 SetCurrentOutput(tmpTitle
);
3018 TexOutput(_T("\n<HEAD><TITLE>"));
3019 TraverseChildrenFromChunk(DocumentTitle
);
3020 TexOutput(_T("</TITLE></HEAD>\n"));
3024 SetCurrentOutput(tmpTitle
);
3025 HTMLHeadTo(tmpTitle
);
3027 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString
);
3029 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot
));
3032 // Output frame information
3033 if (htmlFrameContents
)
3035 wxChar firstFileName
[300];
3036 if (truncateFilenames
)
3037 wxSnprintf(firstFileName
, sizeof(firstFileName
), _T("%s1.htm"), FileRoot
);
3039 wxStrcpy(firstFileName
, gs_filenames
[1].c_str());
3041 wxFprintf(tmpTitle
, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
3043 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName
)));
3044 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName
)));
3045 wxFprintf(tmpTitle
, _T("</FRAMESET>\n"));
3047 wxFprintf(tmpTitle
, _T("<NOFRAMES>\n"));
3050 // Output <BODY...> to temporary title page
3054 FILE *fd
= wxFopen(TitlepageName
, _T("r"));
3066 wxFprintf(tmpTitle
, _T("\n</FONT></BODY>\n"));
3068 if (htmlFrameContents
)
3070 wxFprintf(tmpTitle
, _T("\n</NOFRAMES>\n"));
3072 wxFprintf(tmpTitle
, _T("\n</HTML>\n"));
3075 if (wxFileExists(TitlepageName
)) wxRemoveFile(TitlepageName
);
3076 if (!wxRenameFile(_T("title.tmp"), TitlepageName
))
3078 wxCopyFile(_T("title.tmp"), TitlepageName
);
3079 wxRemoveFile(_T("title.tmp"));
3083 if (lastFileName
) delete[] lastFileName
;
3084 lastFileName
= NULL
;
3085 if (lastTopic
) delete[] lastTopic
;
3088 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
3090 if (!wxRenameFile(TmpContentsName
, ContentsName
))
3092 wxCopyFile(TmpContentsName
, ContentsName
);
3093 wxRemoveFile(TmpContentsName
);
3096 // Generate .htx file if requested
3099 wxChar htmlIndexName
[300];
3100 wxSnprintf(htmlIndexName
, sizeof(htmlIndexName
), _T("%s.htx"), FileRoot
);
3101 GenerateHTMLIndexFile(htmlIndexName
);
3104 // Generate HTML Help Workshop files if requested
3105 if (htmlWorkshopFiles
)
3107 HTMLWorkshopEndContents();
3108 GenerateHTMLWorkshopFiles(FileRoot
);
3118 // Output .htx index file
3119 void GenerateHTMLIndexFile(wxChar
*fname
)
3121 FILE *fd
= wxFopen(fname
, _T("w"));
3125 TopicTable
.BeginFind();
3126 wxNode
*node
= TopicTable
.Next();
3129 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3130 const wxChar
*topicName
= node
->GetKeyString();
3131 if (texTopic
->filename
&& texTopic
->keywords
)
3133 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3136 wxChar
*s
= (wxChar
*)node1
->GetData();
3137 wxFprintf(fd
, _T("%s|%s|%s\n"), topicName
, texTopic
->filename
, s
);
3138 node1
= node1
->GetNext();
3141 node
= TopicTable
.Next();
3152 // output .hpp, .hhc and .hhk files:
3155 void GenerateHTMLWorkshopFiles(wxChar
*fname
)
3160 /* Generate project file : */
3162 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhp"), fname
);
3163 f
= wxFopen(buf
, _T("wt"));
3166 _T("Compatibility=1.1\n")
3167 _T("Full-text search=Yes\n")
3168 _T("Contents file=%s.hhc\n")
3169 _T("Compiled file=%s.chm\n")
3170 _T("Default Window=%sHelp\n")
3171 _T("Default topic=%s\n")
3172 _T("Index file=%s.hhk\n")
3174 wxFileNameFromPath(fname
),
3175 wxFileNameFromPath(fname
),
3176 wxFileNameFromPath(fname
),
3177 wxFileNameFromPath(TitlepageName
),
3178 wxFileNameFromPath(fname
)
3181 if (DocumentTitle
) {
3182 SetCurrentOutput(f
);
3183 TraverseChildrenFromChunk(DocumentTitle
);
3185 else wxFprintf(f
, _T("(unknown)"));
3187 wxFprintf(f
, _T("\n\n[WINDOWS]\n")
3188 _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"),
3189 wxFileNameFromPath(fname
),
3190 wxFileNameFromPath(fname
),
3191 wxFileNameFromPath(fname
),
3192 wxFileNameFromPath(TitlepageName
));
3195 wxFprintf(f
, _T("\n\n[FILES]\n"));
3196 wxFprintf(f
, _T("%s\n"), wxFileNameFromPath(TitlepageName
));
3197 for (int i
= 1; i
<= fileId
; i
++) {
3198 if (truncateFilenames
)
3199 wxSnprintf(buf
, sizeof(buf
), _T("%s%d.htm"), wxFileNameFromPath(FileRoot
), i
);
3201 wxStrcpy(buf
, wxFileNameFromPath(gs_filenames
[i
].c_str()));
3202 wxFprintf(f
, _T("%s\n"), buf
);
3206 /* Generate index file : */
3208 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhk"), fname
);
3209 f
= wxFopen(buf
, _T("wt"));
3212 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3217 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3218 _T("<!-- Sitemap 1.0 -->\n")
3219 _T("</HEAD><BODY>\n")
3220 _T("<OBJECT type=\"text/site properties\">\n")
3221 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3225 TopicTable
.BeginFind();
3226 wxNode
*node
= TopicTable
.Next();
3229 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3230 const wxChar
*topicName
= node
->GetKeyString();
3231 if (texTopic
->filename
&& texTopic
->keywords
)
3233 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3236 wxChar
*s
= (wxChar
*)node1
->GetData();
3238 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3239 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3240 _T(" <param name=\"Name\" value=\"%s\">\n")
3242 texTopic
->filename
, topicName
, s
);
3243 node1
= node1
->GetNext();
3246 node
= TopicTable
.Next();
3249 wxFprintf(f
, _T("</UL>\n"));
3255 static FILE *HTMLWorkshopContents
= NULL
;
3256 static int HTMLWorkshopLastLevel
= 0;
3258 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
)
3262 if (level
> HTMLWorkshopLastLevel
)
3263 for (i
= HTMLWorkshopLastLevel
; i
< level
; i
++)
3264 wxFprintf(HTMLWorkshopContents
, _T("<UL>"));
3265 if (level
< HTMLWorkshopLastLevel
)
3266 for (i
= level
; i
< HTMLWorkshopLastLevel
; i
++)
3267 wxFprintf(HTMLWorkshopContents
, _T("</UL>"));
3269 SetCurrentOutput(HTMLWorkshopContents
);
3270 wxFprintf(HTMLWorkshopContents
,
3271 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3272 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3273 _T(" <param name=\"Name\" value=\""),
3275 OutputCurrentSection();
3276 wxFprintf(HTMLWorkshopContents
,
3278 _T(" </OBJECT>\n"));
3279 HTMLWorkshopLastLevel
= level
;
3283 void HTMLWorkshopStartContents()
3286 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhc"), FileRoot
);
3287 HTMLWorkshopContents
= wxFopen(buf
, _T("wt"));
3288 HTMLWorkshopLastLevel
= 0;
3290 wxFprintf(HTMLWorkshopContents
,
3291 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3293 HTMLHeadTo(HTMLWorkshopContents
);
3294 wxFprintf(HTMLWorkshopContents
,
3296 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3297 _T("<!-- Sitemap 1.0 -->\n")
3298 _T("</HEAD><BODY>\n")
3299 _T("<OBJECT type=\"text/site properties\">\n")
3300 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3303 _T("<LI> <OBJECT type=\"text/sitemap\">\n")
3304 _T("<param name=\"Local\" value=\"%s\">\n")
3305 _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"),
3306 wxFileNameFromPath(TitlepageName
)
3312 void HTMLWorkshopEndContents()
3314 for (int i
= HTMLWorkshopLastLevel
; i
>= 0; i
--)
3315 wxFprintf(HTMLWorkshopContents
, _T("</UL>\n"));
3316 fclose(HTMLWorkshopContents
);