1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Converts Latex to HTML
4 // Author: Julian Smart
5 // Modified by: Wlodzimierz 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 #define HTML_FILENAME_PATTERN _T("%s_%s.html")
35 #if !WXWIN_COMPATIBILITY_2_4
36 static inline wxChar
* copystring(const wxChar
* s
)
37 { return wxStrcpy(new wxChar
[wxStrlen(s
) + 1], s
); }
40 extern wxHashTable TexReferences
;
43 extern void DecToHex(int, wxChar
*);
44 void GenerateHTMLIndexFile(wxChar
*fname
);
46 bool PrimaryAnchorOfTheFile( wxChar
*file
, wxChar
*label
);
48 void GenerateHTMLWorkshopFiles(wxChar
*fname
);
49 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
);
50 void HTMLWorkshopStartContents();
51 void HTMLWorkshopEndContents();
53 void OutputContentsFrame(void);
55 #include "readshg.h" // Segmented hypergraphics parsing
57 wxChar
*ChaptersName
= NULL
;
58 wxChar
*SectionsName
= NULL
;
59 wxChar
*SubsectionsName
= NULL
;
60 wxChar
*SubsubsectionsName
= NULL
;
61 wxChar
*TitlepageName
= NULL
;
62 wxChar
*lastFileName
= NULL
;
63 wxChar
*lastTopic
= NULL
;
64 wxChar
*currentFileName
= NULL
;
65 wxChar
*contentsFrameName
= NULL
;
67 static TexChunk
*descriptionItemArg
= NULL
;
68 static TexChunk
*helpRefFilename
= NULL
;
69 static TexChunk
*helpRefText
= NULL
;
70 static int indentLevel
= 0;
71 static int citeCount
= 1;
72 extern FILE *Contents
;
73 FILE *FrameContents
= NULL
;
74 FILE *Titlepage
= NULL
;
75 // FILE *FrameTitlepage = NULL;
77 bool subsectionStarted
= false;
79 // Which column of a row are we in? (Assumes no nested tables, of course)
80 int currentColumn
= 0;
82 // Are we in verbatim mode? If so, format differently.
83 static bool inVerbatim
= false;
85 // Need to know whether we're in a table or figure for benefit
86 // of listoffigures/listoftables
87 static bool inFigure
= false;
88 static bool inTable
= false;
90 // This is defined in the Tex2Any library.
91 extern wxChar
*BigBuffer
;
93 // DHS Two-column table dimensions.
94 static int TwoColWidthA
= -1;
95 static int TwoColWidthB
= -1;
98 class HyperReference
: public wxObject
103 HyperReference(wxChar
*name
, wxChar
*file
)
105 if (name
) refName
= copystring(name
);
106 if (file
) refFile
= copystring(file
);
110 class TexNextPage
: public wxObject
115 TexNextPage(wxChar
*theLabel
, wxChar
*theFile
)
117 label
= copystring(theLabel
);
118 filename
= copystring(theFile
);
127 wxHashTable
TexNextPages(wxKEY_STRING
);
129 static wxChar
*CurrentChapterName
= NULL
;
130 static wxChar
*CurrentChapterFile
= NULL
;
131 static wxChar
*CurrentSectionName
= NULL
;
132 static wxChar
*CurrentSectionFile
= NULL
;
133 static wxChar
*CurrentSubsectionName
= NULL
;
134 static wxChar
*CurrentSubsectionFile
= NULL
;
135 static wxChar
*CurrentSubsubsectionName
= NULL
;
136 static wxChar
*CurrentSubsubsectionFile
= NULL
;
137 static wxChar
*CurrentTopic
= NULL
;
139 static void SetCurrentTopic(wxChar
*s
)
141 if (CurrentTopic
) delete[] CurrentTopic
;
142 CurrentTopic
= copystring(s
);
145 void SetCurrentChapterName(wxChar
*s
, wxChar
*file
)
147 if (CurrentChapterName
) delete[] CurrentChapterName
;
148 CurrentChapterName
= copystring(s
);
149 if (CurrentChapterFile
) delete[] CurrentChapterFile
;
150 CurrentChapterFile
= copystring(file
);
152 currentFileName
= CurrentChapterFile
;
156 void SetCurrentSectionName(wxChar
*s
, wxChar
*file
)
158 if (CurrentSectionName
) delete[] CurrentSectionName
;
159 CurrentSectionName
= copystring(s
);
160 if (CurrentSectionFile
) delete[] CurrentSectionFile
;
161 CurrentSectionFile
= copystring(file
);
163 currentFileName
= CurrentSectionFile
;
166 void SetCurrentSubsectionName(wxChar
*s
, wxChar
*file
)
168 if (CurrentSubsectionName
) delete[] CurrentSubsectionName
;
169 CurrentSubsectionName
= copystring(s
);
170 if (CurrentSubsectionFile
) delete[] CurrentSubsectionFile
;
171 CurrentSubsectionFile
= copystring(file
);
172 currentFileName
= CurrentSubsectionFile
;
175 void SetCurrentSubsubsectionName(wxChar
*s
, wxChar
*file
)
177 if (CurrentSubsubsectionName
) delete[] CurrentSubsubsectionName
;
178 CurrentSubsubsectionName
= copystring(s
);
179 if (CurrentSubsubsectionFile
) delete[] CurrentSubsubsectionFile
;
180 CurrentSubsubsectionFile
= copystring(file
);
181 currentFileName
= CurrentSubsubsectionFile
;
186 // mapping between fileId and filenames if truncateFilenames=false:
187 static wxArrayString gs_filenames
;
191 * Close former filedescriptor and reopen using another filename.
195 void ReopenFile(FILE **fd
, wxChar
**fileName
, const wxChar
*label
)
199 wxFprintf(*fd
, _T("\n</FONT></BODY></HTML>\n"));
204 if (truncateFilenames
)
206 wxSnprintf(buf
, sizeof(buf
), _T("%s%d.htm"), FileRoot
, fileId
);
211 gs_filenames
.Add(wxEmptyString
);
212 wxSnprintf(buf
, sizeof(buf
), HTML_FILENAME_PATTERN
, FileRoot
, label
);
213 gs_filenames
.Add(buf
);
215 if (*fileName
) delete[] *fileName
;
216 *fileName
= copystring(wxFileNameFromPath(buf
));
217 *fd
= wxFopen(buf
, _T("w"));
218 wxFprintf(*fd
, _T("<HTML>\n"));
222 * Reopen section contents file, i.e. the index appended to each section
223 * in subsectionCombine mode
226 static wxChar
*SectionContentsFilename
= NULL
;
227 static FILE *SectionContentsFD
= NULL
;
229 void ReopenSectionContentsFile(void)
231 if ( SectionContentsFD
)
233 fclose(SectionContentsFD
);
235 if ( SectionContentsFilename
)
236 delete[] SectionContentsFilename
;
237 SectionContentsFD
= NULL
;
238 SectionContentsFilename
= NULL
;
240 // Create the name from the current section filename
241 if ( CurrentSectionFile
)
244 wxStrcpy(buf
, CurrentSectionFile
);
245 wxStripExtension(buf
);
246 wxStrcat(buf
, _T(".con"));
247 SectionContentsFilename
= copystring(buf
);
249 SectionContentsFD
= wxFopen(SectionContentsFilename
, _T("w"));
255 * Given a TexChunk with a string value, scans through the string
256 * converting Latex-isms into HTML-isms, such as 2 newlines -> <P>.
260 void ProcessText2HTML(TexChunk
*chunk
)
262 bool changed
= false;
266 int len
= wxStrlen(chunk
->value
);
269 ch
= chunk
->value
[i
];
271 // 2 newlines means \par
272 if (!inVerbatim
&& chunk
->value
[i
] == 10 && ((len
> i
+1 && chunk
->value
[i
+1] == 10) ||
273 ((len
> i
+1 && chunk
->value
[i
+1] == 13) &&
274 (len
> i
+2 && chunk
->value
[i
+2] == 10))))
276 BigBuffer
[ptr
] = 0; wxStrcat(BigBuffer
, _T("<P>\n\n")); ptr
+= 5;
280 else if (!inVerbatim
&& ch
== '`' && (len
>= i
+1 && chunk
->value
[i
+1] == '`'))
282 BigBuffer
[ptr
] = '"'; ptr
++;
286 else if (!inVerbatim
&& ch
== '`') // Change ` to '
288 BigBuffer
[ptr
] = 39; ptr
++;
292 else if (ch
== '<') // Change < to <
295 wxStrcat(BigBuffer
, _T("<"));
300 else if (ch
== '>') // Change > to >
303 wxStrcat(BigBuffer
, _T(">"));
320 chunk
->value
= copystring(BigBuffer
);
325 * Scan through all chunks starting from the given one,
326 * calling ProcessText2HTML to convert Latex-isms to RTF-isms.
327 * This should be called after Tex2Any has parsed the file,
328 * and before TraverseDocument is called.
332 void Text2HTML(TexChunk
*chunk
)
335 if (stopRunning
) return;
339 case CHUNK_TYPE_MACRO
:
341 TexMacroDef
*def
= chunk
->def
;
343 if (def
&& def
->ignore
)
346 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
349 wxNode
*node
= chunk
->children
.GetFirst();
352 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
353 Text2HTML(child_chunk
);
354 node
= node
->GetNext();
357 if (def
&& (def
->macroId
== ltVERBATIM
|| def
->macroId
== ltVERB
|| def
->macroId
== ltSPECIAL
))
364 wxNode
*node
= chunk
->children
.GetFirst();
367 TexChunk
*child_chunk
= (TexChunk
*)node
->GetData();
368 Text2HTML(child_chunk
);
369 node
= node
->GetNext();
374 case CHUNK_TYPE_STRING
:
377 ProcessText2HTML(chunk
);
384 * Add appropriate browse buttons to this page.
388 void AddBrowseButtons(wxChar
*upLabel
, wxChar
*upFilename
,
389 wxChar
*previousLabel
, wxChar
*previousFilename
,
390 wxChar
*thisLabel
, wxChar
*thisFilename
)
392 wxChar contentsReferenceBuf
[80];
393 wxChar upReferenceBuf
[80];
394 wxChar backReferenceBuf
[80];
395 wxChar forwardReferenceBuf
[80];
396 if (htmlBrowseButtons
== HTML_BUTTONS_NONE
)
399 wxChar
*contentsReference
; // no need to initialize because always assigned below
400 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
401 contentsReference
= ContentsNameString
;
404 // contentsReference = "<img align=center src=\"contents.gif\" BORDER=0 ALT=\"Contents\">";
405 contentsReference
= contentsReferenceBuf
;
406 wxSnprintf(contentsReference
, sizeof(contentsReferenceBuf
),
407 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">"),
408 ConvertCase(_T("contents.gif")));
411 wxChar
*upReference
; // no need to initialize because always assigned below
412 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
413 upReference
= UpNameString
;
416 // upReference = "<img align=center src=\"up.gif\" ALT=\"Up\">";
417 upReference
= upReferenceBuf
;
418 wxSnprintf(upReference
, sizeof(upReferenceBuf
),
419 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">"),
420 ConvertCase(_T("up.gif")));
423 wxChar
*backReference
; // no need to initialize because always assigned below
424 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
425 backReference
= _T("<<");
428 // backReference = "<img align=center src=\"back.gif\" ALT=\"Previous\">";
429 backReference
= backReferenceBuf
;
430 wxSnprintf(backReference
, sizeof(backReferenceBuf
),
431 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">"),
432 ConvertCase(_T("back.gif")));
435 wxChar
*forwardReference
; // no need to initialize because always assigned below
436 if (htmlBrowseButtons
== HTML_BUTTONS_TEXT
)
437 forwardReference
= _T(">>");
440 // forwardReference = "<img align=center src=\"forward.gif\" ALT=\"Next\">";
441 forwardReference
= forwardReferenceBuf
;
442 wxSnprintf(forwardReference
, sizeof(forwardReferenceBuf
),
443 _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">"),
444 ConvertCase(_T("forward.gif")));
447 TexOutput(_T("<CENTER>"));
456 if (truncateFilenames
)
459 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
460 wxSnprintf(buf
, sizeof(buf
),
461 _T("\n<A HREF=\"%s.%s\">%s</A> "),
462 buf1
, ConvertCase(_T("htm")), contentsReference
);
467 wxStrcpy(buf1
, ConvertCase(wxFileNameFromPath(FileRoot
)));
468 wxSnprintf(buf
, sizeof(buf
),
469 _T("\n<A HREF=\"%s%s\">%s</A> "),
470 buf1
, ConvertCase(_T("_contents.html")), contentsReference
);
472 // TexOutput(_T("<NOFRAMES>"));
474 // TexOutput(_T("</NOFRAMES>"));
481 if (upLabel
&& upFilename
)
483 if ( (wxStrlen(upLabel
) > 0) && !PrimaryAnchorOfTheFile(upFilename
, upLabel
) )
484 wxSnprintf(buf
, sizeof(buf
),
485 _T("<A HREF=\"%s#%s\">%s</A> "),
486 ConvertCase(upFilename
), upLabel
, upReference
);
488 wxSnprintf(buf
, sizeof(buf
),
489 _T("<A HREF=\"%s\">%s</A> "),
490 ConvertCase(upFilename
), upReference
);
491 if (wxStrcmp(upLabel
, _T("contents")) == 0)
493 // TexOutput(_T("<NOFRAMES>"));
495 // TexOutput(_T("</NOFRAMES>"));
506 if (previousLabel
&& previousFilename
)
508 if (PrimaryAnchorOfTheFile(previousFilename
, previousLabel
))
509 wxSnprintf(buf
, sizeof(buf
),
510 _T("<A HREF=\"%s\">%s</A> "),
511 ConvertCase(previousFilename
), backReference
);
513 wxSnprintf(buf
, sizeof(buf
),
514 _T("<A HREF=\"%s#%s\">%s</A> "),
515 ConvertCase(previousFilename
), previousLabel
, backReference
);
516 if (wxStrcmp(previousLabel
, _T("contents")) == 0)
518 // TexOutput(_T("<NOFRAMES>"));
520 // TexOutput(_T("</NOFRAMES>"));
527 // A placeholder so the buttons don't keep moving position
528 wxSnprintf(buf
, sizeof(buf
), _T("%s "), backReference
);
532 wxChar
*nextLabel
= NULL
;
533 wxChar
*nextFilename
= NULL
;
535 // Get the next page, and record the previous page's 'next' page
537 TexNextPage
*nextPage
= (TexNextPage
*)TexNextPages
.Get(thisLabel
);
540 nextLabel
= nextPage
->label
;
541 nextFilename
= nextPage
->filename
;
543 if (previousLabel
&& previousFilename
)
545 TexNextPage
*oldNextPage
= (TexNextPage
*)TexNextPages
.Get(previousLabel
);
549 TexNextPages
.Delete(previousLabel
);
551 TexNextPage
*newNextPage
= new TexNextPage(thisLabel
, thisFilename
);
552 TexNextPages
.Put(previousLabel
, newNextPage
);
560 if (nextLabel
&& nextFilename
)
562 if (PrimaryAnchorOfTheFile(nextFilename
, nextLabel
))
563 wxSnprintf(buf
, sizeof(buf
),
564 _T("<A HREF=\"%s\">%s</A> "),
565 ConvertCase(nextFilename
), forwardReference
);
567 wxSnprintf(buf
, sizeof(buf
),
568 _T("<A HREF=\"%s#%s\">%s</A> "),
569 ConvertCase(nextFilename
), nextLabel
, forwardReference
);
574 // A placeholder so the buttons don't keep moving position
575 wxSnprintf(buf
, sizeof(buf
), _T("%s "), forwardReference
);
580 * Horizontal rule to finish it off nicely.
583 TexOutput(_T("</CENTER>"));
584 TexOutput(_T("<HR>\n"));
586 // Update last topic/filename
588 delete[] lastFileName
;
589 lastFileName
= copystring(thisFilename
);
592 lastTopic
= copystring(thisLabel
);
595 // A colour string is either 3 numbers separated by semicolons (RGB),
596 // or a reference to a GIF. Return the filename or a hex string like #934CE8
597 wxChar
*ParseColourString(wxChar
*bkStr
, bool *isPicture
)
599 static wxChar resStr
[300];
600 wxStrcpy(resStr
, bkStr
);
601 wxStringTokenizer
tok(resStr
, _T(";"), wxTOKEN_STRTOK
);
602 if (tok
.HasMoreTokens())
604 wxString token1
= tok
.GetNextToken();
605 if (!tok
.HasMoreTokens())
612 wxString token2
= tok
.GetNextToken();
614 if (tok
.HasMoreTokens())
616 wxString token3
= tok
.GetNextToken();
618 // Now convert 3 strings into decimal numbers, and then hex numbers.
619 int red
= wxAtoi(token1
.c_str());
620 int green
= wxAtoi(token2
.c_str());
621 int blue
= wxAtoi(token3
.c_str());
623 wxStrcpy(resStr
, _T("#"));
627 wxStrcat(resStr
, buf
);
628 DecToHex(green
, buf
);
629 wxStrcat(resStr
, buf
);
631 wxStrcat(resStr
, buf
);
640 void OutputFont(void)
642 // Only output <font face> if explicitly requested by htmlFaceName= directive in
643 // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's
647 // Output <FONT FACE=...>
648 TexOutput(_T("<FONT FACE=\""));
649 TexOutput(htmlFaceName
);
650 TexOutput(_T("\">\n"));
654 // Output start of <BODY> block
655 void OutputBodyStart(void)
657 TexOutput(_T("\n<BODY"));
658 if (backgroundImageString
)
660 bool isPicture
= false;
661 wxChar
*s
= ParseColourString(backgroundImageString
, &isPicture
);
664 TexOutput(_T(" BACKGROUND=\""));
669 if (backgroundColourString
)
671 bool isPicture
= false;
672 wxChar
*s
= ParseColourString(backgroundColourString
, &isPicture
);
675 TexOutput(_T(" BGCOLOR="));
680 // Set foreground text colour, if one is specified
681 if (textColourString
)
683 bool isPicture
= false;
684 wxChar
*s
= ParseColourString(textColourString
, &isPicture
);
687 TexOutput(_T(" TEXT=")); TexOutput(s
);
690 // Set link text colour, if one is specified
691 if (linkColourString
)
693 bool isPicture
= false;
694 wxChar
*s
= ParseColourString(linkColourString
, &isPicture
);
697 TexOutput(_T(" LINK=")); TexOutput(s
);
700 // Set followed link text colour, if one is specified
701 if (followedLinkColourString
)
703 bool isPicture
= false;
704 wxChar
*s
= ParseColourString(followedLinkColourString
, &isPicture
);
707 TexOutput(_T(" VLINK=")); TexOutput(s
);
710 TexOutput(_T(">\n"));
717 TexOutput(_T("<head>"));
718 if (htmlStylesheet
) {
719 TexOutput(_T("<link rel=stylesheet type=\"text/css\" href=\""));
720 TexOutput(htmlStylesheet
);
721 TexOutput(_T("\">"));
725 void HTMLHeadTo(FILE* f
)
728 wxFprintf(f
,_T("<head><link rel=stylesheet type=\"text/css\" href=\"%s\">"),htmlStylesheet
);
730 wxFprintf(f
,_T("<head>"));
733 // Called on start/end of macro examination
734 void HTMLOnMacro(int macroId
, int no_args
, bool start
)
740 case ltCHAPTERHEADING
:
748 if (macroId
!= ltCHAPTERSTAR
)
751 SetCurrentOutput(NULL
);
752 startedSections
= true;
754 wxChar
*topicName
= FindTopicName(GetNextChunk());
755 ReopenFile(&Chapters
, &ChaptersName
, topicName
);
756 AddTexRef(topicName
, ChaptersName
, ChapterNameString
);
758 SetCurrentChapterName(topicName
, ChaptersName
);
759 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(0, topicName
, ChaptersName
);
761 SetCurrentOutput(Chapters
);
764 TexOutput(_T("<title>"));
765 OutputCurrentSection(); // Repeat section header
766 TexOutput(_T("</title></head>\n"));
769 wxChar titleBuf
[200];
770 if (truncateFilenames
)
771 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s.htm"), wxFileNameFromPath(FileRoot
));
773 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
775 wxFprintf(Chapters
, _T("<A NAME=\"%s\"></A>"), topicName
);
777 AddBrowseButtons(_T(""), titleBuf
, // Up
778 lastTopic
, lastFileName
, // Last topic
779 topicName
, ChaptersName
); // This topic
781 if(PrimaryAnchorOfTheFile(ChaptersName
, topicName
))
782 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s\">"), ConvertCase(ChaptersName
));
784 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), topicName
);
786 if (htmlFrameContents
&& FrameContents
)
788 SetCurrentOutput(FrameContents
);
789 if(PrimaryAnchorOfTheFile(ChaptersName
, topicName
))
790 wxFprintf(FrameContents
, _T("\n<LI><A HREF=\"%s\" TARGET=\"mainwindow\">"), ConvertCase(ChaptersName
));
792 wxFprintf(FrameContents
, _T("\n<LI><A HREF=\"%s#%s\" TARGET=\"mainwindow\">"), ConvertCase(ChaptersName
), topicName
);
793 OutputCurrentSection();
794 wxFprintf(FrameContents
, _T("</A>\n"));
797 SetCurrentOutputs(Contents
, Chapters
);
798 wxFprintf(Chapters
, _T("\n<H2>"));
799 OutputCurrentSection();
800 wxFprintf(Contents
, _T("</A>\n"));
801 wxFprintf(Chapters
, _T("</H2>\n"));
803 SetCurrentOutput(Chapters
);
805 // Add this section title to the list of keywords
808 OutputCurrentSectionToString(wxTex2RTFBuffer
);
809 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, ConvertCase(currentFileName
));
816 case ltSECTIONHEADING
:
823 subsectionStarted
= false;
825 if (macroId
!= ltSECTIONSTAR
)
828 SetCurrentOutput(NULL
);
829 startedSections
= true;
831 wxChar
*topicName
= FindTopicName(GetNextChunk());
832 ReopenFile(&Sections
, &SectionsName
, topicName
);
833 AddTexRef(topicName
, SectionsName
, SectionNameString
);
835 SetCurrentSectionName(topicName
, SectionsName
);
836 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(1, topicName
, SectionsName
);
838 SetCurrentOutput(Sections
);
840 TexOutput(_T("<title>"));
841 OutputCurrentSection();
842 TexOutput(_T("</title></head>\n"));
845 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
846 AddBrowseButtons(CurrentChapterName
, CurrentChapterFile
, // Up
847 lastTopic
, lastFileName
, // Last topic
848 topicName
, SectionsName
); // This topic
850 FILE *jumpFrom
= ((DocumentStyle
== LATEX_ARTICLE
) ? Contents
: Chapters
);
852 SetCurrentOutputs(jumpFrom
, Sections
);
853 if (DocumentStyle
== LATEX_ARTICLE
)
855 if(PrimaryAnchorOfTheFile(SectionsName
, topicName
))
856 wxFprintf(jumpFrom
, _T("\n<LI><A HREF=\"%s\">"), ConvertCase(SectionsName
));
858 wxFprintf(jumpFrom
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(SectionsName
), topicName
);
862 if(PrimaryAnchorOfTheFile(SectionsName
, topicName
))
863 wxFprintf(jumpFrom
, _T("\n<A HREF=\"%s\"><B>"), ConvertCase(SectionsName
));
865 wxFprintf(jumpFrom
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SectionsName
), topicName
);
868 wxFprintf(Sections
, _T("\n<H2>"));
869 OutputCurrentSection();
871 if (DocumentStyle
== LATEX_ARTICLE
)
872 wxFprintf(jumpFrom
, _T("</A>\n"));
874 wxFprintf(jumpFrom
, _T("</B></A><BR>\n"));
875 wxFprintf(Sections
, _T("</H2>\n"));
877 SetCurrentOutput(Sections
);
878 // Add this section title to the list of keywords
881 OutputCurrentSectionToString(wxTex2RTFBuffer
);
882 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
888 case ltSUBSECTIONSTAR
:
889 case ltMEMBERSECTION
:
890 case ltFUNCTIONSECTION
:
896 OnError(_T("You cannot have a subsection before a section!"));
902 if (macroId
!= ltSUBSECTIONSTAR
)
905 if ( combineSubSections
&& !subsectionStarted
)
909 // Read old .con file in at this point
911 wxStrcpy(buf
, CurrentSectionFile
);
912 wxStripExtension(buf
);
913 wxStrcat(buf
, _T(".con"));
914 FILE *fd
= wxFopen(buf
, _T("r"));
920 wxPutc(ch
, Sections
);
925 wxFprintf(Sections
, _T("<P>\n"));
927 // Close old file, create a new file for the sub(sub)section contents entries
928 ReopenSectionContentsFile();
931 startedSections
= true;
932 subsectionStarted
= true;
934 wxChar
*topicName
= FindTopicName(GetNextChunk());
936 if ( !combineSubSections
)
938 SetCurrentOutput(NULL
);
939 ReopenFile(&Subsections
, &SubsectionsName
, topicName
);
940 AddTexRef(topicName
, SubsectionsName
, SubsectionNameString
);
941 SetCurrentSubsectionName(topicName
, SubsectionsName
);
942 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SubsectionsName
);
943 SetCurrentOutput(Subsections
);
946 TexOutput(_T("<title>"));
947 OutputCurrentSection();
948 TexOutput(_T("</title></head>\n"));
951 wxFprintf(Subsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
952 AddBrowseButtons(CurrentSectionName
, CurrentSectionFile
, // Up
953 lastTopic
, lastFileName
, // Last topic
954 topicName
, SubsectionsName
); // This topic
956 SetCurrentOutputs(Sections
, Subsections
);
957 if(PrimaryAnchorOfTheFile(SubsectionsName
, topicName
))
958 wxFprintf(Sections
, _T("\n<A HREF=\"%s\"><B>"), ConvertCase(SubsectionsName
));
960 wxFprintf(Sections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName
), topicName
);
962 wxFprintf(Subsections
, _T("\n<H3>"));
963 OutputCurrentSection();
964 wxFprintf(Sections
, _T("</B></A><BR>\n"));
965 wxFprintf(Subsections
, _T("</H3>\n"));
967 SetCurrentOutput(Subsections
);
971 AddTexRef(topicName
, SectionsName
, SubsectionNameString
);
972 SetCurrentSubsectionName(topicName
, SectionsName
);
974 // if ( subsectionNo != 0 )
975 wxFprintf(Sections
, _T("\n<HR>\n"));
977 // We're putting everything into the section file
978 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
979 wxFprintf(Sections
, _T("\n<H3>"));
980 OutputCurrentSection();
981 wxFprintf(Sections
, _T("</H3>\n"));
983 SetCurrentOutput(SectionContentsFD
);
984 wxFprintf(SectionContentsFD
, _T("<A HREF=\"#%s\">"), topicName
);
985 OutputCurrentSection();
986 TexOutput(_T("</A><BR>\n"));
988 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
989 SetCurrentOutput(Sections
);
991 // Add this section title to the list of keywords
994 OutputCurrentSectionToString(wxTex2RTFBuffer
);
995 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
1002 case ltSUBSUBSECTION
:
1003 case ltSUBSUBSECTIONSTAR
:
1007 if (!Subsections
&& !combineSubSections
)
1009 OnError(_T("You cannot have a subsubsection before a subsection!"));
1013 if (macroId
!= ltSUBSUBSECTIONSTAR
)
1016 startedSections
= true;
1018 wxChar
*topicName
= FindTopicName(GetNextChunk());
1020 if ( !combineSubSections
)
1022 SetCurrentOutput(NULL
);
1023 ReopenFile(&Subsubsections
, &SubsubsectionsName
, topicName
);
1024 AddTexRef(topicName
, SubsubsectionsName
, SubsubsectionNameString
);
1025 SetCurrentSubsubsectionName(topicName
, SubsubsectionsName
);
1026 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(3, topicName
, SubsubsectionsName
);
1028 SetCurrentOutput(Subsubsections
);
1030 TexOutput(_T("<title>"));
1031 OutputCurrentSection();
1032 TexOutput(_T("</title></head>\n"));
1035 wxFprintf(Subsubsections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1037 AddBrowseButtons(CurrentSubsectionName
, CurrentSubsectionFile
, // Up
1038 lastTopic
, lastFileName
, // Last topic
1039 topicName
, SubsubsectionsName
); // This topic
1041 SetCurrentOutputs(Subsections
, Subsubsections
);
1042 if(PrimaryAnchorOfTheFile(SubsubsectionsName
, topicName
))
1043 wxFprintf(Subsections
, _T("\n<A HREF=\"%s\"><B>"), ConvertCase(SubsubsectionsName
));
1045 wxFprintf(Subsections
, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName
), topicName
);
1047 wxFprintf(Subsubsections
, _T("\n<H3>"));
1048 OutputCurrentSection();
1049 wxFprintf(Subsections
, _T("</B></A><BR>\n"));
1050 wxFprintf(Subsubsections
, _T("</H3>\n"));
1054 AddTexRef(topicName
, SectionsName
, SubsubsectionNameString
);
1055 SetCurrentSubsectionName(topicName
, SectionsName
);
1056 wxFprintf(Sections
, _T("\n<HR>\n"));
1058 // We're putting everything into the section file
1059 wxFprintf(Sections
, _T("<A NAME=\"%s\"></A>"), topicName
);
1060 wxFprintf(Sections
, _T("\n<H3>"));
1061 OutputCurrentSection();
1062 wxFprintf(Sections
, _T("</H3>\n"));
1063 /* TODO: where do we put subsubsection contents entry - indented, with subsection entries?
1064 SetCurrentOutput(SectionContentsFD);
1065 wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName);
1066 OutputCurrentSection();
1067 TexOutput(_T("</A><BR>"));
1069 if (htmlWorkshopFiles
) HTMLWorkshopAddToContents(2, topicName
, SectionsName
);
1070 SetCurrentOutput(Sections
);
1073 // Add this section title to the list of keywords
1076 OutputCurrentSectionToString(wxTex2RTFBuffer
);
1077 AddKeyWordForTopic(topicName
, wxTex2RTFBuffer
, currentFileName
);
1086 if ( !combineSubSections
)
1087 SetCurrentOutput(Subsections
);
1089 SetCurrentOutput(Sections
);
1100 if ( !combineSubSections
)
1101 SetCurrentOutput(Subsections
);
1103 SetCurrentOutput(Sections
);
1114 if ( !combineSubSections
)
1115 SetCurrentOutput(Subsections
);
1117 SetCurrentOutput(Sections
);
1128 // TexOutput(_T("<B>void</B>"));
1132 TexOutput(_T("HARDY"));
1136 TexOutput(_T("wxCLIPS"));
1140 TexOutput(_T("&"));
1142 case ltSPECIALAMPERSAND
:
1148 // End cell, start cell
1150 TexOutput(_T("</FONT></TD>"));
1152 // Start new row and cell, setting alignment for the first cell.
1153 if (currentColumn
< noColumns
)
1157 if (TableData
[currentColumn
].justification
== 'c')
1158 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=CENTER>"));
1159 else if (TableData
[currentColumn
].justification
== 'r')
1160 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=RIGHT>"));
1161 else if (TableData
[currentColumn
].absWidth
)
1163 // Convert from points * 20 into pixels.
1164 int points
= TableData
[currentColumn
].width
/ 20;
1166 // Say the display is 100 DPI (dots/pixels per inch).
1167 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1168 int pixels
= (int)(points
* 100.0 / 72.0);
1169 wxSnprintf(buf
, sizeof(buf
), _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1172 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD ALIGN=LEFT>"));
1177 TexOutput(_T("&"));
1181 case ltBACKSLASHCHAR
:
1187 // End row. In fact, tables without use of \row or \ruledrow isn't supported for
1188 // HTML: the syntax is too different (e.g. how do we know where to put the first </TH>
1189 // if we've ended the last row?). So normally you wouldn't use \\ to end a row.
1190 TexOutput(_T("</TR>\n"));
1193 TexOutput(_T("<BR>\n"));
1204 // Start new row and cell, setting alignment for the first cell.
1206 if (TableData
[currentColumn
].justification
== 'c')
1207 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=CENTER>"));
1208 else if (TableData
[currentColumn
].justification
== 'r')
1209 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=RIGHT>"));
1210 else if (TableData
[currentColumn
].absWidth
)
1212 // Convert from points * 20 into pixels.
1213 int points
= TableData
[currentColumn
].width
/ 20;
1215 // Say the display is 100 DPI (dots/pixels per inch).
1216 // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots.
1217 int pixels
= (int)(points
* 100.0 / 72.0);
1218 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels
);
1221 wxSnprintf(buf
, sizeof(buf
), _T("<TR>\n<TD ALIGN=LEFT>"));
1228 // Start new row and cell
1229 TexOutput(_T("</FONT></TD>\n</TR>\n"));
1233 // HTML-only: break until the end of the picture (both margins are clear).
1237 TexOutput(_T("<BR CLEAR=ALL>"));
1240 case ltRTFSP
: // Explicit space, RTF only
1242 case ltSPECIALTILDE
:
1246 #if (1) // if(inVerbatim)
1257 TexOutput(_T("<UL><UL>\n"));
1259 TexOutput(_T("</UL></UL>\n"));
1265 // case ltTWOCOLLIST:
1272 if (macroId
== ltENUMERATE
)
1273 listType
= LATEX_ENUMERATE
;
1274 else if (macroId
== ltITEMIZE
)
1275 listType
= LATEX_ITEMIZE
;
1277 listType
= LATEX_DESCRIPTION
;
1279 itemizeStack
.Insert(new ItemizeStruc(listType
));
1283 TexOutput(_T("<UL>\n"));
1285 case LATEX_ENUMERATE
:
1286 TexOutput(_T("<OL>\n"));
1288 case LATEX_DESCRIPTION
:
1290 TexOutput(_T("<DL>\n"));
1297 if (itemizeStack
.GetFirst())
1299 ItemizeStruc
*struc
= (ItemizeStruc
*)itemizeStack
.GetFirst()->GetData();
1300 switch (struc
->listType
)
1303 TexOutput(_T("</UL>\n"));
1305 case LATEX_ENUMERATE
:
1306 TexOutput(_T("</OL>\n"));
1308 case LATEX_DESCRIPTION
:
1310 TexOutput(_T("</DL>\n"));
1315 delete itemizeStack
.GetFirst();
1323 TexOutput(_T("\n<TABLE>\n"));
1325 TexOutput(_T("\n</TABLE>\n"));
1335 TexOutput(_T("<P>\n"));
1338 /* For footnotes we need to output the text at the bottom of the page and
1339 * insert a reference to it. Is it worth the trouble...
1341 case ltFOOTNOTEPOPUP:
1345 TexOutput(_T("<FN>"));
1347 else TexOutput(_T("</FN>"));
1354 TexOutput(_T("<TT>"));
1355 else TexOutput(_T("</TT>"));
1363 wxSnprintf(buf
, sizeof(buf
), _T("<PRE>\n"));
1366 else TexOutput(_T("</PRE>\n"));
1374 TexOutput(_T("<CENTER>"));
1376 else TexOutput(_T("</CENTER>"));
1384 TexOutput(_T("{\\ql "));
1386 else TexOutput(_T("}\\par\\pard\n"));
1395 TexOutput(_T("{\\qr "));
1397 else TexOutput(_T("}\\par\\pard\n"));
1405 // Netscape extension
1406 TexOutput(_T("<FONT SIZE=2>"));
1408 else TexOutput(_T("</FONT>"));
1415 // Netscape extension
1416 TexOutput(_T("<FONT SIZE=1>"));
1418 else TexOutput(_T("</FONT>"));
1425 // Netscape extension
1426 TexOutput(_T("<FONT SIZE=3>"));
1428 else TexOutput(_T("</FONT>"));
1435 // Netscape extension
1436 TexOutput(_T("<FONT SIZE=4>"));
1438 else TexOutput(_T("</FONT>"));
1445 // Netscape extension
1446 TexOutput(_T("<FONT SIZE=5>"));
1448 else TexOutput(_T("</FONT>"));
1455 // Netscape extension
1456 TexOutput(_T("<FONT SIZE=6>"));
1458 else TexOutput(_T("</FONT>"));
1467 TexOutput(_T("<B>"));
1469 else TexOutput(_T("</B>"));
1478 TexOutput(_T("<I>"));
1480 else TexOutput(_T("</I>"));
1488 TexOutput(_T("<EM>"));
1490 else TexOutput(_T("</EM>"));
1497 TexOutput(_T("<UL>"));
1499 else TexOutput(_T("</UL>"));
1508 TexOutput(_T("<TT>"));
1510 else TexOutput(_T("</TT>"));
1516 TexOutput(_T("©"), true);
1522 TexOutput(_T("®"), true);
1528 if (start
) TexOutput(_T("<--"));
1533 if (start
) TexOutput(_T("<=="));
1538 if (start
) TexOutput(_T("-->"));
1543 if (start
) TexOutput(_T("==>"));
1546 case ltLEFTRIGHTARROW
:
1548 if (start
) TexOutput(_T("<-->"));
1551 case ltLEFTRIGHTARROW2
:
1553 if (start
) TexOutput(_T("<==>"));
1566 wxNode
*node
= itemizeStack
.GetFirst();
1569 ItemizeStruc
*struc
= (ItemizeStruc
*)node
->GetData();
1570 struc
->currentItem
+= 1;
1571 if (struc
->listType
== LATEX_DESCRIPTION
)
1573 if (descriptionItemArg
)
1575 TexOutput(_T("<DT> "));
1576 TraverseChildrenFromChunk(descriptionItemArg
);
1577 TexOutput(_T("\n"));
1578 descriptionItemArg
= NULL
;
1580 TexOutput(_T("<DD>"));
1583 TexOutput(_T("<LI>"));
1590 if (start
&& DocumentTitle
&& DocumentAuthor
)
1592 // Add a special label for the contents page.
1593 // TexOutput(_T("<CENTER>\n"));
1594 TexOutput(_T("<A NAME=\"contents\">"));
1595 TexOutput(_T("<H2 ALIGN=CENTER>\n"));
1596 TraverseChildrenFromChunk(DocumentTitle
);
1597 TexOutput(_T("</H2>"));
1598 TexOutput(_T("<P>"));
1599 TexOutput(_T("</A>\n"));
1600 TexOutput(_T("<P>\n\n"));
1601 TexOutput(_T("<H3 ALIGN=CENTER>"));
1602 TraverseChildrenFromChunk(DocumentAuthor
);
1603 TexOutput(_T("</H3><P>\n\n"));
1606 TexOutput(_T("<H3 ALIGN=CENTER>"));
1607 TraverseChildrenFromChunk(DocumentDate
);
1608 TexOutput(_T("</H3><P>\n\n"));
1610 // TexOutput(_T("\n</CENTER>\n"));
1611 TexOutput(_T("\n<P><HR><P>\n"));
1614 // Now do optional frame contents page
1615 if (htmlFrameContents && FrameContents)
1617 SetCurrentOutput(FrameContents);
1619 // Add a special label for the contents page.
1620 TexOutput(_T("<CENTER>\n"));
1621 TexOutput(_T("<H3>\n"));
1622 TraverseChildrenFromChunk(DocumentTitle);
1623 TexOutput(_T("</H3>"));
1624 TexOutput(_T("<P>"));
1625 TexOutput(_T("</A>\n"));
1626 TexOutput(_T("<P>\n\n"));
1627 TexOutput(_T("<H3>"));
1628 TraverseChildrenFromChunk(DocumentAuthor);
1629 TexOutput(_T("</H3><P>\n\n"));
1632 TexOutput(_T("<H4>"));
1633 TraverseChildrenFromChunk(DocumentDate);
1634 TexOutput(_T("</H4><P>\n\n"));
1636 TexOutput(_T("\n</CENTER>\n"));
1637 TexOutput(_T("<P><HR><P>\n"));
1639 SetCurrentOutput(Titlepage);
1652 helpRefFilename
= NULL
;
1657 case ltBIBLIOGRAPHY
:
1661 DefaultOnMacro(macroId
, no_args
, start
);
1665 DefaultOnMacro(macroId
, no_args
, start
);
1666 TexOutput(_T("</DL>\n"));
1674 TexOutput(_T("<HR>\n"));
1682 TexOutput(_T("<HR>\n"));
1686 case ltTABLEOFCONTENTS
:
1690 // NB: if this is uncommented, the table of contents
1691 // completely disappears. If left commented, it's in the wrong
1693 //fflush(Titlepage);
1695 FILE *fd
= wxFopen(ContentsName
, _T("r"));
1701 wxPutc(ch
, Titlepage
);
1709 TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n"));
1710 OnInform(_T("Run Tex2RTF again to include contents page."));
1718 TexOutput(_T("<"));
1724 TexOutput(_T(">"));
1731 TexOutput(_T("<BLOCKQUOTE>"));
1733 TexOutput(_T("</BLOCKQUOTE>"));
1742 TexOutput(_T("\n<CAPTION>"));
1750 if (DocumentStyle
!= LATEX_ARTICLE
)
1751 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d.%d: "), FigureNameString
, chapterNo
, figureNo
);
1753 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d: "), FigureNameString
, figureNo
);
1759 if (DocumentStyle
!= LATEX_ARTICLE
)
1760 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d.%d: "), TableNameString
, chapterNo
, tableNo
);
1762 wxSnprintf(figBuf
, sizeof(figBuf
), _T("%s %d: "), TableNameString
, tableNo
);
1770 TexOutput(_T("\n</CAPTION>\n"));
1772 wxChar
*topicName
= FindTopicName(GetNextChunk());
1774 int n
= inFigure
? figureNo
: tableNo
;
1776 AddTexRef(topicName
, NULL
, NULL
,
1777 ((DocumentStyle
!= LATEX_ARTICLE
) ? chapterNo
: n
),
1778 ((DocumentStyle
!= LATEX_ARTICLE
) ? n
: 0));
1784 if (start
) TexOutput(_T("ß"));
1789 if (start
) inFigure
= true;
1790 else inFigure
= false;
1795 if (start
) inTable
= true;
1796 else inTable
= false;
1800 DefaultOnMacro(macroId
, no_args
, start
);
1805 // Called on start/end of argument examination
1806 bool HTMLOnArgument(int macroId
, int arg_no
, bool start
)
1812 case ltCHAPTERHEADING
:
1815 case ltSECTIONHEADING
:
1817 case ltSUBSECTIONSTAR
:
1818 case ltSUBSUBSECTION
:
1819 case ltSUBSUBSECTIONSTAR
:
1821 case ltMEMBERSECTION
:
1822 case ltFUNCTIONSECTION
:
1824 if (!start
&& (arg_no
== 1))
1825 currentSection
= GetArgChunk();
1830 if (start
&& (arg_no
== 1))
1831 TexOutput(_T("<B>"));
1833 if (!start
&& (arg_no
== 1))
1834 TexOutput(_T("</B> "));
1836 if (start
&& (arg_no
== 2))
1838 if (!suppressNameDecoration
) TexOutput(_T("<B>"));
1839 currentMember
= GetArgChunk();
1841 if (!start
&& (arg_no
== 2))
1843 if (!suppressNameDecoration
) TexOutput(_T("</B>"));
1846 if (start
&& (arg_no
== 3))
1848 if (!start
&& (arg_no
== 3))
1854 if (start
&& (arg_no
== 1))
1855 TexOutput(_T("<B>"));
1856 if (!start
&& (arg_no
== 1))
1857 TexOutput(_T("</B> "));
1859 if (start
&& (arg_no
== 2))
1861 if (!suppressNameDecoration
) TexOutput(_T("( "));
1862 currentMember
= GetArgChunk();
1864 if (!start
&& (arg_no
== 2))
1868 if (!start
&& (arg_no
== 3))
1874 if (!start
&& (arg_no
== 1))
1877 if (start
&& (arg_no
== 2))
1878 TexOutput(_T("(*"));
1879 if (!start
&& (arg_no
== 2))
1882 if (start
&& (arg_no
== 2))
1883 currentMember
= GetArgChunk();
1885 if (start
&& (arg_no
== 3))
1887 if (!start
&& (arg_no
== 3))
1893 if (start
&& (arg_no
== 1))
1894 TexOutput(_T("<B>"));
1895 if (!start
&& (arg_no
== 1))
1896 TexOutput(_T("</B>"));
1897 if (start
&& (arg_no
== 2))
1899 TexOutput(_T("<I>"));
1901 if (!start
&& (arg_no
== 2))
1903 TexOutput(_T("</I>"));
1909 if (start
&& (arg_no
== 1))
1910 TexOutput(_T("<B>"));
1911 if (!start
&& (arg_no
== 1))
1912 TexOutput(_T("</B> ")); // This is the difference from param - one space!
1913 if (start
&& (arg_no
== 2))
1915 TexOutput(_T("<I>"));
1917 if (!start
&& (arg_no
== 2))
1919 TexOutput(_T("</I>"));
1925 if (!start
&& (arg_no
== 1))
1928 if (start
&& (arg_no
== 2))
1929 currentMember
= GetArgChunk();
1938 wxChar
*refName
= GetArgData();
1941 TexRef
*texRef
= FindReference(refName
);
1944 sec
= texRef
->sectionNumber
;
1957 if (IsArgOptional())
1959 else if ((GetNoArgs() - arg_no
) == 1)
1962 helpRefText
= GetArgChunk();
1965 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
1969 TexChunk
*ref
= GetArgChunk();
1970 TexOutput(_T("<A HREF=\""));
1972 TraverseChildrenFromChunk(ref
);
1974 TexOutput(_T("\">"));
1976 TraverseChildrenFromChunk(helpRefText
);
1977 TexOutput(_T("</A>"));
1987 if (IsArgOptional())
1990 helpRefFilename
= GetArgChunk();
1993 if ((GetNoArgs() - arg_no
) == 1)
1996 helpRefText
= GetArgChunk();
1999 else if ((GetNoArgs() - arg_no
) == 0) // Arg = 2, or 3 if first is optional
2003 wxChar
*refName
= GetArgData();
2004 wxChar
*refFilename
= NULL
;
2008 TexRef
*texRef
= FindReference(refName
);
2011 if (texRef
->refFile
&& wxStrcmp(texRef
->refFile
, _T("??")) != 0)
2012 refFilename
= texRef
->refFile
;
2014 TexOutput(_T("<A HREF=\""));
2015 // If a filename is supplied, use it, otherwise try to
2016 // use the filename associated with the reference (from this document).
2017 if (helpRefFilename
)
2019 TraverseChildrenFromChunk(helpRefFilename
);
2023 else if (refFilename
)
2025 TexOutput(ConvertCase(refFilename
));
2026 if(!PrimaryAnchorOfTheFile(texRef
->refFile
, refName
))
2032 TexOutput(_T("\">"));
2034 TraverseChildrenFromChunk(helpRefText
);
2035 TexOutput(_T("</A>"));
2040 TraverseChildrenFromChunk(helpRefText
);
2042 TexOutput(_T(" (REF NOT FOUND)"));
2044 errBuf
.Printf(_T("Warning: unresolved reference '%s'"), refName
);
2045 OnInform((wxChar
*)errBuf
.c_str());
2048 else TexOutput(_T("??"));
2063 wxChar
*alignment
= _T("");
2064 if (macroId
== ltIMAGEL
)
2065 alignment
= _T(" align=left");
2066 else if (macroId
== ltIMAGER
)
2067 alignment
= _T(" align=right");
2069 // Try to find an XBM or GIF image first.
2070 wxChar
*filename
= copystring(GetArgData());
2073 wxStrcpy(buf
, filename
);
2074 StripExtension(buf
);
2075 wxStrcat(buf
, _T(".xbm"));
2076 wxString f
= TexPathList
.FindValidPath(buf
);
2078 if (f
== _T("")) // Try for a GIF instead
2080 wxStrcpy(buf
, filename
);
2081 StripExtension(buf
);
2082 wxStrcat(buf
, _T(".gif"));
2083 f
= TexPathList
.FindValidPath(buf
);
2086 if (f
== _T("")) // Try for a JPEG instead
2088 wxStrcpy(buf
, filename
);
2089 StripExtension(buf
);
2090 wxStrcat(buf
, _T(".jpg"));
2091 f
= TexPathList
.FindValidPath(buf
);
2094 if (f
== _T("")) // Try for a PNG instead
2096 wxStrcpy(buf
, filename
);
2097 StripExtension(buf
);
2098 wxStrcat(buf
, _T(".png"));
2099 f
= TexPathList
.FindValidPath(buf
);
2104 wxChar
*inlineFilename
= copystring(f
);
2106 wxChar
*originalFilename
= TexPathList
.FindValidPath(filename
);
2107 // If we have found the existing filename, make the inline
2108 // image point to the original file (could be PS, for example)
2109 if (originalFilename
&& (wxStrcmp(inlineFilename
, originalFilename
) != 0))
2111 TexOutput(_T("<A HREF=\""));
2112 TexOutput(ConvertCase(originalFilename
));
2113 TexOutput(_T("\">"));
2114 TexOutput(_T("<img src=\""));
2115 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2116 TexOutput(_T("\""));
2117 TexOutput(alignment
);
2118 TexOutput(_T("></A>"));
2123 TexOutput(_T("<img src=\""));
2124 TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename
)));
2125 TexOutput(_T("\""));
2126 TexOutput(alignment
);
2128 delete[] inlineFilename
;
2133 // Last resort - a link to a PS file.
2134 TexOutput(_T("<A HREF=\""));
2135 TexOutput(ConvertCase(wxFileNameFromPath(filename
)));
2136 TexOutput(_T("\">Picture</A>\n"));
2137 wxSnprintf(buf
, sizeof(buf
), _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2144 // First arg is PSBOX spec (ignored), second is image file, third is map name.
2147 static wxChar
*imageFile
= NULL
;
2148 if (start
&& (arg_no
== 2))
2150 // Try to find an XBM or GIF image first.
2151 wxChar
*filename
= copystring(GetArgData());
2154 wxStrcpy(buf
, filename
);
2155 StripExtension(buf
);
2156 wxStrcat(buf
, _T(".xbm"));
2157 wxString f
= TexPathList
.FindValidPath(buf
);
2159 if (f
== _T("")) // Try for a GIF instead
2161 wxStrcpy(buf
, filename
);
2162 StripExtension(buf
);
2163 wxStrcat(buf
, _T(".gif"));
2164 f
= TexPathList
.FindValidPath(buf
);
2169 wxSnprintf(buf
, sizeof(buf
), _T("Warning: could not find an inline XBM/GIF for %s."), filename
);
2178 imageFile
= copystring(f
);
2181 else if (start
&& (arg_no
== 3))
2185 // First, try to find a .shg (segmented hypergraphics file)
2186 // that we can convert to a map file
2188 wxStrcpy(buf
, imageFile
);
2189 StripExtension(buf
);
2190 wxStrcat(buf
, _T(".shg"));
2191 wxString f
= TexPathList
.FindValidPath(buf
);
2195 // The default HTML file to go to is THIS file (so a no-op)
2196 SHGToMap((wxChar
*)f
.c_str(), currentFileName
);
2199 wxChar
*mapName
= GetArgData();
2200 TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/"));
2204 TexOutput(_T("unknown"));
2205 TexOutput(_T("\">"));
2206 TexOutput(_T("<img src=\""));
2207 TexOutput(ConvertCase(wxFileNameFromPath(imageFile
)));
2208 TexOutput(_T("\" ISMAP></A><P>"));
2228 descriptionItemArg
= GetArgChunk();
2234 case ltTWOCOLITEMRULED
:
2237 if (start && (arg_no == 1))
2238 TexOutput(_T("\n<DT> "));
2239 if (start && (arg_no == 2))
2240 TexOutput(_T("<DD> "));
2246 if (TwoColWidthA
> -1)
2249 wxSnprintf(buf
, sizeof(buf
), _T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA
);
2254 TexOutput(_T("\n<TR><TD VALIGN=TOP>\n"));
2258 TexOutput(_T("\n</FONT></TD>\n"));
2265 if (TwoColWidthB
> -1)
2268 wxSnprintf(buf
, sizeof(buf
), _T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB
);
2273 TexOutput(_T("\n<TD VALIGN=TOP>\n"));
2277 TexOutput(_T("\n</FONT></TD></TR>\n"));
2281 case ltNUMBEREDBIBITEM
:
2283 if (arg_no
== 1 && start
)
2285 TexOutput(_T("\n<DT> "));
2287 if (arg_no
== 2 && !start
)
2288 TexOutput(_T("<P>\n"));
2294 if (arg_no
== 1 && start
)
2296 wxChar
*citeKey
= GetArgData();
2297 TexRef
*ref
= (TexRef
*)TexReferences
.Get(citeKey
);
2300 if (ref
->sectionNumber
) delete[] ref
->sectionNumber
;
2301 wxSnprintf(buf
, sizeof(buf
), _T("[%d]"), citeCount
);
2302 ref
->sectionNumber
= copystring(buf
);
2305 wxSnprintf(buf
, sizeof(buf
), _T("\n<DT> [%d] "), citeCount
);
2310 if (arg_no
== 2 && !start
)
2311 TexOutput(_T("<P>\n"));
2315 case ltMARGINPARODD
:
2316 case ltMARGINPAREVEN
:
2322 TexOutput(_T("<HR>\n"));
2326 TexOutput(_T("<HR><P>\n"));
2330 case ltTWOCOLWIDTHA
:
2334 wxChar
*val
= GetArgData();
2335 float points
= ParseUnitArgument(val
);
2336 TwoColWidthA
= (int)((points
* 100.0) / 72.0);
2341 case ltTWOCOLWIDTHB
:
2345 wxChar
*val
= GetArgData();
2346 float points
= ParseUnitArgument(val
);
2347 TwoColWidthB
= (int)((points
* 100.0) / 72.0);
2355 case ltACCENT_GRAVE
:
2359 wxChar
*val
= GetArgData();
2365 TexOutput(_T("à"));
2368 TexOutput(_T("è"));
2371 TexOutput(_T("ì"));
2374 TexOutput(_T("ò"));
2377 TexOutput(_T("ù"));
2380 TexOutput(_T("À"));
2383 TexOutput(_T("È"));
2386 TexOutput(_T("Ì"));
2389 TexOutput(_T("Ò"));
2392 TexOutput(_T("Ì"));
2401 case ltACCENT_ACUTE
:
2405 wxChar
*val
= GetArgData();
2411 TexOutput(_T("á"));
2414 TexOutput(_T("é"));
2417 TexOutput(_T("í"));
2420 TexOutput(_T("ó"));
2423 TexOutput(_T("ú"));
2426 TexOutput(_T("ý"));
2429 TexOutput(_T("Á"));
2432 TexOutput(_T("É"));
2435 TexOutput(_T("Í"));
2438 TexOutput(_T("Ó"));
2441 TexOutput(_T("Ú"));
2444 TexOutput(_T("Ý"));
2453 case ltACCENT_CARET
:
2457 wxChar
*val
= GetArgData();
2463 TexOutput(_T("â"));
2466 TexOutput(_T("ê"));
2469 TexOutput(_T("î"));
2472 TexOutput(_T("ô"));
2475 TexOutput(_T("û"));
2478 TexOutput(_T("Â"));
2481 TexOutput(_T("Ê"));
2484 TexOutput(_T("Î"));
2487 TexOutput(_T("Ô"));
2490 TexOutput(_T("Î"));
2499 case ltACCENT_TILDE
:
2503 wxChar
*val
= GetArgData();
2512 TexOutput(_T("ã"));
2515 TexOutput(_T("ñ"));
2518 TexOutput(_T("õ"));
2521 TexOutput(_T("Ã"));
2524 TexOutput(_T("Ñ"));
2527 TexOutput(_T("Õ"));
2536 case ltACCENT_UMLAUT
:
2540 wxChar
*val
= GetArgData();
2546 TexOutput(_T("ä"));
2549 TexOutput(_T("ë"));
2552 TexOutput(_T("ï"));
2555 TexOutput(_T("ö"));
2558 TexOutput(_T("ü"));
2561 TexOutput(_T("ÿ"));
2564 TexOutput(_T("Ä"));
2567 TexOutput(_T("Ë"));
2570 TexOutput(_T("Ï"));
2573 TexOutput(_T("Ö"));
2576 TexOutput(_T("Ü"));
2579 TexOutput(_T("Ÿ"));
2592 wxChar
*val
= GetArgData();
2598 TexOutput(_T("å"));
2601 TexOutput(_T("Å"));
2614 wxChar
*val
= GetArgData();
2617 bool isPicture
= false;
2618 ParseColourString(val
, &isPicture
);
2621 if (backgroundImageString
)
2622 delete[] backgroundImageString
;
2623 backgroundImageString
= copystring(val
);
2627 if (backgroundColourString
)
2628 delete[] backgroundColourString
;
2629 backgroundColourString
= copystring(val
);
2635 case ltBACKGROUNDIMAGE
:
2639 wxChar
*val
= GetArgData();
2642 if (backgroundImageString
)
2643 delete[] backgroundImageString
;
2644 backgroundImageString
= copystring(val
);
2649 case ltBACKGROUNDCOLOUR
:
2653 wxChar
*val
= GetArgData();
2656 if (backgroundColourString
)
2657 delete[] backgroundColourString
;
2658 backgroundColourString
= copystring(val
);
2667 wxChar
*val
= GetArgData();
2670 if (textColourString
)
2671 delete[] textColourString
;
2672 textColourString
= copystring(val
);
2681 wxChar
*val
= GetArgData();
2684 if (linkColourString
)
2685 delete[] linkColourString
;
2686 linkColourString
= copystring(val
);
2691 case ltFOLLOWEDLINKCOLOUR
:
2695 wxChar
*val
= GetArgData();
2698 if (followedLinkColourString
)
2699 delete[] followedLinkColourString
;
2700 followedLinkColourString
= copystring(val
);
2705 case ltACCENT_CADILLA
:
2709 wxChar
*val
= GetArgData();
2715 TexOutput(_T("ç"));
2718 TexOutput(_T("Ç"));
2729 case ltFOOTNOTEPOPUP:
2739 case ltSUPERTABULAR
:
2745 currentRowNumber
= 0;
2748 tableVerticalLineLeft
= false;
2749 tableVerticalLineRight
= false;
2751 wxChar
*alignString
= copystring(GetArgData());
2752 ParseTableArgument(alignString
);
2754 TexOutput(_T("<TABLE BORDER>\n"));
2756 // Write the first row formatting for compatibility
2757 // with standard Latex
2758 if (compatibilityMode
)
2760 TexOutput(_T("<TR>\n<TD>"));
2763 for (int i = 0; i < noColumns; i++)
2765 currentWidth += TableData[i].width;
2766 wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth);
2769 TexOutput(_T("\\pard\\intbl\n"));
2772 delete[] alignString
;
2777 else if (arg_no
== 2 && !start
)
2779 TexOutput(_T("</TABLE>\n"));
2784 case ltTHEBIBLIOGRAPHY
:
2786 if (start
&& (arg_no
== 1))
2788 ReopenFile(&Chapters
, &ChaptersName
, _T("bibliography"));
2789 AddTexRef(_T("bibliography"), ChaptersName
, _T("bibliography"));
2790 SetCurrentSubsectionName(_T("bibliography"), ChaptersName
);
2794 SetCurrentOutput(Chapters
);
2796 wxChar titleBuf
[150];
2797 if (truncateFilenames
)
2798 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s.htm"), wxFileNameFromPath(FileRoot
));
2800 wxSnprintf(titleBuf
, sizeof(titleBuf
), _T("%s_contents.html"), wxFileNameFromPath(FileRoot
));
2803 TexOutput(_T("<title>"));
2804 TexOutput(ReferencesNameString
);
2805 TexOutput(_T("</title></head>\n"));
2808 wxFprintf(Chapters
, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString
);
2809 AddBrowseButtons(_T("contents"), titleBuf
, // Up
2810 lastTopic
, lastFileName
, // Last topic
2811 _T("bibliography"), ChaptersName
); // This topic
2813 SetCurrentOutputs(Contents
, Chapters
);
2814 if(PrimaryAnchorOfTheFile(ChaptersName
, _T("bibliography")))
2815 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s\">"), ConvertCase(ChaptersName
));
2817 wxFprintf(Contents
, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName
), _T("bibliography"));
2819 wxFprintf(Contents
, _T("%s</A>\n"), ReferencesNameString
);
2820 wxFprintf(Chapters
, _T("</H2>\n</A>\n"));
2822 SetCurrentOutput(Chapters
);
2825 if (!start
&& (arg_no
== 2))
2832 /* Build up list of keywords associated with topics */
2835 // wxChar *entry = GetArgData();
2837 OutputChunkToString(GetArgChunk(), buf
);
2840 AddKeyWordForTopic(CurrentTopic
, buf
, currentFileName
);
2854 wxChar
*name
= GetArgData();
2856 if (!FindColourHTMLString(name
, buf2
))
2858 wxStrcpy(buf2
, _T("#000000"));
2860 wxSnprintf(buf
, sizeof(buf
), _T("Could not find colour name %s"), name
);
2863 TexOutput(_T("<FONT COLOR=\""));
2865 TexOutput(_T("\">"));
2878 if (arg_no
== 2) TexOutput(_T("</FONT>"));
2882 case ltINSERTATLEVEL
:
2884 // This macro allows you to insert text at a different level
2885 // from the current level, e.g. into the Sections from within a subsubsection.
2888 static int currentLevelNo
= 1;
2889 static FILE* oldLevelFile
= Chapters
;
2896 oldLevelFile
= CurrentOutput1
;
2898 wxChar
*str
= GetArgData();
2899 currentLevelNo
= wxAtoi(str
);
2901 // TODO: cope with article style (no chapters)
2902 switch (currentLevelNo
)
2906 outputFile
= Chapters
;
2911 outputFile
= Sections
;
2916 outputFile
= Subsections
;
2921 outputFile
= Subsubsections
;
2931 CurrentOutput1
= outputFile
;
2947 CurrentOutput1
= oldLevelFile
;
2953 return DefaultOnArgument(macroId
, arg_no
, start
);
2965 tableVerticalLineLeft
= false;
2966 tableVerticalLineRight
= false;
2969 if (InputFile
&& OutputFile
)
2971 // Do some HTML-specific transformations on all the strings,
2973 Text2HTML(GetTopLevelChunk());
2976 if (truncateFilenames
)
2977 wxSnprintf(buf
, sizeof(buf
), _T("%s.htm"), FileRoot
);
2979 wxSnprintf(buf
, sizeof(buf
), _T("%s_contents.html"), FileRoot
);
2980 if (TitlepageName
) delete[] TitlepageName
;
2981 TitlepageName
= copystring(buf
);
2982 Titlepage
= wxFopen(buf
, _T("w"));
2984 if (truncateFilenames
)
2985 wxSnprintf(buf
, sizeof(buf
), _T("%s_fc.htm"), FileRoot
);
2987 wxSnprintf(buf
, sizeof(buf
), _T("%s_fcontents.html"), FileRoot
);
2989 contentsFrameName
= copystring(buf
);
2991 Contents
= wxFopen(TmpContentsName
, _T("w"));
2993 if (htmlFrameContents
)
2995 // FrameContents = wxFopen(TmpFrameContentsName, _T("w"));
2996 FrameContents
= wxFopen(contentsFrameName
, _T("w"));
2997 wxFprintf(FrameContents
, _T("<HTML>\n<UL>\n"));
3000 if (!Titlepage
|| !Contents
)
3002 OnError(_T("Cannot open output file!"));
3005 AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName
), ContentsNameString
);
3007 wxFprintf(Contents
, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString
);
3009 wxFprintf(Contents
, _T("<UL>\n"));
3011 SetCurrentOutput(Titlepage
);
3012 if (htmlWorkshopFiles
) HTMLWorkshopStartContents();
3013 OnInform(_T("Converting..."));
3016 wxFprintf(Contents
, _T("</UL>\n\n"));
3018 // SetCurrentOutput(Titlepage);
3023 // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n"));
3030 wxFprintf(FrameContents
, _T("\n</UL>\n"));
3031 wxFprintf(FrameContents
, _T("</HTML>\n"));
3032 fclose(FrameContents
);
3033 FrameContents
= NULL
;
3038 wxFprintf(Chapters
, _T("\n</FONT></BODY></HTML>\n"));
3044 wxFprintf(Sections
, _T("\n</FONT></BODY></HTML>\n"));
3048 if (Subsections
&& !combineSubSections
)
3050 wxFprintf(Subsections
, _T("\n</FONT></BODY></HTML>\n"));
3051 fclose(Subsections
);
3054 if (Subsubsections
&& !combineSubSections
)
3056 wxFprintf(Subsubsections
, _T("\n</FONT></BODY></HTML>\n"));
3057 fclose(Subsubsections
);
3058 Subsubsections
= NULL
;
3060 if ( SectionContentsFD
)
3062 fclose(SectionContentsFD
);
3063 SectionContentsFD
= NULL
;
3066 // Create a temporary file for the title page header, add some info,
3067 // and concat the titlepage just generated.
3068 // This is necessary in order to put the title of the document
3069 // at the TOP of the file within <HEAD>, even though we only find out
3070 // what it is later on.
3071 FILE *tmpTitle
= wxFopen(_T("title.tmp"), _T("w"));
3076 SetCurrentOutput(tmpTitle
);
3078 TexOutput(_T("\n<TITLE>"));
3079 TraverseChildrenFromChunk(DocumentTitle
);
3080 TexOutput(_T("</TITLE></HEAD>\n"));
3084 SetCurrentOutput(tmpTitle
);
3085 HTMLHeadTo(tmpTitle
);
3087 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString
);
3089 wxFprintf(tmpTitle
, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot
));
3092 // Output frame information
3093 if (htmlFrameContents
)
3095 wxChar firstFileName
[300];
3096 if (truncateFilenames
)
3097 wxSnprintf(firstFileName
, sizeof(firstFileName
), _T("%s1.htm"), FileRoot
);
3099 wxStrcpy(firstFileName
, gs_filenames
[1].c_str());
3101 wxFprintf(tmpTitle
, _T("<FRAMESET COLS=\"30%%,70%%\">\n"));
3103 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName
)));
3104 wxFprintf(tmpTitle
, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName
)));
3105 wxFprintf(tmpTitle
, _T("</FRAMESET>\n"));
3107 wxFprintf(tmpTitle
, _T("<NOFRAMES>\n"));
3110 // Output <BODY...> to temporary title page
3115 FILE *fd
= wxFopen(TitlepageName
, _T("r"));
3121 wxPutc(ch
, tmpTitle
);
3127 wxFprintf(tmpTitle
, _T("\n</FONT></BODY>\n"));
3129 if (htmlFrameContents
)
3131 wxFprintf(tmpTitle
, _T("\n</NOFRAMES>\n"));
3133 wxFprintf(tmpTitle
, _T("\n</HTML>\n"));
3136 if (wxFileExists(TitlepageName
)) wxRemoveFile(TitlepageName
);
3137 if (!wxRenameFile(_T("title.tmp"), TitlepageName
))
3139 wxCopyFile(_T("title.tmp"), TitlepageName
);
3140 wxRemoveFile(_T("title.tmp"));
3144 if (lastFileName
) delete[] lastFileName
;
3145 lastFileName
= NULL
;
3146 if (lastTopic
) delete[] lastTopic
;
3149 if (wxFileExists(ContentsName
)) wxRemoveFile(ContentsName
);
3151 if (!wxRenameFile(TmpContentsName
, ContentsName
))
3153 wxCopyFile(TmpContentsName
, ContentsName
);
3154 wxRemoveFile(TmpContentsName
);
3157 // Generate .htx file if requested
3160 wxChar htmlIndexName
[300];
3161 wxSnprintf(htmlIndexName
, sizeof(htmlIndexName
), _T("%s.htx"), FileRoot
);
3162 GenerateHTMLIndexFile(htmlIndexName
);
3165 // Generate HTML Help Workshop files if requested
3166 if (htmlWorkshopFiles
)
3168 HTMLWorkshopEndContents();
3169 GenerateHTMLWorkshopFiles(FileRoot
);
3179 // Output .htx index file
3180 void GenerateHTMLIndexFile(wxChar
*fname
)
3182 FILE *fd
= wxFopen(fname
, _T("w"));
3186 TopicTable
.BeginFind();
3187 wxHashTable::Node
*node
= TopicTable
.Next();
3190 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3191 const wxChar
*topicName
= node
->GetKeyString();
3192 if (texTopic
->filename
&& texTopic
->keywords
)
3194 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3197 wxChar
*s
= (wxChar
*)node1
->GetData();
3198 wxFprintf(fd
, _T("%s|%s|%s\n"), topicName
, texTopic
->filename
, s
);
3199 node1
= node1
->GetNext();
3202 node
= TopicTable
.Next();
3213 // output .hpp, .hhc and .hhk files:
3216 void GenerateHTMLWorkshopFiles(wxChar
*fname
)
3221 /* Generate project file : */
3223 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhp"), fname
);
3224 f
= wxFopen(buf
, _T("wt"));
3227 _T("Compatibility=1.1\n")
3228 _T("Full-text search=Yes\n")
3229 _T("Contents file=%s.hhc\n")
3230 _T("Compiled file=%s.chm\n")
3231 _T("Default Window=%sHelp\n")
3232 _T("Default topic=%s\n")
3233 _T("Index file=%s.hhk\n")
3235 wxFileNameFromPath(fname
),
3236 wxFileNameFromPath(fname
),
3237 wxFileNameFromPath(fname
),
3238 wxFileNameFromPath(TitlepageName
),
3239 wxFileNameFromPath(fname
)
3242 if (DocumentTitle
) {
3243 SetCurrentOutput(f
);
3244 TraverseChildrenFromChunk(DocumentTitle
);
3246 else wxFprintf(f
, _T("(unknown)"));
3248 wxFprintf(f
, _T("\n\n[WINDOWS]\n")
3249 _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"),
3250 wxFileNameFromPath(fname
),
3251 wxFileNameFromPath(fname
),
3252 wxFileNameFromPath(fname
),
3253 wxFileNameFromPath(TitlepageName
));
3256 wxFprintf(f
, _T("\n\n[FILES]\n"));
3257 wxFprintf(f
, _T("%s\n"), wxFileNameFromPath(TitlepageName
));
3258 for (int i
= 1; i
<= fileId
; i
++) {
3259 if (truncateFilenames
)
3260 wxSnprintf(buf
, sizeof(buf
), _T("%s%d.htm"), wxFileNameFromPath(FileRoot
), i
);
3262 wxStrcpy(buf
, wxFileNameFromPath(gs_filenames
[i
].c_str()));
3263 wxFprintf(f
, _T("%s\n"), buf
);
3267 /* Generate index file : */
3269 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhk"), fname
);
3270 f
= wxFopen(buf
, _T("wt"));
3273 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3278 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3279 _T("<!-- Sitemap 1.0 -->\n")
3280 _T("</HEAD><BODY>\n")
3281 _T("<OBJECT type=\"text/site properties\">\n")
3282 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3286 TopicTable
.BeginFind();
3287 wxHashTable::Node
*node
= TopicTable
.Next();
3290 TexTopic
*texTopic
= (TexTopic
*)node
->GetData();
3291 const wxChar
*topicName
= node
->GetKeyString();
3292 if (texTopic
->filename
&& texTopic
->keywords
)
3294 wxStringListNode
*node1
= texTopic
->keywords
->GetFirst();
3297 wxChar
*s
= (wxChar
*)node1
->GetData();
3299 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3300 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3301 _T(" <param name=\"Name\" value=\"%s\">\n")
3303 texTopic
->filename
, topicName
, s
);
3304 node1
= node1
->GetNext();
3307 node
= TopicTable
.Next();
3310 wxFprintf(f
, _T("</UL>\n"));
3316 static FILE *HTMLWorkshopContents
= NULL
;
3317 static int HTMLWorkshopLastLevel
= 0;
3319 void HTMLWorkshopAddToContents(int level
, wxChar
*s
, wxChar
*file
)
3323 if (level
> HTMLWorkshopLastLevel
)
3324 for (i
= HTMLWorkshopLastLevel
; i
< level
; i
++)
3325 wxFprintf(HTMLWorkshopContents
, _T("<UL>"));
3326 if (level
< HTMLWorkshopLastLevel
)
3327 for (i
= level
; i
< HTMLWorkshopLastLevel
; i
++)
3328 wxFprintf(HTMLWorkshopContents
, _T("</UL>"));
3330 SetCurrentOutput(HTMLWorkshopContents
);
3331 wxFprintf(HTMLWorkshopContents
,
3332 _T(" <LI> <OBJECT type=\"text/sitemap\">\n")
3333 _T(" <param name=\"Local\" value=\"%s#%s\">\n")
3334 _T(" <param name=\"Name\" value=\""),
3336 OutputCurrentSection();
3337 wxFprintf(HTMLWorkshopContents
,
3339 _T(" </OBJECT>\n"));
3340 HTMLWorkshopLastLevel
= level
;
3344 void HTMLWorkshopStartContents()
3347 wxSnprintf(buf
, sizeof(buf
), _T("%s.hhc"), FileRoot
);
3348 HTMLWorkshopContents
= wxFopen(buf
, _T("wt"));
3349 HTMLWorkshopLastLevel
= 0;
3351 wxFprintf(HTMLWorkshopContents
,
3352 _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n")
3354 HTMLHeadTo(HTMLWorkshopContents
);
3355 wxFprintf(HTMLWorkshopContents
,
3357 _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n")
3358 _T("<!-- Sitemap 1.0 -->\n")
3359 _T("</HEAD><BODY>\n")
3360 _T("<OBJECT type=\"text/site properties\">\n")
3361 _T(" <param name=\"ImageType\" value=\"Folder\">\n")
3364 _T("<LI> <OBJECT type=\"text/sitemap\">\n")
3365 _T("<param name=\"Local\" value=\"%s\">\n")
3366 _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"),
3367 wxFileNameFromPath(TitlepageName
)
3373 void HTMLWorkshopEndContents()
3375 for (int i
= HTMLWorkshopLastLevel
; i
>= 0; i
--)
3376 wxFprintf(HTMLWorkshopContents
, _T("</UL>\n"));
3377 fclose(HTMLWorkshopContents
);
3381 bool PrimaryAnchorOfTheFile( wxChar
*file
, wxChar
*label
)
3383 wxString file_label
;
3384 file_label
.Printf( HTML_FILENAME_PATTERN
, FileRoot
, label
);
3385 return file_label
.IsSameAs( file
, false );