]>
Commit | Line | Data |
---|---|---|
9a29912f JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: htmlutil.cpp | |
3 | // Purpose: Converts Latex to HTML | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 7.9.93 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation | |
14 | #endif | |
15 | ||
16 | // For compilers that support precompilation, includes "wx.h". | |
17 | #include "wx/wxprec.h" | |
18 | ||
19 | #ifdef __BORLANDC__ | |
20 | #pragma hdrstop | |
21 | #endif | |
22 | ||
23 | #ifndef WX_PRECOMP | |
9a29912f JS |
24 | #endif |
25 | ||
66828481 VS |
26 | #include "wx/arrstr.h" |
27 | ||
9a29912f JS |
28 | #include "tex2any.h" |
29 | #include "tex2rtf.h" | |
30 | #include "table.h" | |
31 | ||
ea172e69 MB |
32 | #if !WXWIN_COMPATIBILITY_2_4 |
33 | static inline wxChar* copystring(const wxChar* s) | |
34 | { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } | |
35 | #endif | |
3924dd22 GT |
36 | |
37 | extern wxHashTable TexReferences; | |
38 | ||
39 | ||
6c155d33 JS |
40 | extern void DecToHex(int, wxChar *); |
41 | void GenerateHTMLIndexFile(wxChar *fname); | |
14204c7a | 42 | |
6c155d33 JS |
43 | void GenerateHTMLWorkshopFiles(wxChar *fname); |
44 | void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file); | |
14204c7a VS |
45 | void HTMLWorkshopStartContents(); |
46 | void HTMLWorkshopEndContents(); | |
47 | ||
9a29912f JS |
48 | void OutputContentsFrame(void); |
49 | ||
50 | #include "readshg.h" // Segmented hypergraphics parsing | |
51 | ||
6c155d33 JS |
52 | wxChar *ChaptersName = NULL; |
53 | wxChar *SectionsName = NULL; | |
54 | wxChar *SubsectionsName = NULL; | |
55 | wxChar *SubsubsectionsName = NULL; | |
56 | wxChar *TitlepageName = NULL; | |
57 | wxChar *lastFileName = NULL; | |
58 | wxChar *lastTopic = NULL; | |
59 | wxChar *currentFileName = NULL; | |
60 | wxChar *contentsFrameName = NULL; | |
9a29912f JS |
61 | |
62 | static TexChunk *descriptionItemArg = NULL; | |
63 | static TexChunk *helpRefFilename = NULL; | |
64 | static TexChunk *helpRefText = NULL; | |
65 | static int indentLevel = 0; | |
66 | static int citeCount = 1; | |
67 | extern FILE *Contents; | |
68 | FILE *FrameContents = NULL; | |
69 | FILE *Titlepage = NULL; | |
70 | // FILE *FrameTitlepage = NULL; | |
71 | int fileId = 0; | |
72 | bool subsectionStarted = FALSE; | |
73 | ||
74 | // Which column of a row are we in? (Assumes no nested tables, of course) | |
75 | int currentColumn = 0; | |
76 | ||
77 | // Are we in verbatim mode? If so, format differently. | |
78 | static bool inVerbatim = FALSE; | |
79 | ||
80 | // Need to know whether we're in a table or figure for benefit | |
81 | // of listoffigures/listoftables | |
82 | static bool inFigure = FALSE; | |
83 | static bool inTable = FALSE; | |
84 | ||
85 | // This is defined in the Tex2Any library. | |
6c155d33 | 86 | extern wxChar *BigBuffer; |
9a29912f | 87 | |
c103ca4b JS |
88 | // DHS Two-column table dimensions. |
89 | static int TwoColWidthA = -1; | |
90 | static int TwoColWidthB = -1; | |
91 | ||
92 | ||
9a29912f JS |
93 | class HyperReference: public wxObject |
94 | { | |
95 | public: | |
6c155d33 JS |
96 | wxChar *refName; |
97 | wxChar *refFile; | |
98 | HyperReference(wxChar *name, wxChar *file) | |
9a29912f JS |
99 | { |
100 | if (name) refName = copystring(name); | |
101 | if (file) refFile = copystring(file); | |
102 | } | |
103 | }; | |
104 | ||
105 | class TexNextPage: public wxObject | |
106 | { | |
107 | public: | |
6c155d33 JS |
108 | wxChar *label; |
109 | wxChar *filename; | |
110 | TexNextPage(wxChar *theLabel, wxChar *theFile) | |
9a29912f JS |
111 | { |
112 | label = copystring(theLabel); | |
113 | filename = copystring(theFile); | |
114 | } | |
115 | ~TexNextPage(void) | |
116 | { | |
117 | delete[] label; | |
118 | delete[] filename; | |
119 | } | |
120 | }; | |
121 | ||
122 | wxHashTable TexNextPages(wxKEY_STRING); | |
123 | ||
6c155d33 JS |
124 | static wxChar *CurrentChapterName = NULL; |
125 | static wxChar *CurrentChapterFile = NULL; | |
126 | static wxChar *CurrentSectionName = NULL; | |
127 | static wxChar *CurrentSectionFile = NULL; | |
128 | static wxChar *CurrentSubsectionName = NULL; | |
129 | static wxChar *CurrentSubsectionFile = NULL; | |
130 | static wxChar *CurrentSubsubsectionName = NULL; | |
131 | static wxChar *CurrentSubsubsectionFile = NULL; | |
132 | static wxChar *CurrentTopic = NULL; | |
133 | ||
134 | static void SetCurrentTopic(wxChar *s) | |
9a29912f JS |
135 | { |
136 | if (CurrentTopic) delete[] CurrentTopic; | |
137 | CurrentTopic = copystring(s); | |
138 | } | |
139 | ||
6c155d33 | 140 | void SetCurrentChapterName(wxChar *s, wxChar *file) |
9a29912f JS |
141 | { |
142 | if (CurrentChapterName) delete[] CurrentChapterName; | |
143 | CurrentChapterName = copystring(s); | |
144 | if (CurrentChapterFile) delete[] CurrentChapterFile; | |
145 | CurrentChapterFile = copystring(file); | |
146 | ||
147 | currentFileName = CurrentChapterFile; | |
119f7a8c | 148 | |
9a29912f JS |
149 | SetCurrentTopic(s); |
150 | } | |
6c155d33 | 151 | void SetCurrentSectionName(wxChar *s, wxChar *file) |
9a29912f JS |
152 | { |
153 | if (CurrentSectionName) delete[] CurrentSectionName; | |
154 | CurrentSectionName = copystring(s); | |
155 | if (CurrentSectionFile) delete[] CurrentSectionFile; | |
156 | CurrentSectionFile = copystring(file); | |
157 | ||
158 | currentFileName = CurrentSectionFile; | |
159 | SetCurrentTopic(s); | |
160 | } | |
6c155d33 | 161 | void SetCurrentSubsectionName(wxChar *s, wxChar *file) |
9a29912f JS |
162 | { |
163 | if (CurrentSubsectionName) delete[] CurrentSubsectionName; | |
164 | CurrentSubsectionName = copystring(s); | |
165 | if (CurrentSubsectionFile) delete[] CurrentSubsectionFile; | |
166 | CurrentSubsectionFile = copystring(file); | |
167 | currentFileName = CurrentSubsectionFile; | |
168 | SetCurrentTopic(s); | |
169 | } | |
6c155d33 | 170 | void SetCurrentSubsubsectionName(wxChar *s, wxChar *file) |
9a29912f JS |
171 | { |
172 | if (CurrentSubsubsectionName) delete[] CurrentSubsubsectionName; | |
173 | CurrentSubsubsectionName = copystring(s); | |
174 | if (CurrentSubsubsectionFile) delete[] CurrentSubsubsectionFile; | |
175 | CurrentSubsubsectionFile = copystring(file); | |
176 | currentFileName = CurrentSubsubsectionFile; | |
177 | SetCurrentTopic(s); | |
178 | } | |
179 | ||
66828481 VS |
180 | |
181 | // mapping between fileId and filenames if truncateFilenames=false: | |
182 | static wxArrayString gs_filenames; | |
183 | ||
184 | ||
9a29912f JS |
185 | /* |
186 | * Close former filedescriptor and reopen using another filename. | |
187 | * | |
188 | */ | |
189 | ||
66828481 | 190 | void ReopenFile(FILE **fd, wxChar **fileName, const wxChar *label) |
9a29912f JS |
191 | { |
192 | if (*fd) | |
193 | { | |
6c155d33 | 194 | wxFprintf(*fd, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
195 | fclose(*fd); |
196 | } | |
197 | fileId ++; | |
6c155d33 | 198 | wxChar buf[400]; |
9a29912f | 199 | if (truncateFilenames) |
66828481 | 200 | { |
6c155d33 | 201 | wxSprintf(buf, _T("%s%d.htm"), FileRoot, fileId); |
66828481 | 202 | } |
9a29912f | 203 | else |
66828481 | 204 | { |
e6a0295c VS |
205 | if (fileId == 1) |
206 | gs_filenames.Add(wxEmptyString); | |
66828481 | 207 | wxSprintf(buf, _T("%s_%s.html"), FileRoot, label); |
e6a0295c | 208 | gs_filenames.Add(buf); |
66828481 | 209 | } |
9a29912f | 210 | if (*fileName) delete[] *fileName; |
2b5f62a0 | 211 | *fileName = copystring(wxFileNameFromPath(buf)); |
6c155d33 JS |
212 | *fd = wxFopen(buf, _T("w")); |
213 | wxFprintf(*fd, _T("<HTML>\n")); | |
9a29912f JS |
214 | } |
215 | ||
216 | /* | |
217 | * Reopen section contents file, i.e. the index appended to each section | |
218 | * in subsectionCombine mode | |
219 | */ | |
220 | ||
6c155d33 | 221 | static wxChar *SectionContentsFilename = NULL; |
9a29912f JS |
222 | static FILE *SectionContentsFD = NULL; |
223 | ||
224 | void ReopenSectionContentsFile(void) | |
225 | { | |
226 | if ( SectionContentsFD ) | |
227 | { | |
228 | fclose(SectionContentsFD); | |
229 | } | |
230 | if ( SectionContentsFilename ) | |
231 | delete[] SectionContentsFilename; | |
232 | SectionContentsFD = NULL; | |
233 | SectionContentsFilename = NULL; | |
234 | ||
235 | // Create the name from the current section filename | |
236 | if ( CurrentSectionFile ) | |
237 | { | |
6c155d33 JS |
238 | wxChar buf[256]; |
239 | wxStrcpy(buf, CurrentSectionFile); | |
9a29912f | 240 | wxStripExtension(buf); |
6c155d33 | 241 | wxStrcat(buf, _T(".con")); |
9a29912f JS |
242 | SectionContentsFilename = copystring(buf); |
243 | ||
6c155d33 | 244 | SectionContentsFD = wxFopen(SectionContentsFilename, _T("w")); |
9a29912f JS |
245 | } |
246 | } | |
247 | ||
248 | ||
249 | /* | |
250 | * Given a TexChunk with a string value, scans through the string | |
251 | * converting Latex-isms into HTML-isms, such as 2 newlines -> <P>. | |
252 | * | |
253 | */ | |
119f7a8c | 254 | |
9a29912f JS |
255 | void ProcessText2HTML(TexChunk *chunk) |
256 | { | |
257 | bool changed = FALSE; | |
258 | int ptr = 0; | |
259 | int i = 0; | |
260 | char ch = 1; | |
6c155d33 | 261 | int len = wxStrlen(chunk->value); |
9a29912f JS |
262 | while (ch != 0) |
263 | { | |
264 | ch = chunk->value[i]; | |
265 | ||
266 | // 2 newlines means \par | |
267 | if (!inVerbatim && chunk->value[i] == 10 && ((len > i+1 && chunk->value[i+1] == 10) || | |
268 | ((len > i+1 && chunk->value[i+1] == 13) && | |
269 | (len > i+2 && chunk->value[i+2] == 10)))) | |
270 | { | |
6c155d33 | 271 | BigBuffer[ptr] = 0; wxStrcat(BigBuffer, _T("<P>\n\n")); ptr += 5; |
9a29912f JS |
272 | i += 2; |
273 | changed = TRUE; | |
274 | } | |
275 | else if (!inVerbatim && ch == '`' && (len >= i+1 && chunk->value[i+1] == '`')) | |
276 | { | |
277 | BigBuffer[ptr] = '"'; ptr ++; | |
278 | i += 2; | |
279 | changed = TRUE; | |
280 | } | |
281 | else if (!inVerbatim && ch == '`') // Change ` to ' | |
282 | { | |
283 | BigBuffer[ptr] = 39; ptr ++; | |
284 | i += 1; | |
285 | changed = TRUE; | |
286 | } | |
287 | else if (ch == '<') // Change < to < | |
288 | { | |
289 | BigBuffer[ptr] = 0; | |
6c155d33 | 290 | wxStrcat(BigBuffer, _T("<")); |
9a29912f JS |
291 | ptr += 4; |
292 | i += 1; | |
293 | changed = TRUE; | |
294 | } | |
295 | else if (ch == '>') // Change > to > | |
296 | { | |
297 | BigBuffer[ptr] = 0; | |
6c155d33 | 298 | wxStrcat(BigBuffer, _T(">")); |
9a29912f JS |
299 | ptr += 4; |
300 | i += 1; | |
301 | changed = TRUE; | |
302 | } | |
303 | else | |
304 | { | |
305 | BigBuffer[ptr] = ch; | |
306 | i ++; | |
307 | ptr ++; | |
308 | } | |
309 | } | |
310 | BigBuffer[ptr] = 0; | |
311 | ||
312 | if (changed) | |
313 | { | |
314 | delete chunk->value; | |
315 | chunk->value = copystring(BigBuffer); | |
316 | } | |
317 | } | |
318 | ||
319 | /* | |
320 | * Scan through all chunks starting from the given one, | |
321 | * calling ProcessText2HTML to convert Latex-isms to RTF-isms. | |
322 | * This should be called after Tex2Any has parsed the file, | |
323 | * and before TraverseDocument is called. | |
324 | * | |
325 | */ | |
119f7a8c | 326 | |
9a29912f JS |
327 | void Text2HTML(TexChunk *chunk) |
328 | { | |
329 | Tex2RTFYield(); | |
330 | if (stopRunning) return; | |
331 | ||
332 | switch (chunk->type) | |
333 | { | |
334 | case CHUNK_TYPE_MACRO: | |
335 | { | |
336 | TexMacroDef *def = chunk->def; | |
337 | ||
338 | if (def && def->ignore) | |
339 | return; | |
340 | ||
341 | if (def && (def->macroId == ltVERBATIM || def->macroId == ltVERB || def->macroId == ltSPECIAL)) | |
342 | inVerbatim = TRUE; | |
343 | ||
ddc4f3b5 | 344 | wxNode *node = chunk->children.GetFirst(); |
9a29912f JS |
345 | while (node) |
346 | { | |
ddc4f3b5 | 347 | TexChunk *child_chunk = (TexChunk *)node->GetData(); |
9a29912f | 348 | Text2HTML(child_chunk); |
ddc4f3b5 | 349 | node = node->GetNext(); |
9a29912f JS |
350 | } |
351 | ||
352 | if (def && (def->macroId == ltVERBATIM || def->macroId == ltVERB || def->macroId == ltSPECIAL)) | |
353 | inVerbatim = FALSE; | |
354 | ||
355 | break; | |
356 | } | |
357 | case CHUNK_TYPE_ARG: | |
358 | { | |
ddc4f3b5 | 359 | wxNode *node = chunk->children.GetFirst(); |
9a29912f JS |
360 | while (node) |
361 | { | |
ddc4f3b5 | 362 | TexChunk *child_chunk = (TexChunk *)node->GetData(); |
9a29912f | 363 | Text2HTML(child_chunk); |
ddc4f3b5 | 364 | node = node->GetNext(); |
9a29912f JS |
365 | } |
366 | ||
367 | break; | |
368 | } | |
369 | case CHUNK_TYPE_STRING: | |
370 | { | |
371 | if (chunk->value) | |
372 | ProcessText2HTML(chunk); | |
373 | break; | |
374 | } | |
375 | } | |
376 | } | |
377 | ||
378 | /* | |
379 | * Add appropriate browse buttons to this page. | |
380 | * | |
381 | */ | |
382 | ||
6c155d33 JS |
383 | void AddBrowseButtons(wxChar *upLabel, wxChar *upFilename, |
384 | wxChar *previousLabel, wxChar *previousFilename, | |
385 | wxChar *thisLabel, wxChar *thisFilename) | |
9a29912f | 386 | { |
6c155d33 JS |
387 | wxChar contentsReferenceBuf[80]; |
388 | wxChar upReferenceBuf[80]; | |
389 | wxChar backReferenceBuf[80]; | |
390 | wxChar forwardReferenceBuf[80]; | |
9a29912f JS |
391 | if (htmlBrowseButtons == HTML_BUTTONS_NONE) |
392 | return; | |
393 | ||
6c155d33 | 394 | wxChar *contentsReference; // no need to initialize because always assigned below |
9a29912f JS |
395 | if (htmlBrowseButtons == HTML_BUTTONS_TEXT) |
396 | contentsReference = ContentsNameString; | |
397 | else | |
398 | { | |
399 | // contentsReference = "<img align=center src=\"contents.gif\" BORDER=0 ALT=\"Contents\">"; | |
400 | contentsReference = contentsReferenceBuf; | |
6c155d33 | 401 | wxSprintf(contentsReference, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Contents\">"), ConvertCase(_T("contents.gif"))); |
9a29912f | 402 | } |
119f7a8c | 403 | |
6c155d33 | 404 | wxChar *upReference; // no need to initialize because always assigned below |
9a29912f JS |
405 | if (htmlBrowseButtons == HTML_BUTTONS_TEXT) |
406 | upReference = UpNameString; | |
407 | else | |
408 | { | |
409 | // upReference = "<img align=center src=\"up.gif\" ALT=\"Up\">"; | |
410 | upReference = upReferenceBuf; | |
6c155d33 | 411 | wxSprintf(upReference, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Up\">"), ConvertCase(_T("up.gif"))); |
9a29912f | 412 | } |
119f7a8c | 413 | |
6c155d33 | 414 | wxChar *backReference; // no need to initialize because always assigned below |
9a29912f | 415 | if (htmlBrowseButtons == HTML_BUTTONS_TEXT) |
6c155d33 | 416 | backReference = _T("<<"); |
9a29912f JS |
417 | else |
418 | { | |
419 | // backReference = "<img align=center src=\"back.gif\" ALT=\"Previous\">"; | |
420 | backReference = backReferenceBuf; | |
6c155d33 | 421 | wxSprintf(backReference, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Previous\">"), ConvertCase(_T("back.gif"))); |
9a29912f | 422 | } |
119f7a8c | 423 | |
6c155d33 | 424 | wxChar *forwardReference; // no need to initialize because always assigned below |
9a29912f | 425 | if (htmlBrowseButtons == HTML_BUTTONS_TEXT) |
6c155d33 | 426 | forwardReference = _T(">>"); |
9a29912f JS |
427 | else |
428 | { | |
429 | // forwardReference = "<img align=center src=\"forward.gif\" ALT=\"Next\">"; | |
430 | forwardReference = forwardReferenceBuf; | |
6c155d33 | 431 | wxSprintf(forwardReference, _T("<img align=center src=\"%s\" BORDER=0 ALT=\"Next\">"), ConvertCase(_T("forward.gif"))); |
9a29912f | 432 | } |
119f7a8c | 433 | |
6c155d33 | 434 | TexOutput(_T("<CENTER>")); |
119f7a8c | 435 | |
6c155d33 | 436 | wxChar buf[200]; |
9a29912f JS |
437 | |
438 | /* | |
439 | * Contents button | |
440 | * | |
441 | */ | |
442 | ||
443 | if (truncateFilenames) | |
444 | { | |
6c155d33 JS |
445 | wxChar buf1[80]; |
446 | wxStrcpy(buf1, ConvertCase(wxFileNameFromPath(FileRoot))); | |
447 | wxSprintf(buf, _T("\n<A HREF=\"%s.%s\">%s</A> "), buf1, ConvertCase(_T("htm")), contentsReference); | |
9a29912f JS |
448 | } |
449 | else | |
450 | { | |
6c155d33 JS |
451 | wxChar buf1[80]; |
452 | wxStrcpy(buf1, ConvertCase(wxFileNameFromPath(FileRoot))); | |
453 | wxSprintf(buf, _T("\n<A HREF=\"%s%s\">%s</A> "), buf1, ConvertCase(_T("_contents.html")), contentsReference); | |
9a29912f | 454 | } |
6c155d33 | 455 | // TexOutput(_T("<NOFRAMES>")); |
9a29912f | 456 | TexOutput(buf); |
6c155d33 | 457 | // TexOutput(_T("</NOFRAMES>")); |
9a29912f JS |
458 | |
459 | /* | |
460 | * Up button | |
461 | * | |
462 | */ | |
463 | ||
464 | if (upLabel && upFilename) | |
465 | { | |
6c155d33 JS |
466 | if (wxStrlen(upLabel) > 0) |
467 | wxSprintf(buf, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(upFilename), upLabel, upReference); | |
9a29912f | 468 | else |
6c155d33 JS |
469 | wxSprintf(buf, _T("<A HREF=\"%s\">%s</A> "), ConvertCase(upFilename), upReference); |
470 | if (wxStrcmp(upLabel, _T("contents")) == 0) | |
9a29912f | 471 | { |
6c155d33 | 472 | // TexOutput(_T("<NOFRAMES>")); |
9a29912f | 473 | TexOutput(buf); |
6c155d33 | 474 | // TexOutput(_T("</NOFRAMES>")); |
9a29912f JS |
475 | } |
476 | else | |
477 | TexOutput(buf); | |
478 | } | |
479 | ||
480 | /* | |
481 | * << button | |
482 | * | |
483 | */ | |
484 | ||
485 | if (previousLabel && previousFilename) | |
486 | { | |
6c155d33 JS |
487 | wxSprintf(buf, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(previousFilename), previousLabel, backReference); |
488 | if (wxStrcmp(previousLabel, _T("contents")) == 0) | |
9a29912f | 489 | { |
6c155d33 | 490 | // TexOutput(_T("<NOFRAMES>")); |
9a29912f | 491 | TexOutput(buf); |
6c155d33 | 492 | // TexOutput(_T("</NOFRAMES>")); |
9a29912f JS |
493 | } |
494 | else | |
495 | TexOutput(buf); | |
496 | } | |
497 | else | |
498 | { | |
499 | // A placeholder so the buttons don't keep moving position | |
6c155d33 | 500 | wxSprintf(buf, _T("%s "), backReference); |
9a29912f JS |
501 | TexOutput(buf); |
502 | } | |
503 | ||
6c155d33 JS |
504 | wxChar *nextLabel = NULL; |
505 | wxChar *nextFilename = NULL; | |
9a29912f JS |
506 | |
507 | // Get the next page, and record the previous page's 'next' page | |
508 | // (i.e. this page) | |
509 | TexNextPage *nextPage = (TexNextPage *)TexNextPages.Get(thisLabel); | |
510 | if (nextPage) | |
511 | { | |
512 | nextLabel = nextPage->label; | |
513 | nextFilename = nextPage->filename; | |
514 | } | |
515 | if (previousLabel && previousFilename) | |
516 | { | |
517 | TexNextPage *oldNextPage = (TexNextPage *)TexNextPages.Get(previousLabel); | |
518 | if (oldNextPage) | |
519 | { | |
520 | delete oldNextPage; | |
521 | TexNextPages.Delete(previousLabel); | |
522 | } | |
523 | TexNextPage *newNextPage = new TexNextPage(thisLabel, thisFilename); | |
524 | TexNextPages.Put(previousLabel, newNextPage); | |
525 | } | |
526 | ||
527 | /* | |
528 | * >> button | |
529 | * | |
530 | */ | |
531 | ||
532 | if (nextLabel && nextFilename) | |
533 | { | |
6c155d33 | 534 | wxSprintf(buf, _T("<A HREF=\"%s#%s\">%s</A> "), ConvertCase(nextFilename), nextLabel, forwardReference); |
9a29912f JS |
535 | TexOutput(buf); |
536 | } | |
537 | else | |
538 | { | |
539 | // A placeholder so the buttons don't keep moving position | |
6c155d33 | 540 | wxSprintf(buf, _T("%s "), forwardReference); |
9a29912f JS |
541 | TexOutput(buf); |
542 | } | |
543 | ||
544 | /* | |
545 | * Horizontal rule to finish it off nicely. | |
546 | * | |
547 | */ | |
6c155d33 JS |
548 | TexOutput(_T("</CENTER>")); |
549 | TexOutput(_T("<HR>\n")); | |
9a29912f JS |
550 | |
551 | // Update last topic/filename | |
552 | if (lastFileName) | |
553 | delete[] lastFileName; | |
554 | lastFileName = copystring(thisFilename); | |
555 | if (lastTopic) | |
556 | delete[] lastTopic; | |
557 | lastTopic = copystring(thisLabel); | |
558 | } | |
559 | ||
560 | // A colour string is either 3 numbers separated by semicolons (RGB), | |
561 | // or a reference to a GIF. Return the filename or a hex string like #934CE8 | |
6c155d33 | 562 | wxChar *ParseColourString(wxChar *bkStr, bool *isPicture) |
9a29912f | 563 | { |
6c155d33 JS |
564 | static wxChar resStr[300]; |
565 | wxStrcpy(resStr, bkStr); | |
566 | wxStringTokenizer tok(resStr, _T(";"), wxTOKEN_STRTOK); | |
567 | if (tok.HasMoreTokens()) | |
9a29912f | 568 | { |
6c155d33 JS |
569 | wxString token1 = tok.GetNextToken(); |
570 | if (!tok.HasMoreTokens()) | |
9a29912f JS |
571 | { |
572 | *isPicture = TRUE; | |
573 | return resStr; | |
574 | } | |
575 | else | |
576 | { | |
6c155d33 | 577 | wxString token2 = tok.GetNextToken(); |
9a29912f | 578 | *isPicture = FALSE; |
6c155d33 | 579 | if (tok.HasMoreTokens()) |
9a29912f | 580 | { |
6c155d33 JS |
581 | wxString token3 = tok.GetNextToken(); |
582 | ||
9a29912f | 583 | // Now convert 3 strings into decimal numbers, and then hex numbers. |
6c155d33 JS |
584 | int red = wxAtoi(token1.c_str()); |
585 | int green = wxAtoi(token2.c_str()); | |
586 | int blue = wxAtoi(token3.c_str()); | |
119f7a8c | 587 | |
6c155d33 | 588 | wxStrcpy(resStr, _T("#")); |
119f7a8c | 589 | |
6c155d33 | 590 | wxChar buf[3]; |
9a29912f | 591 | DecToHex(red, buf); |
6c155d33 | 592 | wxStrcat(resStr, buf); |
9a29912f | 593 | DecToHex(green, buf); |
6c155d33 | 594 | wxStrcat(resStr, buf); |
9a29912f | 595 | DecToHex(blue, buf); |
6c155d33 | 596 | wxStrcat(resStr, buf); |
9a29912f JS |
597 | return resStr; |
598 | } | |
599 | else return NULL; | |
600 | } | |
601 | } | |
602 | else return NULL; | |
603 | } | |
604 | ||
d7d17624 JS |
605 | void OutputFont(void) |
606 | { | |
2b5f62a0 VZ |
607 | // Only output <font face> if explicitly requested by htmlFaceName= directive in |
608 | // tex2rtf.ini. Otherwise do NOT set the font because we want to use browser's | |
609 | // default font: | |
d7d17624 | 610 | if (htmlFaceName) |
2b5f62a0 VZ |
611 | { |
612 | // Output <FONT FACE=...> | |
6c155d33 | 613 | TexOutput(_T("<FONT FACE=\"")); |
2b5f62a0 | 614 | TexOutput(htmlFaceName); |
6c155d33 | 615 | TexOutput(_T("\">\n")); |
2b5f62a0 | 616 | } |
d7d17624 JS |
617 | } |
618 | ||
9a29912f JS |
619 | // Output start of <BODY> block |
620 | void OutputBodyStart(void) | |
621 | { | |
6c155d33 | 622 | TexOutput(_T("\n<BODY")); |
9a29912f JS |
623 | if (backgroundImageString) |
624 | { | |
625 | bool isPicture = FALSE; | |
6c155d33 | 626 | wxChar *s = ParseColourString(backgroundImageString, &isPicture); |
9a29912f JS |
627 | if (s) |
628 | { | |
6c155d33 JS |
629 | TexOutput(_T(" BACKGROUND=\"")); |
630 | TexOutput(s); | |
631 | TexOutput(_T("\"")); | |
9a29912f JS |
632 | } |
633 | } | |
634 | if (backgroundColourString) | |
635 | { | |
636 | bool isPicture = FALSE; | |
6c155d33 | 637 | wxChar *s = ParseColourString(backgroundColourString, &isPicture); |
9a29912f JS |
638 | if (s) |
639 | { | |
6c155d33 JS |
640 | TexOutput(_T(" BGCOLOR=")); |
641 | TexOutput(s); | |
9a29912f JS |
642 | } |
643 | } | |
119f7a8c | 644 | |
9a29912f JS |
645 | // Set foreground text colour, if one is specified |
646 | if (textColourString) | |
647 | { | |
648 | bool isPicture = FALSE; | |
6c155d33 | 649 | wxChar *s = ParseColourString(textColourString, &isPicture); |
9a29912f JS |
650 | if (s) |
651 | { | |
6c155d33 | 652 | TexOutput(_T(" TEXT=")); TexOutput(s); |
9a29912f JS |
653 | } |
654 | } | |
655 | // Set link text colour, if one is specified | |
656 | if (linkColourString) | |
657 | { | |
658 | bool isPicture = FALSE; | |
6c155d33 | 659 | wxChar *s = ParseColourString(linkColourString, &isPicture); |
9a29912f JS |
660 | if (s) |
661 | { | |
6c155d33 | 662 | TexOutput(_T(" LINK=")); TexOutput(s); |
9a29912f JS |
663 | } |
664 | } | |
665 | // Set followed link text colour, if one is specified | |
666 | if (followedLinkColourString) | |
667 | { | |
668 | bool isPicture = FALSE; | |
6c155d33 | 669 | wxChar *s = ParseColourString(followedLinkColourString, &isPicture); |
9a29912f JS |
670 | if (s) |
671 | { | |
6c155d33 | 672 | TexOutput(_T(" VLINK=")); TexOutput(s); |
9a29912f JS |
673 | } |
674 | } | |
6c155d33 | 675 | TexOutput(_T(">\n")); |
d7d17624 JS |
676 | |
677 | OutputFont(); | |
9a29912f JS |
678 | } |
679 | ||
6d8b260c VS |
680 | void HTMLHead() |
681 | { | |
6c155d33 | 682 | TexOutput(_T("<head>")); |
6d8b260c | 683 | if (htmlStylesheet) { |
6c155d33 | 684 | TexOutput(_T("<link rel=stylesheet type=\"text/css\" href=\"")); |
6d8b260c | 685 | TexOutput(htmlStylesheet); |
6c155d33 | 686 | TexOutput(_T("\">")); |
6d8b260c VS |
687 | } |
688 | }; | |
689 | ||
690 | void HTMLHeadTo(FILE* f) | |
691 | { | |
692 | if (htmlStylesheet) | |
6c155d33 | 693 | wxFprintf(f,_T("<head><link rel=stylesheet type=\"text/css\" href=\"%s\">"),htmlStylesheet); |
6d8b260c | 694 | else |
6c155d33 | 695 | wxFprintf(f,_T("<head>")); |
6d8b260c VS |
696 | } |
697 | ||
9a29912f JS |
698 | // Called on start/end of macro examination |
699 | void HTMLOnMacro(int macroId, int no_args, bool start) | |
700 | { | |
701 | switch (macroId) | |
702 | { | |
703 | case ltCHAPTER: | |
704 | case ltCHAPTERSTAR: | |
705 | case ltCHAPTERHEADING: | |
706 | { | |
707 | if (!start) | |
708 | { | |
709 | sectionNo = 0; | |
710 | figureNo = 0; | |
711 | subsectionNo = 0; | |
712 | subsubsectionNo = 0; | |
713 | if (macroId != ltCHAPTERSTAR) | |
714 | chapterNo ++; | |
715 | ||
716 | SetCurrentOutput(NULL); | |
717 | startedSections = TRUE; | |
718 | ||
6c155d33 | 719 | wxChar *topicName = FindTopicName(GetNextChunk()); |
66828481 | 720 | ReopenFile(&Chapters, &ChaptersName, topicName); |
9a29912f JS |
721 | AddTexRef(topicName, ChaptersName, ChapterNameString); |
722 | ||
723 | SetCurrentChapterName(topicName, ChaptersName); | |
14204c7a | 724 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(0, topicName, ChaptersName); |
9a29912f JS |
725 | |
726 | SetCurrentOutput(Chapters); | |
727 | ||
6d8b260c | 728 | HTMLHead(); |
6c155d33 | 729 | TexOutput(_T("<title>")); |
9a29912f | 730 | OutputCurrentSection(); // Repeat section header |
6c155d33 | 731 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
732 | OutputBodyStart(); |
733 | ||
6c155d33 | 734 | wxChar titleBuf[200]; |
9a29912f | 735 | if (truncateFilenames) |
6c155d33 | 736 | wxSprintf(titleBuf, _T("%s.htm"), wxFileNameFromPath(FileRoot)); |
9a29912f | 737 | else |
6c155d33 | 738 | wxSprintf(titleBuf, _T("%s_contents.html"), wxFileNameFromPath(FileRoot)); |
9a29912f | 739 | |
6c155d33 | 740 | wxFprintf(Chapters, _T("<A NAME=\"%s\"></A>"), topicName); |
119f7a8c | 741 | |
6c155d33 | 742 | AddBrowseButtons(_T(""), titleBuf, // Up |
9a29912f JS |
743 | lastTopic, lastFileName, // Last topic |
744 | topicName, ChaptersName); // This topic | |
745 | ||
6c155d33 | 746 | wxFprintf(Contents, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName), topicName); |
9a29912f JS |
747 | |
748 | if (htmlFrameContents && FrameContents) | |
749 | { | |
750 | SetCurrentOutput(FrameContents); | |
6c155d33 | 751 | wxFprintf(FrameContents, _T("\n<LI><A HREF=\"%s#%s\" TARGET=\"mainwindow\">"), ConvertCase(ChaptersName), topicName); |
9a29912f | 752 | OutputCurrentSection(); |
6c155d33 | 753 | wxFprintf(FrameContents, _T("</A>\n")); |
9a29912f JS |
754 | } |
755 | ||
756 | SetCurrentOutputs(Contents, Chapters); | |
6c155d33 | 757 | wxFprintf(Chapters, _T("\n<H2>")); |
9a29912f | 758 | OutputCurrentSection(); |
6c155d33 JS |
759 | wxFprintf(Contents, _T("</A>\n")); |
760 | wxFprintf(Chapters, _T("</H2>\n")); | |
9a29912f JS |
761 | |
762 | SetCurrentOutput(Chapters); | |
763 | ||
764 | // Add this section title to the list of keywords | |
765 | if (htmlIndex) | |
766 | { | |
aed3314d JS |
767 | OutputCurrentSectionToString(wxTex2RTFBuffer); |
768 | AddKeyWordForTopic(topicName, wxTex2RTFBuffer, ConvertCase(currentFileName)); | |
9a29912f JS |
769 | } |
770 | } | |
771 | break; | |
772 | } | |
773 | case ltSECTION: | |
774 | case ltSECTIONSTAR: | |
775 | case ltSECTIONHEADING: | |
776 | case ltGLOSS: | |
777 | { | |
778 | if (!start) | |
779 | { | |
780 | subsectionNo = 0; | |
781 | subsubsectionNo = 0; | |
782 | subsectionStarted = FALSE; | |
783 | ||
784 | if (macroId != ltSECTIONSTAR) | |
785 | sectionNo ++; | |
119f7a8c | 786 | |
9a29912f JS |
787 | SetCurrentOutput(NULL); |
788 | startedSections = TRUE; | |
789 | ||
6c155d33 | 790 | wxChar *topicName = FindTopicName(GetNextChunk()); |
66828481 | 791 | ReopenFile(&Sections, &SectionsName, topicName); |
9a29912f JS |
792 | AddTexRef(topicName, SectionsName, SectionNameString); |
793 | ||
794 | SetCurrentSectionName(topicName, SectionsName); | |
14204c7a | 795 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(1, topicName, SectionsName); |
9a29912f JS |
796 | |
797 | SetCurrentOutput(Sections); | |
6d8b260c | 798 | HTMLHead(); |
6c155d33 | 799 | TexOutput(_T("<title>")); |
9a29912f | 800 | OutputCurrentSection(); |
6c155d33 | 801 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
802 | OutputBodyStart(); |
803 | ||
6c155d33 | 804 | wxFprintf(Sections, _T("<A NAME=\"%s\"></A>"), topicName); |
9a29912f JS |
805 | AddBrowseButtons(CurrentChapterName, CurrentChapterFile, // Up |
806 | lastTopic, lastFileName, // Last topic | |
807 | topicName, SectionsName); // This topic | |
808 | ||
809 | FILE *jumpFrom = ((DocumentStyle == LATEX_ARTICLE) ? Contents : Chapters); | |
810 | ||
811 | SetCurrentOutputs(jumpFrom, Sections); | |
812 | if (DocumentStyle == LATEX_ARTICLE) | |
6c155d33 | 813 | wxFprintf(jumpFrom, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(SectionsName), topicName); |
9a29912f | 814 | else |
6c155d33 | 815 | wxFprintf(jumpFrom, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SectionsName), topicName); |
9a29912f | 816 | |
6c155d33 | 817 | wxFprintf(Sections, _T("\n<H2>")); |
9a29912f JS |
818 | OutputCurrentSection(); |
819 | ||
820 | if (DocumentStyle == LATEX_ARTICLE) | |
6c155d33 | 821 | wxFprintf(jumpFrom, _T("</A>\n")); |
9a29912f | 822 | else |
6c155d33 JS |
823 | wxFprintf(jumpFrom, _T("</B></A><BR>\n")); |
824 | wxFprintf(Sections, _T("</H2>\n")); | |
9a29912f JS |
825 | |
826 | SetCurrentOutput(Sections); | |
827 | // Add this section title to the list of keywords | |
828 | if (htmlIndex) | |
829 | { | |
aed3314d JS |
830 | OutputCurrentSectionToString(wxTex2RTFBuffer); |
831 | AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); | |
9a29912f JS |
832 | } |
833 | } | |
834 | break; | |
835 | } | |
836 | case ltSUBSECTION: | |
837 | case ltSUBSECTIONSTAR: | |
838 | case ltMEMBERSECTION: | |
839 | case ltFUNCTIONSECTION: | |
840 | { | |
841 | if (!start) | |
842 | { | |
843 | if (!Sections) | |
844 | { | |
6c155d33 | 845 | OnError(_T("You cannot have a subsection before a section!")); |
9a29912f JS |
846 | } |
847 | else | |
848 | { | |
849 | subsubsectionNo = 0; | |
850 | ||
851 | if (macroId != ltSUBSECTIONSTAR) | |
852 | subsectionNo ++; | |
853 | ||
854 | if ( combineSubSections && !subsectionStarted ) | |
855 | { | |
856 | // Read old .con file in at this point | |
6c155d33 JS |
857 | wxChar buf[256]; |
858 | wxStrcpy(buf, CurrentSectionFile); | |
9a29912f | 859 | wxStripExtension(buf); |
6c155d33 JS |
860 | wxStrcat(buf, _T(".con")); |
861 | FILE *fd = wxFopen(buf, _T("r")); | |
9a29912f JS |
862 | if ( fd ) |
863 | { | |
864 | int ch = getc(fd); | |
865 | while (ch != EOF) | |
866 | { | |
867 | putc(ch, Sections); | |
868 | ch = getc(fd); | |
869 | } | |
870 | fclose(fd); | |
871 | } | |
6c155d33 | 872 | wxFprintf(Sections, _T("<P>\n")); |
9a29912f JS |
873 | |
874 | // Close old file, create a new file for the sub(sub)section contents entries | |
875 | ReopenSectionContentsFile(); | |
876 | } | |
877 | ||
878 | startedSections = TRUE; | |
879 | subsectionStarted = TRUE; | |
880 | ||
6c155d33 | 881 | wxChar *topicName = FindTopicName(GetNextChunk()); |
9a29912f JS |
882 | |
883 | if ( !combineSubSections ) | |
884 | { | |
885 | SetCurrentOutput(NULL); | |
66828481 | 886 | ReopenFile(&Subsections, &SubsectionsName, topicName); |
9a29912f JS |
887 | AddTexRef(topicName, SubsectionsName, SubsectionNameString); |
888 | SetCurrentSubsectionName(topicName, SubsectionsName); | |
14204c7a | 889 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SubsectionsName); |
9a29912f JS |
890 | SetCurrentOutput(Subsections); |
891 | ||
6d8b260c | 892 | HTMLHead(); |
6c155d33 | 893 | TexOutput(_T("<title>")); |
9a29912f | 894 | OutputCurrentSection(); |
6c155d33 | 895 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
896 | OutputBodyStart(); |
897 | ||
6c155d33 | 898 | wxFprintf(Subsections, _T("<A NAME=\"%s\"></A>"), topicName); |
9a29912f JS |
899 | AddBrowseButtons(CurrentSectionName, CurrentSectionFile, // Up |
900 | lastTopic, lastFileName, // Last topic | |
901 | topicName, SubsectionsName); // This topic | |
902 | ||
903 | SetCurrentOutputs(Sections, Subsections); | |
6c155d33 | 904 | wxFprintf(Sections, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName), topicName); |
9a29912f | 905 | |
6c155d33 | 906 | wxFprintf(Subsections, _T("\n<H3>")); |
9a29912f | 907 | OutputCurrentSection(); |
6c155d33 JS |
908 | wxFprintf(Sections, _T("</B></A><BR>\n")); |
909 | wxFprintf(Subsections, _T("</H3>\n")); | |
9a29912f JS |
910 | |
911 | SetCurrentOutput(Subsections); | |
912 | } | |
913 | else | |
914 | { | |
915 | AddTexRef(topicName, SectionsName, SubsectionNameString); | |
916 | SetCurrentSubsectionName(topicName, SectionsName); | |
14204c7a | 917 | |
9a29912f | 918 | // if ( subsectionNo != 0 ) |
6c155d33 | 919 | wxFprintf(Sections, _T("\n<HR>\n")); |
9a29912f JS |
920 | |
921 | // We're putting everything into the section file | |
6c155d33 JS |
922 | wxFprintf(Sections, _T("<A NAME=\"%s\"></A>"), topicName); |
923 | wxFprintf(Sections, _T("\n<H3>")); | |
9a29912f | 924 | OutputCurrentSection(); |
6c155d33 | 925 | wxFprintf(Sections, _T("</H3>\n")); |
9a29912f JS |
926 | |
927 | SetCurrentOutput(SectionContentsFD); | |
6c155d33 | 928 | wxFprintf(SectionContentsFD, _T("<A HREF=\"#%s\">"), topicName); |
9a29912f | 929 | OutputCurrentSection(); |
6c155d33 | 930 | TexOutput(_T("</A><BR>\n")); |
9a29912f | 931 | |
14204c7a | 932 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); |
9a29912f JS |
933 | SetCurrentOutput(Sections); |
934 | } | |
935 | // Add this section title to the list of keywords | |
936 | if (htmlIndex) | |
937 | { | |
aed3314d JS |
938 | OutputCurrentSectionToString(wxTex2RTFBuffer); |
939 | AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); | |
9a29912f JS |
940 | } |
941 | ||
942 | } | |
943 | } | |
944 | break; | |
945 | } | |
946 | case ltSUBSUBSECTION: | |
947 | case ltSUBSUBSECTIONSTAR: | |
948 | { | |
949 | if (!start) | |
950 | { | |
951 | if (!Subsections && !combineSubSections) | |
952 | { | |
6c155d33 | 953 | OnError(_T("You cannot have a subsubsection before a subsection!")); |
9a29912f JS |
954 | } |
955 | else | |
956 | { | |
957 | if (macroId != ltSUBSUBSECTIONSTAR) | |
958 | subsubsectionNo ++; | |
959 | ||
960 | startedSections = TRUE; | |
961 | ||
6c155d33 | 962 | wxChar *topicName = FindTopicName(GetNextChunk()); |
9a29912f JS |
963 | |
964 | if ( !combineSubSections ) | |
965 | { | |
966 | SetCurrentOutput(NULL); | |
66828481 | 967 | ReopenFile(&Subsubsections, &SubsubsectionsName, topicName); |
9a29912f JS |
968 | AddTexRef(topicName, SubsubsectionsName, SubsubsectionNameString); |
969 | SetCurrentSubsubsectionName(topicName, SubsubsectionsName); | |
14204c7a | 970 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(3, topicName, SubsubsectionsName); |
9a29912f JS |
971 | |
972 | SetCurrentOutput(Subsubsections); | |
6d8b260c | 973 | HTMLHead(); |
6c155d33 | 974 | TexOutput(_T("<title>")); |
9a29912f | 975 | OutputCurrentSection(); |
6c155d33 | 976 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
977 | OutputBodyStart(); |
978 | ||
6c155d33 | 979 | wxFprintf(Subsubsections, _T("<A NAME=\"%s\"></A>"), topicName); |
9a29912f JS |
980 | |
981 | AddBrowseButtons(CurrentSubsectionName, CurrentSubsectionFile, // Up | |
982 | lastTopic, lastFileName, // Last topic | |
983 | topicName, SubsubsectionsName); // This topic | |
984 | ||
985 | SetCurrentOutputs(Subsections, Subsubsections); | |
6c155d33 | 986 | wxFprintf(Subsections, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName), topicName); |
9a29912f | 987 | |
6c155d33 | 988 | wxFprintf(Subsubsections, _T("\n<H3>")); |
9a29912f | 989 | OutputCurrentSection(); |
6c155d33 JS |
990 | wxFprintf(Subsections, _T("</B></A><BR>\n")); |
991 | wxFprintf(Subsubsections, _T("</H3>\n")); | |
9a29912f JS |
992 | } |
993 | else | |
994 | { | |
995 | AddTexRef(topicName, SectionsName, SubsubsectionNameString); | |
996 | SetCurrentSubsectionName(topicName, SectionsName); | |
6c155d33 | 997 | wxFprintf(Sections, _T("\n<HR>\n")); |
9a29912f JS |
998 | |
999 | // We're putting everything into the section file | |
6c155d33 JS |
1000 | wxFprintf(Sections, _T("<A NAME=\"%s\"></A>"), topicName); |
1001 | wxFprintf(Sections, _T("\n<H3>")); | |
9a29912f | 1002 | OutputCurrentSection(); |
6c155d33 | 1003 | wxFprintf(Sections, _T("</H3>\n")); |
9a29912f JS |
1004 | /* TODO: where do we put subsubsection contents entry - indented, with subsection entries? |
1005 | SetCurrentOutput(SectionContentsFD); | |
6c155d33 | 1006 | wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName); |
9a29912f | 1007 | OutputCurrentSection(); |
6c155d33 | 1008 | TexOutput(_T("</A><BR>")); |
9a29912f | 1009 | */ |
119f7a8c | 1010 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); |
9a29912f JS |
1011 | SetCurrentOutput(Sections); |
1012 | } | |
1013 | ||
1014 | // Add this section title to the list of keywords | |
1015 | if (htmlIndex) | |
1016 | { | |
aed3314d JS |
1017 | OutputCurrentSectionToString(wxTex2RTFBuffer); |
1018 | AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); | |
9a29912f JS |
1019 | } |
1020 | } | |
1021 | } | |
1022 | break; | |
1023 | } | |
1024 | case ltFUNC: | |
1025 | case ltPFUNC: | |
1026 | { | |
1027 | if ( !combineSubSections ) | |
1028 | SetCurrentOutput(Subsections); | |
1029 | else | |
1030 | SetCurrentOutput(Sections); | |
1031 | if (start) | |
1032 | { | |
1033 | } | |
1034 | else | |
1035 | { | |
1036 | } | |
1037 | break; | |
1038 | } | |
1039 | case ltCLIPSFUNC: | |
1040 | { | |
1041 | if ( !combineSubSections ) | |
1042 | SetCurrentOutput(Subsections); | |
1043 | else | |
1044 | SetCurrentOutput(Sections); | |
1045 | if (start) | |
1046 | { | |
1047 | } | |
1048 | else | |
1049 | { | |
1050 | } | |
1051 | break; | |
1052 | } | |
1053 | case ltMEMBER: | |
1054 | { | |
1055 | if ( !combineSubSections ) | |
1056 | SetCurrentOutput(Subsections); | |
1057 | else | |
1058 | SetCurrentOutput(Sections); | |
1059 | if (start) | |
1060 | { | |
1061 | } | |
1062 | else | |
1063 | { | |
1064 | } | |
1065 | break; | |
1066 | } | |
1067 | case ltVOID: | |
1068 | // if (start) | |
6c155d33 | 1069 | // TexOutput(_T("<B>void</B>")); |
9a29912f JS |
1070 | break; |
1071 | case ltHARDY: | |
1072 | if (start) | |
6c155d33 | 1073 | TexOutput(_T("HARDY")); |
9a29912f JS |
1074 | break; |
1075 | case ltWXCLIPS: | |
1076 | if (start) | |
6c155d33 | 1077 | TexOutput(_T("wxCLIPS")); |
9a29912f JS |
1078 | break; |
1079 | case ltAMPERSAND: | |
1080 | if (start) | |
6c155d33 | 1081 | TexOutput(_T("&")); |
9a29912f JS |
1082 | break; |
1083 | case ltSPECIALAMPERSAND: | |
1084 | { | |
1085 | if (start) | |
1086 | { | |
1087 | if (inTabular) | |
1088 | { | |
1089 | // End cell, start cell | |
d7d17624 | 1090 | |
6c155d33 | 1091 | TexOutput(_T("</FONT></TD>")); |
119f7a8c | 1092 | |
9a29912f JS |
1093 | // Start new row and cell, setting alignment for the first cell. |
1094 | if (currentColumn < noColumns) | |
1095 | currentColumn ++; | |
1096 | ||
6c155d33 | 1097 | wxChar buf[100]; |
9a29912f | 1098 | if (TableData[currentColumn].justification == 'c') |
6c155d33 | 1099 | wxSprintf(buf, _T("\n<TD ALIGN=CENTER>")); |
9a29912f | 1100 | else if (TableData[currentColumn].justification == 'r') |
6c155d33 | 1101 | wxSprintf(buf, _T("\n<TD ALIGN=RIGHT>")); |
9a29912f JS |
1102 | else if (TableData[currentColumn].absWidth) |
1103 | { | |
1104 | // Convert from points * 20 into pixels. | |
1105 | int points = TableData[currentColumn].width / 20; | |
119f7a8c | 1106 | |
9a29912f JS |
1107 | // Say the display is 100 DPI (dots/pixels per inch). |
1108 | // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. | |
1109 | int pixels = (int)(points * 100.0 / 72.0); | |
6c155d33 | 1110 | wxSprintf(buf, _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels); |
9a29912f JS |
1111 | } |
1112 | else | |
6c155d33 | 1113 | wxSprintf(buf, _T("\n<TD ALIGN=LEFT>")); |
9a29912f | 1114 | TexOutput(buf); |
d7d17624 | 1115 | OutputFont(); |
9a29912f JS |
1116 | } |
1117 | else | |
6c155d33 | 1118 | TexOutput(_T("&")); |
9a29912f JS |
1119 | } |
1120 | break; | |
1121 | } | |
1122 | case ltBACKSLASHCHAR: | |
1123 | { | |
1124 | if (start) | |
1125 | { | |
1126 | if (inTabular) | |
1127 | { | |
1128 | // End row. In fact, tables without use of \row or \ruledrow isn't supported for | |
1129 | // HTML: the syntax is too different (e.g. how do we know where to put the first </TH> | |
1130 | // if we've ended the last row?). So normally you wouldn't use \\ to end a row. | |
6c155d33 | 1131 | TexOutput(_T("</TR>\n")); |
9a29912f JS |
1132 | } |
1133 | else | |
6c155d33 | 1134 | TexOutput(_T("<BR>\n")); |
9a29912f JS |
1135 | } |
1136 | break; | |
1137 | } | |
1138 | case ltROW: | |
1139 | case ltRULEDROW: | |
1140 | { | |
1141 | if (start) | |
1142 | { | |
1143 | currentColumn = 0; | |
119f7a8c | 1144 | |
9a29912f | 1145 | // Start new row and cell, setting alignment for the first cell. |
6c155d33 | 1146 | wxChar buf[100]; |
9a29912f | 1147 | if (TableData[currentColumn].justification == 'c') |
6c155d33 | 1148 | wxSprintf(buf, _T("<TR>\n<TD ALIGN=CENTER>")); |
9a29912f | 1149 | else if (TableData[currentColumn].justification == 'r') |
6c155d33 | 1150 | wxSprintf(buf, _T("<TR>\n<TD ALIGN=RIGHT>")); |
9a29912f JS |
1151 | else if (TableData[currentColumn].absWidth) |
1152 | { | |
1153 | // Convert from points * 20 into pixels. | |
1154 | int points = TableData[currentColumn].width / 20; | |
119f7a8c | 1155 | |
9a29912f JS |
1156 | // Say the display is 100 DPI (dots/pixels per inch). |
1157 | // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. | |
1158 | int pixels = (int)(points * 100.0 / 72.0); | |
6c155d33 | 1159 | wxSprintf(buf, _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels); |
9a29912f JS |
1160 | } |
1161 | else | |
6c155d33 | 1162 | wxSprintf(buf, _T("<TR>\n<TD ALIGN=LEFT>")); |
9a29912f | 1163 | TexOutput(buf); |
d7d17624 | 1164 | OutputFont(); |
9a29912f JS |
1165 | } |
1166 | else | |
1167 | { | |
1168 | // End cell and row | |
1169 | // Start new row and cell | |
6c155d33 | 1170 | TexOutput(_T("</FONT></TD>\n</TR>\n")); |
9a29912f JS |
1171 | } |
1172 | break; | |
1173 | } | |
1174 | // HTML-only: break until the end of the picture (both margins are clear). | |
1175 | case ltBRCLEAR: | |
1176 | { | |
1177 | if (start) | |
6c155d33 | 1178 | TexOutput(_T("<BR CLEAR=ALL>")); |
9a29912f JS |
1179 | break; |
1180 | } | |
1181 | case ltRTFSP: // Explicit space, RTF only | |
1182 | break; | |
1183 | case ltSPECIALTILDE: | |
1184 | { | |
1185 | if (start) | |
1186 | { | |
40126b09 | 1187 | if (TRUE) // (inVerbatim) |
6c155d33 | 1188 | TexOutput(_T("~")); |
9a29912f | 1189 | else |
6c155d33 | 1190 | TexOutput(_T(" ")); |
9a29912f JS |
1191 | } |
1192 | break; | |
1193 | } | |
1194 | case ltINDENTED : | |
1195 | { | |
1196 | if ( start ) | |
6c155d33 | 1197 | TexOutput(_T("<UL><UL>\n")); |
9a29912f | 1198 | else |
6c155d33 | 1199 | TexOutput(_T("</UL></UL>\n")); |
9a29912f JS |
1200 | break; |
1201 | } | |
1202 | case ltITEMIZE: | |
1203 | case ltENUMERATE: | |
1204 | case ltDESCRIPTION: | |
1205 | // case ltTWOCOLLIST: | |
1206 | { | |
1207 | if (start) | |
1208 | { | |
1209 | indentLevel ++; | |
1210 | ||
1211 | int listType; | |
1212 | if (macroId == ltENUMERATE) | |
1213 | listType = LATEX_ENUMERATE; | |
1214 | else if (macroId == ltITEMIZE) | |
1215 | listType = LATEX_ITEMIZE; | |
1216 | else | |
1217 | listType = LATEX_DESCRIPTION; | |
1218 | ||
1219 | itemizeStack.Insert(new ItemizeStruc(listType)); | |
1220 | switch (listType) | |
1221 | { | |
1222 | case LATEX_ITEMIZE: | |
6c155d33 | 1223 | TexOutput(_T("<UL>\n")); |
9a29912f JS |
1224 | break; |
1225 | case LATEX_ENUMERATE: | |
6c155d33 | 1226 | TexOutput(_T("<OL>\n")); |
9a29912f JS |
1227 | break; |
1228 | case LATEX_DESCRIPTION: | |
1229 | default: | |
6c155d33 | 1230 | TexOutput(_T("<DL>\n")); |
9a29912f JS |
1231 | break; |
1232 | } | |
1233 | } | |
1234 | else | |
1235 | { | |
1236 | indentLevel --; | |
ddc4f3b5 | 1237 | if (itemizeStack.GetFirst()) |
9a29912f | 1238 | { |
ddc4f3b5 | 1239 | ItemizeStruc *struc = (ItemizeStruc *)itemizeStack.GetFirst()->GetData(); |
9a29912f JS |
1240 | switch (struc->listType) |
1241 | { | |
1242 | case LATEX_ITEMIZE: | |
6c155d33 | 1243 | TexOutput(_T("</UL>\n")); |
9a29912f JS |
1244 | break; |
1245 | case LATEX_ENUMERATE: | |
6c155d33 | 1246 | TexOutput(_T("</OL>\n")); |
9a29912f JS |
1247 | break; |
1248 | case LATEX_DESCRIPTION: | |
1249 | default: | |
6c155d33 | 1250 | TexOutput(_T("</DL>\n")); |
9a29912f JS |
1251 | break; |
1252 | } | |
1253 | ||
1254 | delete struc; | |
ddc4f3b5 | 1255 | delete itemizeStack.GetFirst(); |
9a29912f JS |
1256 | } |
1257 | } | |
1258 | break; | |
1259 | } | |
1260 | case ltTWOCOLLIST : | |
1261 | { | |
1262 | if ( start ) | |
6c155d33 | 1263 | TexOutput(_T("\n<TABLE>\n")); |
c103ca4b | 1264 | else { |
6c155d33 | 1265 | TexOutput(_T("\n</TABLE>\n")); |
c103ca4b JS |
1266 | // DHS |
1267 | TwoColWidthA = -1; | |
1268 | TwoColWidthB = -1; | |
1269 | } | |
9a29912f JS |
1270 | break; |
1271 | } | |
1272 | case ltPAR: | |
1273 | { | |
1274 | if (start) | |
6c155d33 | 1275 | TexOutput(_T("<P>\n")); |
9a29912f JS |
1276 | break; |
1277 | } | |
1278 | /* For footnotes we need to output the text at the bottom of the page and | |
1279 | * insert a reference to it. Is it worth the trouble... | |
1280 | case ltFOOTNOTE: | |
1281 | case ltFOOTNOTEPOPUP: | |
1282 | { | |
1283 | if (start) | |
1284 | { | |
6c155d33 | 1285 | TexOutput(_T("<FN>")); |
9a29912f | 1286 | } |
6c155d33 | 1287 | else TexOutput(_T("</FN>")); |
9a29912f JS |
1288 | break; |
1289 | } | |
1290 | */ | |
1291 | case ltVERB: | |
1292 | { | |
1293 | if (start) | |
6c155d33 JS |
1294 | TexOutput(_T("<TT>")); |
1295 | else TexOutput(_T("</TT>")); | |
9a29912f JS |
1296 | break; |
1297 | } | |
1298 | case ltVERBATIM: | |
1299 | { | |
1300 | if (start) | |
1301 | { | |
6c155d33 JS |
1302 | wxChar buf[100]; |
1303 | wxSprintf(buf, _T("<PRE>\n")); | |
9a29912f JS |
1304 | TexOutput(buf); |
1305 | } | |
6c155d33 | 1306 | else TexOutput(_T("</PRE>\n")); |
9a29912f JS |
1307 | break; |
1308 | } | |
1309 | case ltCENTERLINE: | |
1310 | case ltCENTER: | |
1311 | { | |
1312 | if (start) | |
1313 | { | |
6c155d33 | 1314 | TexOutput(_T("<CENTER>")); |
9a29912f | 1315 | } |
6c155d33 | 1316 | else TexOutput(_T("</CENTER>")); |
9a29912f JS |
1317 | break; |
1318 | } | |
1319 | case ltFLUSHLEFT: | |
1320 | { | |
1321 | /* | |
1322 | if (start) | |
1323 | { | |
6c155d33 | 1324 | TexOutput(_T("{\\ql ")); |
9a29912f | 1325 | } |
6c155d33 | 1326 | else TexOutput(_T("}\\par\\pard\n")); |
9a29912f JS |
1327 | */ |
1328 | break; | |
1329 | } | |
1330 | case ltFLUSHRIGHT: | |
1331 | { | |
1332 | /* | |
1333 | if (start) | |
1334 | { | |
6c155d33 | 1335 | TexOutput(_T("{\\qr ")); |
9a29912f | 1336 | } |
6c155d33 | 1337 | else TexOutput(_T("}\\par\\pard\n")); |
9a29912f JS |
1338 | */ |
1339 | break; | |
1340 | } | |
1341 | case ltSMALL: | |
1342 | { | |
1343 | if (start) | |
1344 | { | |
1345 | // Netscape extension | |
6c155d33 | 1346 | TexOutput(_T("<FONT SIZE=2>")); |
9a29912f | 1347 | } |
6c155d33 | 1348 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1349 | break; |
1350 | } | |
1351 | case ltTINY: | |
1352 | { | |
1353 | if (start) | |
1354 | { | |
1355 | // Netscape extension | |
6c155d33 | 1356 | TexOutput(_T("<FONT SIZE=1>")); |
9a29912f | 1357 | } |
6c155d33 | 1358 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1359 | break; |
1360 | } | |
1361 | case ltNORMALSIZE: | |
1362 | { | |
1363 | if (start) | |
1364 | { | |
1365 | // Netscape extension | |
6c155d33 | 1366 | TexOutput(_T("<FONT SIZE=3>")); |
9a29912f | 1367 | } |
6c155d33 | 1368 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1369 | break; |
1370 | } | |
1371 | case ltlarge: | |
1372 | { | |
1373 | if (start) | |
1374 | { | |
1375 | // Netscape extension | |
6c155d33 | 1376 | TexOutput(_T("<FONT SIZE=4>")); |
9a29912f | 1377 | } |
6c155d33 | 1378 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1379 | break; |
1380 | } | |
1381 | case ltLarge: | |
1382 | { | |
1383 | if (start) | |
1384 | { | |
1385 | // Netscape extension | |
6c155d33 | 1386 | TexOutput(_T("<FONT SIZE=5>")); |
9a29912f | 1387 | } |
6c155d33 | 1388 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1389 | break; |
1390 | } | |
1391 | case ltLARGE: | |
1392 | { | |
1393 | if (start) | |
1394 | { | |
1395 | // Netscape extension | |
6c155d33 | 1396 | TexOutput(_T("<FONT SIZE=6>")); |
9a29912f | 1397 | } |
6c155d33 | 1398 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1399 | break; |
1400 | } | |
1401 | case ltBFSERIES: | |
1402 | case ltTEXTBF: | |
1403 | case ltBF: | |
1404 | { | |
1405 | if (start) | |
1406 | { | |
6c155d33 | 1407 | TexOutput(_T("<B>")); |
9a29912f | 1408 | } |
6c155d33 | 1409 | else TexOutput(_T("</B>")); |
9a29912f JS |
1410 | break; |
1411 | } | |
1412 | case ltITSHAPE: | |
1413 | case ltTEXTIT: | |
1414 | case ltIT: | |
1415 | { | |
1416 | if (start) | |
1417 | { | |
6c155d33 | 1418 | TexOutput(_T("<I>")); |
9a29912f | 1419 | } |
6c155d33 | 1420 | else TexOutput(_T("</I>")); |
9a29912f JS |
1421 | break; |
1422 | } | |
1423 | case ltEMPH: | |
1424 | case ltEM: | |
1425 | { | |
1426 | if (start) | |
1427 | { | |
6c155d33 | 1428 | TexOutput(_T("<EM>")); |
9a29912f | 1429 | } |
6c155d33 | 1430 | else TexOutput(_T("</EM>")); |
9a29912f JS |
1431 | break; |
1432 | } | |
1433 | case ltUNDERLINE: | |
1434 | { | |
1435 | if (start) | |
1436 | { | |
6c155d33 | 1437 | TexOutput(_T("<UL>")); |
9a29912f | 1438 | } |
6c155d33 | 1439 | else TexOutput(_T("</UL>")); |
9a29912f JS |
1440 | break; |
1441 | } | |
1442 | case ltTTFAMILY: | |
1443 | case ltTEXTTT: | |
1444 | case ltTT: | |
1445 | { | |
1446 | if (start) | |
1447 | { | |
6c155d33 | 1448 | TexOutput(_T("<TT>")); |
9a29912f | 1449 | } |
6c155d33 | 1450 | else TexOutput(_T("</TT>")); |
9a29912f JS |
1451 | break; |
1452 | } | |
1453 | case ltCOPYRIGHT: | |
1454 | { | |
1455 | if (start) | |
6c155d33 | 1456 | TexOutput(_T("©"), TRUE); |
9a29912f JS |
1457 | break; |
1458 | } | |
1459 | case ltREGISTERED: | |
1460 | { | |
1461 | if (start) | |
6c155d33 | 1462 | TexOutput(_T("®"), TRUE); |
9a29912f JS |
1463 | break; |
1464 | } | |
1465 | // Arrows | |
1466 | case ltLEFTARROW: | |
1467 | { | |
6c155d33 | 1468 | if (start) TexOutput(_T("<--")); |
9a29912f JS |
1469 | break; |
1470 | } | |
1471 | case ltLEFTARROW2: | |
1472 | { | |
6c155d33 | 1473 | if (start) TexOutput(_T("<==")); |
9a29912f JS |
1474 | break; |
1475 | } | |
1476 | case ltRIGHTARROW: | |
1477 | { | |
6c155d33 | 1478 | if (start) TexOutput(_T("-->")); |
9a29912f JS |
1479 | break; |
1480 | } | |
1481 | case ltRIGHTARROW2: | |
1482 | { | |
6c155d33 | 1483 | if (start) TexOutput(_T("==>")); |
9a29912f JS |
1484 | break; |
1485 | } | |
1486 | case ltLEFTRIGHTARROW: | |
1487 | { | |
6c155d33 | 1488 | if (start) TexOutput(_T("<-->")); |
9a29912f JS |
1489 | break; |
1490 | } | |
1491 | case ltLEFTRIGHTARROW2: | |
1492 | { | |
6c155d33 | 1493 | if (start) TexOutput(_T("<==>")); |
9a29912f JS |
1494 | break; |
1495 | } | |
1496 | /* | |
1497 | case ltSC: | |
1498 | { | |
1499 | break; | |
1500 | } | |
1501 | */ | |
1502 | case ltITEM: | |
1503 | { | |
1504 | if (!start) | |
1505 | { | |
ddc4f3b5 | 1506 | wxNode *node = itemizeStack.GetFirst(); |
9a29912f JS |
1507 | if (node) |
1508 | { | |
ddc4f3b5 | 1509 | ItemizeStruc *struc = (ItemizeStruc *)node->GetData(); |
9a29912f JS |
1510 | struc->currentItem += 1; |
1511 | if (struc->listType == LATEX_DESCRIPTION) | |
1512 | { | |
1513 | if (descriptionItemArg) | |
1514 | { | |
6c155d33 | 1515 | TexOutput(_T("<DT> ")); |
9a29912f | 1516 | TraverseChildrenFromChunk(descriptionItemArg); |
6c155d33 | 1517 | TexOutput(_T("\n")); |
9a29912f JS |
1518 | descriptionItemArg = NULL; |
1519 | } | |
6c155d33 | 1520 | TexOutput(_T("<DD>")); |
9a29912f JS |
1521 | } |
1522 | else | |
6c155d33 | 1523 | TexOutput(_T("<LI>")); |
9a29912f JS |
1524 | } |
1525 | } | |
1526 | break; | |
1527 | } | |
1528 | case ltMAKETITLE: | |
1529 | { | |
1530 | if (start && DocumentTitle && DocumentAuthor) | |
1531 | { | |
1532 | // Add a special label for the contents page. | |
6c155d33 JS |
1533 | // TexOutput(_T("<CENTER>\n")); |
1534 | TexOutput(_T("<A NAME=\"contents\">")); | |
1535 | TexOutput(_T("<H2 ALIGN=CENTER>\n")); | |
9a29912f | 1536 | TraverseChildrenFromChunk(DocumentTitle); |
6c155d33 JS |
1537 | TexOutput(_T("</H2>")); |
1538 | TexOutput(_T("<P>")); | |
1539 | TexOutput(_T("</A>\n")); | |
1540 | TexOutput(_T("<P>\n\n")); | |
1541 | TexOutput(_T("<H3 ALIGN=CENTER>")); | |
9a29912f | 1542 | TraverseChildrenFromChunk(DocumentAuthor); |
6c155d33 | 1543 | TexOutput(_T("</H3><P>\n\n")); |
9a29912f JS |
1544 | if (DocumentDate) |
1545 | { | |
6c155d33 | 1546 | TexOutput(_T("<H3 ALIGN=CENTER>")); |
9a29912f | 1547 | TraverseChildrenFromChunk(DocumentDate); |
6c155d33 | 1548 | TexOutput(_T("</H3><P>\n\n")); |
9a29912f | 1549 | } |
6c155d33 JS |
1550 | // TexOutput(_T("\n</CENTER>\n")); |
1551 | TexOutput(_T("\n<P><HR><P>\n")); | |
9a29912f JS |
1552 | |
1553 | /* | |
1554 | // Now do optional frame contents page | |
1555 | if (htmlFrameContents && FrameContents) | |
1556 | { | |
1557 | SetCurrentOutput(FrameContents); | |
119f7a8c | 1558 | |
9a29912f | 1559 | // Add a special label for the contents page. |
6c155d33 JS |
1560 | TexOutput(_T("<CENTER>\n")); |
1561 | TexOutput(_T("<H3>\n")); | |
9a29912f | 1562 | TraverseChildrenFromChunk(DocumentTitle); |
6c155d33 JS |
1563 | TexOutput(_T("</H3>")); |
1564 | TexOutput(_T("<P>")); | |
1565 | TexOutput(_T("</A>\n")); | |
1566 | TexOutput(_T("<P>\n\n")); | |
1567 | TexOutput(_T("<H3>")); | |
9a29912f | 1568 | TraverseChildrenFromChunk(DocumentAuthor); |
6c155d33 | 1569 | TexOutput(_T("</H3><P>\n\n")); |
9a29912f JS |
1570 | if (DocumentDate) |
1571 | { | |
6c155d33 | 1572 | TexOutput(_T("<H4>")); |
9a29912f | 1573 | TraverseChildrenFromChunk(DocumentDate); |
6c155d33 | 1574 | TexOutput(_T("</H4><P>\n\n")); |
9a29912f | 1575 | } |
6c155d33 JS |
1576 | TexOutput(_T("\n</CENTER>\n")); |
1577 | TexOutput(_T("<P><HR><P>\n")); | |
119f7a8c | 1578 | |
9a29912f JS |
1579 | SetCurrentOutput(Titlepage); |
1580 | } | |
1581 | */ | |
1582 | } | |
1583 | break; | |
1584 | } | |
1585 | case ltHELPREF: | |
1586 | case ltHELPREFN: | |
1587 | case ltPOPREF: | |
1588 | case ltURLREF: | |
1589 | { | |
1590 | if (start) | |
1591 | { | |
1592 | helpRefFilename = NULL; | |
1593 | helpRefText = NULL; | |
1594 | } | |
1595 | break; | |
1596 | } | |
1597 | case ltBIBLIOGRAPHY: | |
1598 | { | |
1599 | if (start) | |
1600 | { | |
1601 | DefaultOnMacro(macroId, no_args, start); | |
1602 | } | |
1603 | else | |
1604 | { | |
1605 | DefaultOnMacro(macroId, no_args, start); | |
6c155d33 | 1606 | TexOutput(_T("</DL>\n")); |
9a29912f JS |
1607 | } |
1608 | break; | |
1609 | } | |
1610 | case ltHRULE: | |
1611 | { | |
1612 | if (start) | |
1613 | { | |
6c155d33 | 1614 | TexOutput(_T("<HR>\n")); |
9a29912f JS |
1615 | } |
1616 | break; | |
1617 | } | |
1618 | case ltRULE: | |
1619 | { | |
1620 | if (start) | |
1621 | { | |
6c155d33 | 1622 | TexOutput(_T("<HR>\n")); |
9a29912f JS |
1623 | } |
1624 | break; | |
1625 | } | |
1626 | case ltTABLEOFCONTENTS: | |
1627 | { | |
1628 | if (start) | |
1629 | { | |
6c155d33 | 1630 | FILE *fd = wxFopen(ContentsName, _T("r")); |
9a29912f JS |
1631 | if (fd) |
1632 | { | |
1633 | int ch = getc(fd); | |
1634 | while (ch != EOF) | |
1635 | { | |
1636 | putc(ch, Titlepage); | |
1637 | ch = getc(fd); | |
1638 | } | |
1639 | fclose(fd); | |
1640 | } | |
1641 | else | |
1642 | { | |
6c155d33 JS |
1643 | TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n")); |
1644 | OnInform(_T("Run Tex2RTF again to include contents page.")); | |
9a29912f JS |
1645 | } |
1646 | } | |
1647 | break; | |
1648 | } | |
1649 | case ltLANGLEBRA: | |
1650 | { | |
1651 | if (start) | |
6c155d33 | 1652 | TexOutput(_T("<")); |
9a29912f JS |
1653 | break; |
1654 | } | |
1655 | case ltRANGLEBRA: | |
1656 | { | |
1657 | if (start) | |
6c155d33 | 1658 | TexOutput(_T(">")); |
9a29912f JS |
1659 | break; |
1660 | } | |
1661 | case ltQUOTE: | |
1662 | case ltQUOTATION: | |
1663 | { | |
1664 | if (start) | |
6c155d33 | 1665 | TexOutput(_T("<BLOCKQUOTE>")); |
9a29912f | 1666 | else |
6c155d33 | 1667 | TexOutput(_T("</BLOCKQUOTE>")); |
9a29912f JS |
1668 | break; |
1669 | } | |
1670 | case ltCAPTION: | |
1671 | case ltCAPTIONSTAR: | |
1672 | { | |
1673 | if (start) | |
1674 | { | |
1675 | if (inTabular) | |
6c155d33 | 1676 | TexOutput(_T("\n<CAPTION>")); |
9a29912f | 1677 | |
6c155d33 | 1678 | wxChar figBuf[40]; |
9a29912f JS |
1679 | |
1680 | if ( inFigure ) | |
1681 | { | |
1682 | figureNo ++; | |
1683 | ||
1684 | if (DocumentStyle != LATEX_ARTICLE) | |
6c155d33 | 1685 | wxSprintf(figBuf, _T("%s %d.%d: "), FigureNameString, chapterNo, figureNo); |
9a29912f | 1686 | else |
6c155d33 | 1687 | wxSprintf(figBuf, _T("%s %d: "), FigureNameString, figureNo); |
9a29912f JS |
1688 | } |
1689 | else | |
1690 | { | |
1691 | tableNo ++; | |
1692 | ||
1693 | if (DocumentStyle != LATEX_ARTICLE) | |
6c155d33 | 1694 | wxSprintf(figBuf, _T("%s %d.%d: "), TableNameString, chapterNo, tableNo); |
9a29912f | 1695 | else |
6c155d33 | 1696 | wxSprintf(figBuf, _T("%s %d: "), TableNameString, tableNo); |
9a29912f JS |
1697 | } |
1698 | ||
1699 | TexOutput(figBuf); | |
1700 | } | |
1701 | else | |
1702 | { | |
1703 | if (inTabular) | |
6c155d33 | 1704 | TexOutput(_T("\n</CAPTION>\n")); |
9a29912f | 1705 | |
6c155d33 | 1706 | wxChar *topicName = FindTopicName(GetNextChunk()); |
9a29912f JS |
1707 | |
1708 | int n = inFigure ? figureNo : tableNo; | |
1709 | ||
1710 | AddTexRef(topicName, NULL, NULL, | |
1711 | ((DocumentStyle != LATEX_ARTICLE) ? chapterNo : n), | |
1712 | ((DocumentStyle != LATEX_ARTICLE) ? n : 0)); | |
1713 | } | |
1714 | break; | |
1715 | } | |
1716 | case ltSS: | |
1717 | { | |
6c155d33 | 1718 | if (start) TexOutput(_T("ß")); |
9a29912f JS |
1719 | break; |
1720 | } | |
1721 | case ltFIGURE: | |
1722 | { | |
1723 | if (start) inFigure = TRUE; | |
1724 | else inFigure = FALSE; | |
1725 | break; | |
1726 | } | |
1727 | case ltTABLE: | |
1728 | { | |
1729 | if (start) inTable = TRUE; | |
1730 | else inTable = FALSE; | |
1731 | break; | |
1732 | } | |
1733 | default: | |
1734 | DefaultOnMacro(macroId, no_args, start); | |
1735 | break; | |
1736 | } | |
1737 | } | |
1738 | ||
1739 | // Called on start/end of argument examination | |
1740 | bool HTMLOnArgument(int macroId, int arg_no, bool start) | |
1741 | { | |
1742 | switch (macroId) | |
1743 | { | |
1744 | case ltCHAPTER: | |
1745 | case ltCHAPTERSTAR: | |
1746 | case ltCHAPTERHEADING: | |
1747 | case ltSECTION: | |
1748 | case ltSECTIONSTAR: | |
1749 | case ltSECTIONHEADING: | |
1750 | case ltSUBSECTION: | |
1751 | case ltSUBSECTIONSTAR: | |
1752 | case ltSUBSUBSECTION: | |
1753 | case ltSUBSUBSECTIONSTAR: | |
1754 | case ltGLOSS: | |
1755 | case ltMEMBERSECTION: | |
1756 | case ltFUNCTIONSECTION: | |
1757 | { | |
1758 | if (!start && (arg_no == 1)) | |
1759 | currentSection = GetArgChunk(); | |
1760 | return FALSE; | |
9a29912f JS |
1761 | } |
1762 | case ltFUNC: | |
1763 | { | |
1764 | if (start && (arg_no == 1)) | |
6c155d33 | 1765 | TexOutput(_T("<B>")); |
9a29912f JS |
1766 | |
1767 | if (!start && (arg_no == 1)) | |
6c155d33 | 1768 | TexOutput(_T("</B> ")); |
9a29912f JS |
1769 | |
1770 | if (start && (arg_no == 2)) | |
1771 | { | |
6c155d33 | 1772 | if (!suppressNameDecoration) TexOutput(_T("<B>")); |
9a29912f JS |
1773 | currentMember = GetArgChunk(); |
1774 | } | |
1775 | if (!start && (arg_no == 2)) | |
1776 | { | |
6c155d33 | 1777 | if (!suppressNameDecoration) TexOutput(_T("</B>")); |
9a29912f | 1778 | } |
119f7a8c | 1779 | |
9a29912f | 1780 | if (start && (arg_no == 3)) |
6c155d33 | 1781 | TexOutput(_T("(")); |
9a29912f | 1782 | if (!start && (arg_no == 3)) |
6c155d33 | 1783 | TexOutput(_T(")")); |
9a29912f JS |
1784 | break; |
1785 | } | |
1786 | case ltCLIPSFUNC: | |
1787 | { | |
1788 | if (start && (arg_no == 1)) | |
6c155d33 | 1789 | TexOutput(_T("<B>")); |
9a29912f | 1790 | if (!start && (arg_no == 1)) |
6c155d33 | 1791 | TexOutput(_T("</B> ")); |
9a29912f JS |
1792 | |
1793 | if (start && (arg_no == 2)) | |
1794 | { | |
6c155d33 | 1795 | if (!suppressNameDecoration) TexOutput(_T("( ")); |
9a29912f JS |
1796 | currentMember = GetArgChunk(); |
1797 | } | |
1798 | if (!start && (arg_no == 2)) | |
1799 | { | |
1800 | } | |
1801 | ||
1802 | if (!start && (arg_no == 3)) | |
6c155d33 | 1803 | TexOutput(_T(")")); |
9a29912f JS |
1804 | break; |
1805 | } | |
1806 | case ltPFUNC: | |
1807 | { | |
1808 | if (!start && (arg_no == 1)) | |
6c155d33 | 1809 | TexOutput(_T(" ")); |
9a29912f JS |
1810 | |
1811 | if (start && (arg_no == 2)) | |
6c155d33 | 1812 | TexOutput(_T("(*")); |
9a29912f | 1813 | if (!start && (arg_no == 2)) |
6c155d33 | 1814 | TexOutput(_T(")")); |
9a29912f JS |
1815 | |
1816 | if (start && (arg_no == 2)) | |
1817 | currentMember = GetArgChunk(); | |
1818 | ||
1819 | if (start && (arg_no == 3)) | |
6c155d33 | 1820 | TexOutput(_T("(")); |
9a29912f | 1821 | if (!start && (arg_no == 3)) |
6c155d33 | 1822 | TexOutput(_T(")")); |
9a29912f JS |
1823 | break; |
1824 | } | |
1825 | case ltPARAM: | |
1826 | { | |
1827 | if (start && (arg_no == 1)) | |
6c155d33 | 1828 | TexOutput(_T("<B>")); |
9a29912f | 1829 | if (!start && (arg_no == 1)) |
6c155d33 | 1830 | TexOutput(_T("</B>")); |
9a29912f JS |
1831 | if (start && (arg_no == 2)) |
1832 | { | |
6c155d33 | 1833 | TexOutput(_T("<I>")); |
9a29912f JS |
1834 | } |
1835 | if (!start && (arg_no == 2)) | |
1836 | { | |
6c155d33 | 1837 | TexOutput(_T("</I>")); |
9a29912f JS |
1838 | } |
1839 | break; | |
1840 | } | |
1841 | case ltCPARAM: | |
1842 | { | |
1843 | if (start && (arg_no == 1)) | |
6c155d33 | 1844 | TexOutput(_T("<B>")); |
9a29912f | 1845 | if (!start && (arg_no == 1)) |
6c155d33 | 1846 | TexOutput(_T("</B> ")); // This is the difference from param - one space! |
9a29912f JS |
1847 | if (start && (arg_no == 2)) |
1848 | { | |
6c155d33 | 1849 | TexOutput(_T("<I>")); |
9a29912f JS |
1850 | } |
1851 | if (!start && (arg_no == 2)) | |
1852 | { | |
6c155d33 | 1853 | TexOutput(_T("</I>")); |
9a29912f JS |
1854 | } |
1855 | break; | |
1856 | } | |
1857 | case ltMEMBER: | |
1858 | { | |
1859 | if (!start && (arg_no == 1)) | |
6c155d33 | 1860 | TexOutput(_T(" ")); |
9a29912f JS |
1861 | |
1862 | if (start && (arg_no == 2)) | |
1863 | currentMember = GetArgChunk(); | |
1864 | break; | |
1865 | } | |
1866 | case ltREF: | |
1867 | { | |
1868 | if (start) | |
1869 | { | |
6c155d33 | 1870 | wxChar *sec = NULL; |
119f7a8c | 1871 | |
6c155d33 | 1872 | wxChar *refName = GetArgData(); |
9a29912f JS |
1873 | if (refName) |
1874 | { | |
1875 | TexRef *texRef = FindReference(refName); | |
1876 | if (texRef) | |
1877 | { | |
1878 | sec = texRef->sectionNumber; | |
1879 | } | |
1880 | } | |
1881 | if (sec) | |
1882 | { | |
1883 | TexOutput(sec); | |
1884 | } | |
1885 | return FALSE; | |
1886 | } | |
1887 | break; | |
1888 | } | |
1889 | case ltURLREF: | |
1890 | { | |
1891 | if (IsArgOptional()) | |
1892 | return FALSE; | |
1893 | else if ((GetNoArgs() - arg_no) == 1) | |
1894 | { | |
1895 | if (start) | |
1896 | helpRefText = GetArgChunk(); | |
1897 | return FALSE; | |
1898 | } | |
1899 | else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional | |
1900 | { | |
1901 | if (start) | |
1902 | { | |
1903 | TexChunk *ref = GetArgChunk(); | |
6c155d33 | 1904 | TexOutput(_T("<A HREF=\"")); |
9a29912f JS |
1905 | inVerbatim = TRUE; |
1906 | TraverseChildrenFromChunk(ref); | |
1907 | inVerbatim = FALSE; | |
6c155d33 | 1908 | TexOutput(_T("\">")); |
9a29912f JS |
1909 | if (helpRefText) |
1910 | TraverseChildrenFromChunk(helpRefText); | |
6c155d33 | 1911 | TexOutput(_T("</A>")); |
9a29912f JS |
1912 | } |
1913 | return FALSE; | |
1914 | } | |
1915 | break; | |
1916 | } | |
1917 | case ltHELPREF: | |
1918 | case ltHELPREFN: | |
1919 | case ltPOPREF: | |
1920 | { | |
1921 | if (IsArgOptional()) | |
1922 | { | |
1923 | if (start) | |
1924 | helpRefFilename = GetArgChunk(); | |
1925 | return FALSE; | |
1926 | } | |
1927 | if ((GetNoArgs() - arg_no) == 1) | |
1928 | { | |
1929 | if (start) | |
1930 | helpRefText = GetArgChunk(); | |
1931 | return FALSE; | |
1932 | } | |
1933 | else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional | |
1934 | { | |
1935 | if (start) | |
1936 | { | |
6c155d33 JS |
1937 | wxChar *refName = GetArgData(); |
1938 | wxChar *refFilename = NULL; | |
9a29912f JS |
1939 | |
1940 | if (refName) | |
1941 | { | |
1942 | TexRef *texRef = FindReference(refName); | |
1943 | if (texRef) | |
1944 | { | |
6c155d33 | 1945 | if (texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0) |
9a29912f JS |
1946 | refFilename = texRef->refFile; |
1947 | ||
6c155d33 | 1948 | TexOutput(_T("<A HREF=\"")); |
9a29912f JS |
1949 | // If a filename is supplied, use it, otherwise try to |
1950 | // use the filename associated with the reference (from this document). | |
1951 | if (helpRefFilename) | |
1952 | { | |
1953 | TraverseChildrenFromChunk(helpRefFilename); | |
6c155d33 | 1954 | TexOutput(_T("#")); |
9a29912f JS |
1955 | } |
1956 | else if (refFilename) | |
1957 | { | |
1958 | TexOutput(ConvertCase(refFilename)); | |
6c155d33 | 1959 | TexOutput(_T("#")); |
9a29912f JS |
1960 | } |
1961 | TexOutput(refName); | |
6c155d33 | 1962 | TexOutput(_T("\">")); |
9a29912f JS |
1963 | if (helpRefText) |
1964 | TraverseChildrenFromChunk(helpRefText); | |
6c155d33 | 1965 | TexOutput(_T("</A>")); |
9a29912f JS |
1966 | } |
1967 | else | |
1968 | { | |
1969 | if (helpRefText) | |
1970 | TraverseChildrenFromChunk(helpRefText); | |
bf16085d | 1971 | if (!ignoreBadRefs) |
6c155d33 | 1972 | TexOutput(_T(" (REF NOT FOUND)")); |
31ad62bc | 1973 | wxString errBuf; |
6c155d33 JS |
1974 | errBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); |
1975 | OnInform((wxChar *)errBuf.c_str()); | |
9a29912f JS |
1976 | } |
1977 | } | |
6c155d33 | 1978 | else TexOutput(_T("??")); |
9a29912f JS |
1979 | } |
1980 | return FALSE; | |
1981 | } | |
1982 | break; | |
1983 | } | |
1984 | case ltIMAGE: | |
1985 | case ltIMAGEL: | |
1986 | case ltIMAGER: | |
1987 | case ltPSBOXTO: | |
1988 | { | |
1989 | if (arg_no == 2) | |
1990 | { | |
1991 | if (start) | |
1992 | { | |
6c155d33 | 1993 | wxChar *alignment = _T(""); |
9a29912f | 1994 | if (macroId == ltIMAGEL) |
6c155d33 | 1995 | alignment = _T(" align=left"); |
9a29912f | 1996 | else if (macroId == ltIMAGER) |
6c155d33 | 1997 | alignment = _T(" align=right"); |
119f7a8c | 1998 | |
9a29912f | 1999 | // Try to find an XBM or GIF image first. |
6c155d33 JS |
2000 | wxChar *filename = copystring(GetArgData()); |
2001 | wxChar buf[500]; | |
119f7a8c | 2002 | |
6c155d33 | 2003 | wxStrcpy(buf, filename); |
9a29912f | 2004 | StripExtension(buf); |
6c155d33 | 2005 | wxStrcat(buf, _T(".xbm")); |
9a29912f JS |
2006 | wxString f = TexPathList.FindValidPath(buf); |
2007 | ||
6c155d33 | 2008 | if (f == _T("")) // Try for a GIF instead |
9a29912f | 2009 | { |
6c155d33 | 2010 | wxStrcpy(buf, filename); |
9a29912f | 2011 | StripExtension(buf); |
6c155d33 | 2012 | wxStrcat(buf, _T(".gif")); |
9a29912f JS |
2013 | f = TexPathList.FindValidPath(buf); |
2014 | } | |
14204c7a | 2015 | |
6c155d33 | 2016 | if (f == _T("")) // Try for a JPEG instead |
14204c7a | 2017 | { |
6c155d33 | 2018 | wxStrcpy(buf, filename); |
14204c7a | 2019 | StripExtension(buf); |
6c155d33 | 2020 | wxStrcat(buf, _T(".jpg")); |
14204c7a VS |
2021 | f = TexPathList.FindValidPath(buf); |
2022 | } | |
2023 | ||
6c155d33 | 2024 | if (f == _T("")) // Try for a PNG instead |
14204c7a | 2025 | { |
6c155d33 | 2026 | wxStrcpy(buf, filename); |
14204c7a | 2027 | StripExtension(buf); |
6c155d33 | 2028 | wxStrcat(buf, _T(".png")); |
14204c7a VS |
2029 | f = TexPathList.FindValidPath(buf); |
2030 | } | |
2031 | ||
6c155d33 | 2032 | if (f != _T("")) |
9a29912f | 2033 | { |
6c155d33 | 2034 | wxChar *inlineFilename = copystring(f); |
9a29912f | 2035 | #if 0 |
6c155d33 | 2036 | wxChar *originalFilename = TexPathList.FindValidPath(filename); |
9a29912f JS |
2037 | // If we have found the existing filename, make the inline |
2038 | // image point to the original file (could be PS, for example) | |
6c155d33 | 2039 | if (originalFilename && (wxStrcmp(inlineFilename, originalFilename) != 0)) |
9a29912f | 2040 | { |
6c155d33 | 2041 | TexOutput(_T("<A HREF=\"")); |
9a29912f | 2042 | TexOutput(ConvertCase(originalFilename)); |
6c155d33 JS |
2043 | TexOutput(_T("\">")); |
2044 | TexOutput(_T("<img src=\"")); | |
9a29912f | 2045 | TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename))); |
6c155d33 JS |
2046 | TexOutput(_T("\"")); |
2047 | TexOutput(alignment); | |
2048 | TexOutput(_T("></A>")); | |
9a29912f JS |
2049 | } |
2050 | else | |
2051 | #endif | |
2052 | { | |
6c155d33 | 2053 | TexOutput(_T("<img src=\"")); |
9a29912f | 2054 | TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename))); |
6c155d33 JS |
2055 | TexOutput(_T("\"")); |
2056 | TexOutput(alignment); | |
2057 | TexOutput(_T(">")); | |
9a29912f JS |
2058 | delete[] inlineFilename; |
2059 | } | |
2060 | } | |
2061 | else | |
2062 | { | |
2063 | // Last resort - a link to a PS file. | |
6c155d33 | 2064 | TexOutput(_T("<A HREF=\"")); |
9a29912f | 2065 | TexOutput(ConvertCase(wxFileNameFromPath(filename))); |
6c155d33 JS |
2066 | TexOutput(_T("\">Picture</A>\n")); |
2067 | wxSprintf(buf, _T("Warning: could not find an inline XBM/GIF for %s."), filename); | |
9a29912f JS |
2068 | OnInform(buf); |
2069 | } | |
2070 | } | |
2071 | } | |
2072 | return FALSE; | |
9a29912f JS |
2073 | } |
2074 | // First arg is PSBOX spec (ignored), second is image file, third is map name. | |
2075 | case ltIMAGEMAP: | |
2076 | { | |
6c155d33 | 2077 | static wxChar *imageFile = NULL; |
9a29912f JS |
2078 | if (start && (arg_no == 2)) |
2079 | { | |
2080 | // Try to find an XBM or GIF image first. | |
6c155d33 JS |
2081 | wxChar *filename = copystring(GetArgData()); |
2082 | wxChar buf[500]; | |
119f7a8c | 2083 | |
6c155d33 | 2084 | wxStrcpy(buf, filename); |
9a29912f | 2085 | StripExtension(buf); |
6c155d33 | 2086 | wxStrcat(buf, _T(".xbm")); |
9a29912f JS |
2087 | wxString f = TexPathList.FindValidPath(buf); |
2088 | ||
6c155d33 | 2089 | if (f == _T("")) // Try for a GIF instead |
9a29912f | 2090 | { |
6c155d33 | 2091 | wxStrcpy(buf, filename); |
9a29912f | 2092 | StripExtension(buf); |
6c155d33 | 2093 | wxStrcat(buf, _T(".gif")); |
9a29912f JS |
2094 | f = TexPathList.FindValidPath(buf); |
2095 | } | |
6c155d33 | 2096 | if (f == _T("")) |
9a29912f | 2097 | { |
6c155d33 JS |
2098 | wxChar buf[300]; |
2099 | wxSprintf(buf, _T("Warning: could not find an inline XBM/GIF for %s."), filename); | |
9a29912f JS |
2100 | OnInform(buf); |
2101 | } | |
2102 | delete[] filename; | |
2103 | if (imageFile) | |
2104 | delete[] imageFile; | |
2105 | imageFile = NULL; | |
48c12cb1 | 2106 | if (!f.IsEmpty()) |
9a29912f JS |
2107 | { |
2108 | imageFile = copystring(f); | |
2109 | } | |
2110 | } | |
2111 | else if (start && (arg_no == 3)) | |
2112 | { | |
2113 | if (imageFile) | |
2114 | { | |
2115 | // First, try to find a .shg (segmented hypergraphics file) | |
2116 | // that we can convert to a map file | |
6c155d33 JS |
2117 | wxChar buf[256]; |
2118 | wxStrcpy(buf, imageFile); | |
9a29912f | 2119 | StripExtension(buf); |
6c155d33 | 2120 | wxStrcat(buf, _T(".shg")); |
9a29912f JS |
2121 | wxString f = TexPathList.FindValidPath(buf); |
2122 | ||
6c155d33 | 2123 | if (f != _T("")) |
9a29912f JS |
2124 | { |
2125 | // The default HTML file to go to is THIS file (so a no-op) | |
6c155d33 | 2126 | SHGToMap((wxChar *)f.c_str(), currentFileName); |
9a29912f JS |
2127 | } |
2128 | ||
6c155d33 JS |
2129 | wxChar *mapName = GetArgData(); |
2130 | TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/")); | |
9a29912f JS |
2131 | if (mapName) |
2132 | TexOutput(mapName); | |
2133 | else | |
6c155d33 JS |
2134 | TexOutput(_T("unknown")); |
2135 | TexOutput(_T("\">")); | |
2136 | TexOutput(_T("<img src=\"")); | |
9a29912f | 2137 | TexOutput(ConvertCase(wxFileNameFromPath(imageFile))); |
6c155d33 | 2138 | TexOutput(_T("\" ISMAP></A><P>")); |
9a29912f JS |
2139 | delete[] imageFile; |
2140 | imageFile = NULL; | |
2141 | } | |
2142 | } | |
2143 | return FALSE; | |
9a29912f JS |
2144 | } |
2145 | case ltINDENTED : | |
2146 | { | |
2147 | if ( arg_no == 1 ) | |
2148 | return FALSE; | |
2149 | else | |
2150 | { | |
2151 | return TRUE; | |
2152 | } | |
2153 | } | |
2154 | case ltITEM: | |
2155 | { | |
2156 | if (start) | |
2157 | { | |
2158 | descriptionItemArg = GetArgChunk(); | |
2159 | return FALSE; | |
2160 | } | |
db0faf58 | 2161 | return TRUE; |
9a29912f JS |
2162 | } |
2163 | case ltTWOCOLITEM: | |
2164 | case ltTWOCOLITEMRULED: | |
2165 | { | |
2166 | /* | |
2167 | if (start && (arg_no == 1)) | |
6c155d33 | 2168 | TexOutput(_T("\n<DT> ")); |
9a29912f | 2169 | if (start && (arg_no == 2)) |
6c155d33 | 2170 | TexOutput(_T("<DD> ")); |
9a29912f JS |
2171 | */ |
2172 | if (arg_no == 1) | |
2173 | { | |
c103ca4b JS |
2174 | if ( start ) { |
2175 | // DHS | |
2176 | if (TwoColWidthA > -1) { | |
6c155d33 JS |
2177 | wxChar buf[100]; |
2178 | wxSprintf(buf,_T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA); | |
c103ca4b JS |
2179 | TexOutput(buf); |
2180 | } else | |
6c155d33 | 2181 | TexOutput(_T("\n<TR><TD VALIGN=TOP>\n")); |
d7d17624 | 2182 | OutputFont(); |
c103ca4b | 2183 | } else |
6c155d33 | 2184 | TexOutput(_T("\n</FONT></TD>\n")); |
9a29912f JS |
2185 | } |
2186 | if (arg_no == 2) | |
2187 | { | |
c103ca4b JS |
2188 | // DHS |
2189 | if ( start ) { | |
2190 | if (TwoColWidthB > -1) { | |
6c155d33 JS |
2191 | wxChar buf[100]; |
2192 | wxSprintf(buf,_T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB); | |
c103ca4b JS |
2193 | TexOutput(buf); |
2194 | } else | |
6c155d33 | 2195 | TexOutput(_T("\n<TD VALIGN=TOP>\n")); |
d7d17624 | 2196 | OutputFont(); |
c103ca4b | 2197 | } else |
6c155d33 | 2198 | TexOutput(_T("\n</FONT></TD></TR>\n")); |
9a29912f JS |
2199 | } |
2200 | return TRUE; | |
9a29912f JS |
2201 | } |
2202 | case ltNUMBEREDBIBITEM: | |
2203 | { | |
2204 | if (arg_no == 1 && start) | |
2205 | { | |
6c155d33 | 2206 | TexOutput(_T("\n<DT> ")); |
9a29912f JS |
2207 | } |
2208 | if (arg_no == 2 && !start) | |
6c155d33 | 2209 | TexOutput(_T("<P>\n")); |
9a29912f JS |
2210 | break; |
2211 | } | |
2212 | case ltBIBITEM: | |
2213 | { | |
6c155d33 | 2214 | wxChar buf[100]; |
9a29912f JS |
2215 | if (arg_no == 1 && start) |
2216 | { | |
6c155d33 | 2217 | wxChar *citeKey = GetArgData(); |
9a29912f JS |
2218 | TexRef *ref = (TexRef *)TexReferences.Get(citeKey); |
2219 | if (ref) | |
2220 | { | |
2221 | if (ref->sectionNumber) delete[] ref->sectionNumber; | |
6c155d33 | 2222 | wxSprintf(buf, _T("[%d]"), citeCount); |
9a29912f JS |
2223 | ref->sectionNumber = copystring(buf); |
2224 | } | |
2225 | ||
6c155d33 | 2226 | wxSprintf(buf, _T("\n<DT> [%d] "), citeCount); |
9a29912f JS |
2227 | TexOutput(buf); |
2228 | citeCount ++; | |
2229 | return FALSE; | |
2230 | } | |
2231 | if (arg_no == 2 && !start) | |
6c155d33 | 2232 | TexOutput(_T("<P>\n")); |
9a29912f | 2233 | return TRUE; |
9a29912f JS |
2234 | } |
2235 | case ltMARGINPAR: | |
2236 | case ltMARGINPARODD: | |
2237 | case ltMARGINPAREVEN: | |
2238 | case ltNORMALBOX: | |
2239 | case ltNORMALBOXD: | |
2240 | { | |
2241 | if (start) | |
2242 | { | |
6c155d33 | 2243 | TexOutput(_T("<HR>\n")); |
9a29912f JS |
2244 | return TRUE; |
2245 | } | |
2246 | else | |
6c155d33 | 2247 | TexOutput(_T("<HR><P>\n")); |
9a29912f JS |
2248 | break; |
2249 | } | |
c103ca4b JS |
2250 | // DHS |
2251 | case ltTWOCOLWIDTHA: | |
2252 | { | |
2253 | if (start) | |
2254 | { | |
6c155d33 | 2255 | wxChar *val = GetArgData(); |
c103ca4b JS |
2256 | float points = ParseUnitArgument(val); |
2257 | TwoColWidthA = (int)((points * 100.0) / 72.0); | |
2258 | } | |
2259 | return FALSE; | |
c103ca4b JS |
2260 | } |
2261 | // DHS | |
2262 | case ltTWOCOLWIDTHB: | |
2263 | { | |
2264 | if (start) | |
2265 | { | |
6c155d33 | 2266 | wxChar *val = GetArgData(); |
c103ca4b JS |
2267 | float points = ParseUnitArgument(val); |
2268 | TwoColWidthB = (int)((points * 100.0) / 72.0); | |
2269 | } | |
2270 | return FALSE; | |
c103ca4b | 2271 | } |
9a29912f JS |
2272 | /* |
2273 | * Accents | |
2274 | * | |
2275 | */ | |
2276 | case ltACCENT_GRAVE: | |
2277 | { | |
2278 | if (start) | |
2279 | { | |
6c155d33 | 2280 | wxChar *val = GetArgData(); |
9a29912f JS |
2281 | if (val) |
2282 | { | |
2283 | switch (val[0]) | |
2284 | { | |
2285 | case 'a': | |
6c155d33 | 2286 | TexOutput(_T("à")); |
9a29912f JS |
2287 | break; |
2288 | case 'e': | |
6c155d33 | 2289 | TexOutput(_T("è")); |
9a29912f JS |
2290 | break; |
2291 | case 'i': | |
6c155d33 | 2292 | TexOutput(_T("ì")); |
9a29912f JS |
2293 | break; |
2294 | case 'o': | |
6c155d33 | 2295 | TexOutput(_T("ò")); |
9a29912f JS |
2296 | break; |
2297 | case 'u': | |
6c155d33 | 2298 | TexOutput(_T("ù")); |
9a29912f JS |
2299 | break; |
2300 | case 'A': | |
6c155d33 | 2301 | TexOutput(_T("À")); |
9a29912f JS |
2302 | break; |
2303 | case 'E': | |
6c155d33 | 2304 | TexOutput(_T("È")); |
9a29912f JS |
2305 | break; |
2306 | case 'I': | |
6c155d33 | 2307 | TexOutput(_T("Ì")); |
9a29912f JS |
2308 | break; |
2309 | case 'O': | |
6c155d33 | 2310 | TexOutput(_T("Ò")); |
9a29912f JS |
2311 | break; |
2312 | case 'U': | |
6c155d33 | 2313 | TexOutput(_T("Ì")); |
9a29912f JS |
2314 | break; |
2315 | default: | |
2316 | break; | |
2317 | } | |
2318 | } | |
2319 | } | |
2320 | return FALSE; | |
9a29912f JS |
2321 | } |
2322 | case ltACCENT_ACUTE: | |
2323 | { | |
2324 | if (start) | |
2325 | { | |
6c155d33 | 2326 | wxChar *val = GetArgData(); |
9a29912f JS |
2327 | if (val) |
2328 | { | |
2329 | switch (val[0]) | |
2330 | { | |
2331 | case 'a': | |
6c155d33 | 2332 | TexOutput(_T("á")); |
9a29912f JS |
2333 | break; |
2334 | case 'e': | |
6c155d33 | 2335 | TexOutput(_T("é")); |
9a29912f JS |
2336 | break; |
2337 | case 'i': | |
6c155d33 | 2338 | TexOutput(_T("í")); |
9a29912f JS |
2339 | break; |
2340 | case 'o': | |
6c155d33 | 2341 | TexOutput(_T("ó")); |
9a29912f JS |
2342 | break; |
2343 | case 'u': | |
6c155d33 | 2344 | TexOutput(_T("ú")); |
9a29912f JS |
2345 | break; |
2346 | case 'y': | |
6c155d33 | 2347 | TexOutput(_T("ý")); |
9a29912f JS |
2348 | break; |
2349 | case 'A': | |
6c155d33 | 2350 | TexOutput(_T("Á")); |
9a29912f JS |
2351 | break; |
2352 | case 'E': | |
6c155d33 | 2353 | TexOutput(_T("É")); |
9a29912f JS |
2354 | break; |
2355 | case 'I': | |
6c155d33 | 2356 | TexOutput(_T("Í")); |
9a29912f JS |
2357 | break; |
2358 | case 'O': | |
6c155d33 | 2359 | TexOutput(_T("Ó")); |
9a29912f JS |
2360 | break; |
2361 | case 'U': | |
6c155d33 | 2362 | TexOutput(_T("Ú")); |
9a29912f JS |
2363 | break; |
2364 | case 'Y': | |
6c155d33 | 2365 | TexOutput(_T("Ý")); |
9a29912f JS |
2366 | break; |
2367 | default: | |
2368 | break; | |
2369 | } | |
2370 | } | |
2371 | } | |
2372 | return FALSE; | |
9a29912f JS |
2373 | } |
2374 | case ltACCENT_CARET: | |
2375 | { | |
2376 | if (start) | |
2377 | { | |
6c155d33 | 2378 | wxChar *val = GetArgData(); |
9a29912f JS |
2379 | if (val) |
2380 | { | |
2381 | switch (val[0]) | |
2382 | { | |
2383 | case 'a': | |
6c155d33 | 2384 | TexOutput(_T("â")); |
9a29912f JS |
2385 | break; |
2386 | case 'e': | |
6c155d33 | 2387 | TexOutput(_T("ê")); |
9a29912f JS |
2388 | break; |
2389 | case 'i': | |
6c155d33 | 2390 | TexOutput(_T("î")); |
9a29912f JS |
2391 | break; |
2392 | case 'o': | |
6c155d33 | 2393 | TexOutput(_T("ô")); |
9a29912f JS |
2394 | break; |
2395 | case 'u': | |
6c155d33 | 2396 | TexOutput(_T("û")); |
9a29912f JS |
2397 | break; |
2398 | case 'A': | |
6c155d33 | 2399 | TexOutput(_T("Â")); |
9a29912f JS |
2400 | break; |
2401 | case 'E': | |
6c155d33 | 2402 | TexOutput(_T("Ê")); |
9a29912f JS |
2403 | break; |
2404 | case 'I': | |
6c155d33 | 2405 | TexOutput(_T("Î")); |
9a29912f JS |
2406 | break; |
2407 | case 'O': | |
6c155d33 | 2408 | TexOutput(_T("Ô")); |
9a29912f JS |
2409 | break; |
2410 | case 'U': | |
6c155d33 | 2411 | TexOutput(_T("Î")); |
9a29912f JS |
2412 | break; |
2413 | default: | |
2414 | break; | |
2415 | } | |
2416 | } | |
2417 | } | |
2418 | return FALSE; | |
9a29912f JS |
2419 | } |
2420 | case ltACCENT_TILDE: | |
2421 | { | |
2422 | if (start) | |
2423 | { | |
6c155d33 | 2424 | wxChar *val = GetArgData(); |
9a29912f JS |
2425 | if (val) |
2426 | { | |
2427 | switch (val[0]) | |
2428 | { | |
2429 | case ' ': | |
6c155d33 | 2430 | TexOutput(_T("~")); |
9a29912f JS |
2431 | break; |
2432 | case 'a': | |
6c155d33 | 2433 | TexOutput(_T("ã")); |
9a29912f JS |
2434 | break; |
2435 | case 'n': | |
6c155d33 | 2436 | TexOutput(_T("ñ")); |
9a29912f JS |
2437 | break; |
2438 | case 'o': | |
6c155d33 | 2439 | TexOutput(_T("õ")); |
9a29912f JS |
2440 | break; |
2441 | case 'A': | |
6c155d33 | 2442 | TexOutput(_T("Ã")); |
9a29912f JS |
2443 | break; |
2444 | case 'N': | |
6c155d33 | 2445 | TexOutput(_T("Ñ")); |
9a29912f JS |
2446 | break; |
2447 | case 'O': | |
6c155d33 | 2448 | TexOutput(_T("Õ")); |
9a29912f JS |
2449 | break; |
2450 | default: | |
2451 | break; | |
2452 | } | |
2453 | } | |
2454 | } | |
2455 | return FALSE; | |
9a29912f JS |
2456 | } |
2457 | case ltACCENT_UMLAUT: | |
2458 | { | |
2459 | if (start) | |
2460 | { | |
6c155d33 | 2461 | wxChar *val = GetArgData(); |
9a29912f JS |
2462 | if (val) |
2463 | { | |
2464 | switch (val[0]) | |
2465 | { | |
2466 | case 'a': | |
6c155d33 | 2467 | TexOutput(_T("ä")); |
9a29912f JS |
2468 | break; |
2469 | case 'e': | |
6c155d33 | 2470 | TexOutput(_T("ë")); |
9a29912f JS |
2471 | break; |
2472 | case 'i': | |
6c155d33 | 2473 | TexOutput(_T("ï")); |
9a29912f JS |
2474 | break; |
2475 | case 'o': | |
6c155d33 | 2476 | TexOutput(_T("ö")); |
9a29912f JS |
2477 | break; |
2478 | case 'u': | |
6c155d33 | 2479 | TexOutput(_T("ü")); |
9a29912f JS |
2480 | break; |
2481 | case 'y': | |
6c155d33 | 2482 | TexOutput(_T("ÿ")); |
9a29912f JS |
2483 | break; |
2484 | case 'A': | |
6c155d33 | 2485 | TexOutput(_T("Ä")); |
9a29912f JS |
2486 | break; |
2487 | case 'E': | |
6c155d33 | 2488 | TexOutput(_T("Ë")); |
9a29912f JS |
2489 | break; |
2490 | case 'I': | |
6c155d33 | 2491 | TexOutput(_T("Ï")); |
9a29912f JS |
2492 | break; |
2493 | case 'O': | |
6c155d33 | 2494 | TexOutput(_T("Ö")); |
9a29912f JS |
2495 | break; |
2496 | case 'U': | |
6c155d33 | 2497 | TexOutput(_T("Ü")); |
9a29912f JS |
2498 | break; |
2499 | case 'Y': | |
6c155d33 | 2500 | TexOutput(_T("Ÿ")); |
9a29912f JS |
2501 | break; |
2502 | default: | |
2503 | break; | |
2504 | } | |
2505 | } | |
2506 | } | |
2507 | return FALSE; | |
9a29912f JS |
2508 | } |
2509 | case ltACCENT_DOT: | |
2510 | { | |
2511 | if (start) | |
2512 | { | |
6c155d33 | 2513 | wxChar *val = GetArgData(); |
9a29912f JS |
2514 | if (val) |
2515 | { | |
2516 | switch (val[0]) | |
2517 | { | |
2518 | case 'a': | |
6c155d33 | 2519 | TexOutput(_T("å")); |
9a29912f JS |
2520 | break; |
2521 | case 'A': | |
6c155d33 | 2522 | TexOutput(_T("Å")); |
9a29912f JS |
2523 | break; |
2524 | default: | |
2525 | break; | |
2526 | } | |
2527 | } | |
2528 | } | |
2529 | return FALSE; | |
9a29912f JS |
2530 | } |
2531 | case ltBACKGROUND: | |
2532 | { | |
2533 | if (start) | |
2534 | { | |
6c155d33 | 2535 | wxChar *val = GetArgData(); |
9a29912f JS |
2536 | if (val) |
2537 | { | |
2538 | bool isPicture = FALSE; | |
6a205442 | 2539 | ParseColourString(val, &isPicture); |
9a29912f JS |
2540 | if (isPicture) |
2541 | { | |
2542 | if (backgroundImageString) | |
2543 | delete[] backgroundImageString; | |
2544 | backgroundImageString = copystring(val); | |
2545 | } | |
2546 | else | |
2547 | { | |
2548 | if (backgroundColourString) | |
2549 | delete[] backgroundColourString; | |
2550 | backgroundColourString = copystring(val); | |
2551 | } | |
2552 | } | |
2553 | } | |
2554 | return FALSE; | |
9a29912f JS |
2555 | } |
2556 | case ltBACKGROUNDIMAGE: | |
2557 | { | |
2558 | if (start) | |
2559 | { | |
6c155d33 | 2560 | wxChar *val = GetArgData(); |
9a29912f JS |
2561 | if (val) |
2562 | { | |
2563 | if (backgroundImageString) | |
2564 | delete[] backgroundImageString; | |
2565 | backgroundImageString = copystring(val); | |
2566 | } | |
2567 | } | |
2568 | return FALSE; | |
9a29912f JS |
2569 | } |
2570 | case ltBACKGROUNDCOLOUR: | |
2571 | { | |
2572 | if (start) | |
2573 | { | |
6c155d33 | 2574 | wxChar *val = GetArgData(); |
9a29912f JS |
2575 | if (val) |
2576 | { | |
2577 | if (backgroundColourString) | |
2578 | delete[] backgroundColourString; | |
2579 | backgroundColourString = copystring(val); | |
2580 | } | |
2581 | } | |
2582 | return FALSE; | |
9a29912f JS |
2583 | } |
2584 | case ltTEXTCOLOUR: | |
2585 | { | |
2586 | if (start) | |
2587 | { | |
6c155d33 | 2588 | wxChar *val = GetArgData(); |
9a29912f JS |
2589 | if (val) |
2590 | { | |
2591 | if (textColourString) | |
2592 | delete[] textColourString; | |
2593 | textColourString = copystring(val); | |
2594 | } | |
2595 | } | |
2596 | return FALSE; | |
9a29912f JS |
2597 | } |
2598 | case ltLINKCOLOUR: | |
2599 | { | |
2600 | if (start) | |
2601 | { | |
6c155d33 | 2602 | wxChar *val = GetArgData(); |
9a29912f JS |
2603 | if (val) |
2604 | { | |
2605 | if (linkColourString) | |
2606 | delete[] linkColourString; | |
2607 | linkColourString = copystring(val); | |
2608 | } | |
2609 | } | |
2610 | return FALSE; | |
9a29912f JS |
2611 | } |
2612 | case ltFOLLOWEDLINKCOLOUR: | |
2613 | { | |
2614 | if (start) | |
2615 | { | |
6c155d33 | 2616 | wxChar *val = GetArgData(); |
9a29912f JS |
2617 | if (val) |
2618 | { | |
2619 | if (followedLinkColourString) | |
2620 | delete[] followedLinkColourString; | |
2621 | followedLinkColourString = copystring(val); | |
2622 | } | |
2623 | } | |
2624 | return FALSE; | |
9a29912f JS |
2625 | } |
2626 | case ltACCENT_CADILLA: | |
2627 | { | |
2628 | if (start) | |
2629 | { | |
6c155d33 | 2630 | wxChar *val = GetArgData(); |
9a29912f JS |
2631 | if (val) |
2632 | { | |
2633 | switch (val[0]) | |
2634 | { | |
2635 | case 'c': | |
6c155d33 | 2636 | TexOutput(_T("ç")); |
9a29912f JS |
2637 | break; |
2638 | case 'C': | |
6c155d33 | 2639 | TexOutput(_T("Ç")); |
9a29912f JS |
2640 | break; |
2641 | default: | |
2642 | break; | |
2643 | } | |
2644 | } | |
2645 | } | |
2646 | return FALSE; | |
9a29912f JS |
2647 | } |
2648 | /* | |
2649 | case ltFOOTNOTE: | |
2650 | case ltFOOTNOTEPOPUP: | |
2651 | { | |
2652 | if (arg_no == 1) | |
2653 | return TRUE; | |
2654 | else | |
2655 | return FALSE; | |
2656 | break; | |
2657 | } | |
119f7a8c | 2658 | */ |
9a29912f JS |
2659 | case ltTABULAR: |
2660 | case ltSUPERTABULAR: | |
2661 | { | |
2662 | if (arg_no == 1) | |
2663 | { | |
2664 | if (start) | |
2665 | { | |
2666 | currentRowNumber = 0; | |
2667 | inTabular = TRUE; | |
2668 | startRows = TRUE; | |
2669 | tableVerticalLineLeft = FALSE; | |
2670 | tableVerticalLineRight = FALSE; | |
9a29912f | 2671 | |
6c155d33 | 2672 | wxChar *alignString = copystring(GetArgData()); |
9a29912f JS |
2673 | ParseTableArgument(alignString); |
2674 | ||
6c155d33 | 2675 | TexOutput(_T("<TABLE BORDER>\n")); |
9a29912f JS |
2676 | |
2677 | // Write the first row formatting for compatibility | |
2678 | // with standard Latex | |
2679 | if (compatibilityMode) | |
2680 | { | |
6c155d33 | 2681 | TexOutput(_T("<TR>\n<TD>")); |
d7d17624 | 2682 | OutputFont(); |
9a29912f JS |
2683 | /* |
2684 | for (int i = 0; i < noColumns; i++) | |
2685 | { | |
2686 | currentWidth += TableData[i].width; | |
6c155d33 | 2687 | wxSprintf(buf, _T("\\cellx%d"), currentWidth); |
9a29912f JS |
2688 | TexOutput(buf); |
2689 | } | |
6c155d33 | 2690 | TexOutput(_T("\\pard\\intbl\n")); |
9a29912f JS |
2691 | */ |
2692 | } | |
2693 | delete[] alignString; | |
2694 | ||
2695 | return FALSE; | |
2696 | } | |
2697 | } | |
2698 | else if (arg_no == 2 && !start) | |
2699 | { | |
6c155d33 | 2700 | TexOutput(_T("</TABLE>\n")); |
9a29912f JS |
2701 | inTabular = FALSE; |
2702 | } | |
2703 | break; | |
2704 | } | |
2705 | case ltTHEBIBLIOGRAPHY: | |
2706 | { | |
2707 | if (start && (arg_no == 1)) | |
2708 | { | |
66828481 | 2709 | ReopenFile(&Chapters, &ChaptersName, _T("bibliography")); |
6c155d33 JS |
2710 | AddTexRef(_T("bibliography"), ChaptersName, _T("bibliography")); |
2711 | SetCurrentSubsectionName(_T("bibliography"), ChaptersName); | |
9a29912f JS |
2712 | |
2713 | citeCount = 1; | |
2714 | ||
2715 | SetCurrentOutput(Chapters); | |
2716 | ||
6c155d33 | 2717 | wxChar titleBuf[150]; |
9a29912f | 2718 | if (truncateFilenames) |
6c155d33 | 2719 | wxSprintf(titleBuf, _T("%s.htm"), wxFileNameFromPath(FileRoot)); |
9a29912f | 2720 | else |
6c155d33 | 2721 | wxSprintf(titleBuf, _T("%s_contents.html"), wxFileNameFromPath(FileRoot)); |
9a29912f | 2722 | |
6d8b260c | 2723 | HTMLHead(); |
6c155d33 | 2724 | TexOutput(_T("<title>")); |
9a29912f | 2725 | TexOutput(ReferencesNameString); |
6c155d33 | 2726 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
2727 | OutputBodyStart(); |
2728 | ||
6c155d33 JS |
2729 | wxFprintf(Chapters, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString); |
2730 | AddBrowseButtons(_T("contents"), titleBuf, // Up | |
9a29912f | 2731 | lastTopic, lastFileName, // Last topic |
6c155d33 | 2732 | _T("bibliography"), ChaptersName); // This topic |
9a29912f JS |
2733 | |
2734 | SetCurrentOutputs(Contents, Chapters); | |
6c155d33 | 2735 | wxFprintf(Contents, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName), "bibliography"); |
9a29912f | 2736 | |
6c155d33 JS |
2737 | wxFprintf(Contents, _T("%s</A>\n"), ReferencesNameString); |
2738 | wxFprintf(Chapters, _T("</H2>\n</A>\n")); | |
9a29912f JS |
2739 | |
2740 | SetCurrentOutput(Chapters); | |
2741 | return FALSE; | |
2742 | } | |
2743 | if (!start && (arg_no == 2)) | |
2744 | { | |
2745 | } | |
2746 | return TRUE; | |
9a29912f JS |
2747 | } |
2748 | case ltINDEX: | |
2749 | { | |
2750 | /* Build up list of keywords associated with topics */ | |
2751 | if (start) | |
2752 | { | |
6c155d33 JS |
2753 | // wxChar *entry = GetArgData(); |
2754 | wxChar buf[300]; | |
9a29912f JS |
2755 | OutputChunkToString(GetArgChunk(), buf); |
2756 | if (CurrentTopic) | |
2757 | { | |
2758 | AddKeyWordForTopic(CurrentTopic, buf, currentFileName); | |
2759 | } | |
2760 | } | |
2761 | return FALSE; | |
9a29912f JS |
2762 | } |
2763 | case ltFCOL: | |
2764 | // case ltBCOL: | |
2765 | { | |
2766 | if (start) | |
2767 | { | |
2768 | switch (arg_no) | |
2769 | { | |
2770 | case 1: | |
2771 | { | |
6c155d33 JS |
2772 | wxChar *name = GetArgData(); |
2773 | wxChar buf2[10]; | |
9a29912f JS |
2774 | if (!FindColourHTMLString(name, buf2)) |
2775 | { | |
6c155d33 JS |
2776 | wxStrcpy(buf2, _T("#000000")); |
2777 | wxChar buf[100]; | |
2778 | wxSprintf(buf, _T("Could not find colour name %s"), name); | |
9a29912f JS |
2779 | OnError(buf); |
2780 | } | |
6c155d33 | 2781 | TexOutput(_T("<FONT COLOR=\"")); |
9a29912f | 2782 | TexOutput(buf2); |
6c155d33 | 2783 | TexOutput(_T("\">")); |
9a29912f JS |
2784 | break; |
2785 | } | |
2786 | case 2: | |
2787 | { | |
2788 | return TRUE; | |
9a29912f JS |
2789 | } |
2790 | default: | |
2791 | break; | |
2792 | } | |
2793 | } | |
2794 | else | |
2795 | { | |
6c155d33 | 2796 | if (arg_no == 2) TexOutput(_T("</FONT>")); |
9a29912f JS |
2797 | } |
2798 | return FALSE; | |
9a29912f JS |
2799 | } |
2800 | case ltINSERTATLEVEL: | |
2801 | { | |
2802 | // This macro allows you to insert text at a different level | |
2803 | // from the current level, e.g. into the Sections from within a subsubsection. | |
2804 | if (useWord) | |
2805 | return FALSE; | |
2806 | static int currentLevelNo = 1; | |
2807 | static FILE* oldLevelFile = Chapters; | |
2808 | if (start) | |
2809 | { | |
2810 | switch (arg_no) | |
2811 | { | |
2812 | case 1: | |
2813 | { | |
2814 | oldLevelFile = CurrentOutput1; | |
2815 | ||
6c155d33 JS |
2816 | wxChar *str = GetArgData(); |
2817 | currentLevelNo = wxAtoi(str); | |
9a29912f JS |
2818 | FILE* outputFile; |
2819 | // TODO: cope with article style (no chapters) | |
2820 | switch (currentLevelNo) | |
2821 | { | |
2822 | case 1: | |
2823 | { | |
2824 | outputFile = Chapters; | |
2825 | break; | |
2826 | } | |
2827 | case 2: | |
2828 | { | |
2829 | outputFile = Sections; | |
2830 | break; | |
2831 | } | |
2832 | case 3: | |
2833 | { | |
2834 | outputFile = Subsections; | |
2835 | break; | |
2836 | } | |
2837 | case 4: | |
2838 | { | |
2839 | outputFile = Subsubsections; | |
2840 | break; | |
2841 | } | |
2842 | default: | |
2843 | { | |
2844 | outputFile = NULL; | |
2845 | break; | |
2846 | } | |
2847 | } | |
2848 | if (outputFile) | |
2849 | CurrentOutput1 = outputFile; | |
2850 | return FALSE; | |
9a29912f JS |
2851 | } |
2852 | case 2: | |
2853 | { | |
2854 | return TRUE; | |
9a29912f JS |
2855 | } |
2856 | default: | |
2857 | break; | |
2858 | } | |
2859 | return TRUE; | |
2860 | } | |
2861 | else | |
2862 | { | |
2863 | if (arg_no == 2) | |
2864 | { | |
2865 | CurrentOutput1 = oldLevelFile; | |
2866 | } | |
2867 | return TRUE; | |
2868 | } | |
2869 | } | |
2870 | default: | |
2871 | return DefaultOnArgument(macroId, arg_no, start); | |
9a29912f JS |
2872 | } |
2873 | return TRUE; | |
2874 | } | |
2875 | ||
2876 | bool HTMLGo(void) | |
2877 | { | |
2878 | fileId = 0; | |
2879 | inVerbatim = FALSE; | |
2880 | indentLevel = 0; | |
2881 | inTabular = FALSE; | |
2882 | startRows = FALSE; | |
2883 | tableVerticalLineLeft = FALSE; | |
2884 | tableVerticalLineRight = FALSE; | |
2885 | noColumns = 0; | |
2886 | ||
2887 | if (InputFile && OutputFile) | |
2888 | { | |
2889 | // Do some HTML-specific transformations on all the strings, | |
2890 | // recursively | |
2891 | Text2HTML(GetTopLevelChunk()); | |
2892 | ||
6c155d33 | 2893 | wxChar buf[300]; |
9a29912f | 2894 | if (truncateFilenames) |
6c155d33 | 2895 | wxSprintf(buf, _T("%s.htm"), FileRoot); |
9a29912f | 2896 | else |
6c155d33 | 2897 | wxSprintf(buf, _T("%s_contents.html"), FileRoot); |
9a29912f JS |
2898 | if (TitlepageName) delete[] TitlepageName; |
2899 | TitlepageName = copystring(buf); | |
6c155d33 | 2900 | Titlepage = wxFopen(buf, _T("w")); |
119f7a8c | 2901 | |
9a29912f | 2902 | if (truncateFilenames) |
6c155d33 | 2903 | wxSprintf(buf, _T("%s_fc.htm"), FileRoot); |
9a29912f | 2904 | else |
6c155d33 | 2905 | wxSprintf(buf, _T("%s_fcontents.html"), FileRoot); |
9a29912f JS |
2906 | |
2907 | contentsFrameName = copystring(buf); | |
2908 | ||
6c155d33 | 2909 | Contents = wxFopen(TmpContentsName, _T("w")); |
9a29912f JS |
2910 | |
2911 | if (htmlFrameContents) | |
2912 | { | |
6c155d33 JS |
2913 | // FrameContents = wxFopen(TmpFrameContentsName, _T("w")); |
2914 | FrameContents = wxFopen(contentsFrameName, _T("w")); | |
2915 | wxFprintf(FrameContents, _T("<HTML>\n<UL>\n")); | |
9a29912f JS |
2916 | } |
2917 | ||
2918 | if (!Titlepage || !Contents) | |
2919 | { | |
6c155d33 | 2920 | OnError(_T("Cannot open output file!")); |
9a29912f JS |
2921 | return FALSE; |
2922 | } | |
6c155d33 | 2923 | AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName), ContentsNameString); |
9a29912f | 2924 | |
6c155d33 | 2925 | wxFprintf(Contents, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString); |
9a29912f | 2926 | |
6c155d33 | 2927 | wxFprintf(Contents, _T("<UL>\n")); |
9a29912f JS |
2928 | |
2929 | SetCurrentOutput(Titlepage); | |
14204c7a | 2930 | if (htmlWorkshopFiles) HTMLWorkshopStartContents(); |
6c155d33 | 2931 | OnInform(_T("Converting...")); |
9a29912f JS |
2932 | |
2933 | TraverseDocument(); | |
6c155d33 | 2934 | wxFprintf(Contents, _T("</UL>\n\n")); |
9a29912f JS |
2935 | |
2936 | // SetCurrentOutput(Titlepage); | |
2937 | fclose(Titlepage); | |
2938 | ||
2939 | if (Contents) | |
2940 | { | |
6c155d33 | 2941 | // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n")); |
9a29912f JS |
2942 | fclose(Contents); |
2943 | Contents = NULL; | |
2944 | } | |
2945 | ||
2946 | if (FrameContents) | |
2947 | { | |
6c155d33 JS |
2948 | wxFprintf(FrameContents, _T("\n</UL>\n")); |
2949 | wxFprintf(FrameContents, _T("</HTML>\n")); | |
9a29912f JS |
2950 | fclose(FrameContents); |
2951 | FrameContents = NULL; | |
2952 | } | |
2953 | ||
2954 | if (Chapters) | |
2955 | { | |
6c155d33 | 2956 | wxFprintf(Chapters, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
2957 | fclose(Chapters); |
2958 | Chapters = NULL; | |
2959 | } | |
2960 | if (Sections) | |
2961 | { | |
6c155d33 | 2962 | wxFprintf(Sections, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
2963 | fclose(Sections); |
2964 | Sections = NULL; | |
2965 | } | |
2966 | if (Subsections && !combineSubSections) | |
2967 | { | |
6c155d33 | 2968 | wxFprintf(Subsections, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
2969 | fclose(Subsections); |
2970 | Subsections = NULL; | |
2971 | } | |
2972 | if (Subsubsections && !combineSubSections) | |
2973 | { | |
6c155d33 | 2974 | wxFprintf(Subsubsections, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
2975 | fclose(Subsubsections); |
2976 | Subsubsections = NULL; | |
2977 | } | |
2978 | if ( SectionContentsFD ) | |
2979 | { | |
2980 | fclose(SectionContentsFD); | |
2981 | SectionContentsFD = NULL; | |
2982 | } | |
2983 | ||
2984 | // Create a temporary file for the title page header, add some info, | |
2985 | // and concat the titlepage just generated. | |
2986 | // This is necessary in order to put the title of the document | |
2987 | // at the TOP of the file within <HEAD>, even though we only find out | |
2988 | // what it is later on. | |
6c155d33 | 2989 | FILE *tmpTitle = wxFopen(_T("title.tmp"), _T("w")); |
9a29912f JS |
2990 | if (tmpTitle) |
2991 | { | |
2992 | if (DocumentTitle) | |
2993 | { | |
2994 | SetCurrentOutput(tmpTitle); | |
6d8b260c | 2995 | HTMLHead(); |
6c155d33 | 2996 | TexOutput(_T("\n<HEAD><TITLE>")); |
9a29912f | 2997 | TraverseChildrenFromChunk(DocumentTitle); |
6c155d33 | 2998 | TexOutput(_T("</TITLE></HEAD>\n")); |
9a29912f JS |
2999 | } |
3000 | else | |
3001 | { | |
3002 | SetCurrentOutput(tmpTitle); | |
6d8b260c | 3003 | HTMLHeadTo(tmpTitle); |
9a29912f | 3004 | if (contentsString) |
6c155d33 | 3005 | wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString); |
9a29912f | 3006 | else |
6c155d33 | 3007 | wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot)); |
9a29912f | 3008 | } |
119f7a8c | 3009 | |
9a29912f JS |
3010 | // Output frame information |
3011 | if (htmlFrameContents) | |
3012 | { | |
6c155d33 | 3013 | wxChar firstFileName[300]; |
9a29912f | 3014 | if (truncateFilenames) |
6c155d33 | 3015 | wxSprintf(firstFileName, _T("%s1.htm"), FileRoot); |
9a29912f | 3016 | else |
66828481 | 3017 | wxStrcpy(firstFileName, gs_filenames[1].c_str()); |
9a29912f | 3018 | |
6c155d33 | 3019 | wxFprintf(tmpTitle, _T("<FRAMESET COLS=\"30%%,70%%\">\n")); |
9a29912f | 3020 | |
6c155d33 JS |
3021 | wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName))); |
3022 | wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName))); | |
3023 | wxFprintf(tmpTitle, _T("</FRAMESET>\n")); | |
119f7a8c | 3024 | |
6c155d33 | 3025 | wxFprintf(tmpTitle, _T("<NOFRAMES>\n")); |
9a29912f JS |
3026 | } |
3027 | ||
3028 | // Output <BODY...> to temporary title page | |
3029 | OutputBodyStart(); | |
119f7a8c | 3030 | |
9a29912f | 3031 | // Concat titlepage |
6c155d33 | 3032 | FILE *fd = wxFopen(TitlepageName, _T("r")); |
9a29912f JS |
3033 | if (fd) |
3034 | { | |
3035 | int ch = getc(fd); | |
3036 | while (ch != EOF) | |
3037 | { | |
3038 | putc(ch, tmpTitle); | |
3039 | ch = getc(fd); | |
3040 | } | |
3041 | fclose(fd); | |
3042 | } | |
3043 | ||
6c155d33 | 3044 | wxFprintf(tmpTitle, _T("\n</FONT></BODY>\n")); |
9a29912f JS |
3045 | |
3046 | if (htmlFrameContents) | |
3047 | { | |
6c155d33 | 3048 | wxFprintf(tmpTitle, _T("\n</NOFRAMES>\n")); |
9a29912f | 3049 | } |
6c155d33 | 3050 | wxFprintf(tmpTitle, _T("\n</HTML>\n")); |
9a29912f JS |
3051 | |
3052 | fclose(tmpTitle); | |
2b5f62a0 | 3053 | if (wxFileExists(TitlepageName)) wxRemoveFile(TitlepageName); |
6c155d33 | 3054 | if (!wxRenameFile(_T("title.tmp"), TitlepageName)) |
9a29912f | 3055 | { |
6c155d33 JS |
3056 | wxCopyFile(_T("title.tmp"), TitlepageName); |
3057 | wxRemoveFile(_T("title.tmp")); | |
9a29912f JS |
3058 | } |
3059 | } | |
3060 | ||
3061 | if (lastFileName) delete[] lastFileName; | |
3062 | lastFileName = NULL; | |
3063 | if (lastTopic) delete[] lastTopic; | |
3064 | lastTopic = NULL; | |
3065 | ||
2b5f62a0 | 3066 | if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName); |
9a29912f JS |
3067 | |
3068 | if (!wxRenameFile(TmpContentsName, ContentsName)) | |
3069 | { | |
3070 | wxCopyFile(TmpContentsName, ContentsName); | |
3071 | wxRemoveFile(TmpContentsName); | |
3072 | } | |
3073 | ||
3074 | // Generate .htx file if requested | |
3075 | if (htmlIndex) | |
3076 | { | |
6c155d33 JS |
3077 | wxChar htmlIndexName[300]; |
3078 | wxSprintf(htmlIndexName, _T("%s.htx"), FileRoot); | |
9a29912f JS |
3079 | GenerateHTMLIndexFile(htmlIndexName); |
3080 | } | |
3081 | ||
14204c7a VS |
3082 | // Generate HTML Help Workshop files if requested |
3083 | if (htmlWorkshopFiles) | |
3084 | { | |
3085 | HTMLWorkshopEndContents(); | |
3086 | GenerateHTMLWorkshopFiles(FileRoot); | |
3087 | } | |
3088 | ||
3089 | ||
9a29912f JS |
3090 | return TRUE; |
3091 | } | |
14204c7a | 3092 | |
9a29912f JS |
3093 | return FALSE; |
3094 | } | |
3095 | ||
3096 | // Output .htx index file | |
6c155d33 | 3097 | void GenerateHTMLIndexFile(wxChar *fname) |
9a29912f | 3098 | { |
6c155d33 | 3099 | FILE *fd = wxFopen(fname, _T("w")); |
9a29912f JS |
3100 | if (!fd) |
3101 | return; | |
3102 | ||
3103 | TopicTable.BeginFind(); | |
6c155d33 JS |
3104 | wxNode *node = TopicTable.Next(); |
3105 | while (node) | |
9a29912f | 3106 | { |
ddc4f3b5 | 3107 | TexTopic *texTopic = (TexTopic *)node->GetData(); |
6c155d33 | 3108 | const wxChar *topicName = node->GetKeyString(); |
9a29912f JS |
3109 | if (texTopic->filename && texTopic->keywords) |
3110 | { | |
ddc4f3b5 | 3111 | wxStringListNode *node1 = texTopic->keywords->GetFirst(); |
9a29912f JS |
3112 | while (node1) |
3113 | { | |
6c155d33 JS |
3114 | wxChar *s = (wxChar *)node1->GetData(); |
3115 | wxFprintf(fd, _T("%s|%s|%s\n"), topicName, texTopic->filename, s); | |
ddc4f3b5 | 3116 | node1 = node1->GetNext(); |
9a29912f JS |
3117 | } |
3118 | } | |
6c155d33 | 3119 | node = TopicTable.Next(); |
9a29912f JS |
3120 | } |
3121 | fclose(fd); | |
3122 | } | |
14204c7a VS |
3123 | |
3124 | ||
3125 | ||
3126 | ||
3127 | ||
3128 | ||
3129 | ||
3130 | // output .hpp, .hhc and .hhk files: | |
3131 | ||
3132 | ||
6c155d33 | 3133 | void GenerateHTMLWorkshopFiles(wxChar *fname) |
14204c7a VS |
3134 | { |
3135 | FILE *f; | |
6c155d33 | 3136 | wxChar buf[300]; |
14204c7a VS |
3137 | |
3138 | /* Generate project file : */ | |
3139 | ||
6c155d33 JS |
3140 | wxSprintf(buf, _T("%s.hhp"), fname); |
3141 | f = wxFopen(buf, _T("wt")); | |
3142 | wxFprintf(f, | |
3143 | _T("[OPTIONS]\n") | |
3144 | _T("Compatibility=1.1\n") | |
3145 | _T("Full-text search=Yes\n") | |
3146 | _T("Contents file=%s.hhc\n") | |
3147 | _T("Compiled file=%s.chm\n") | |
3148 | _T("Default Window=%sHelp\n") | |
3149 | _T("Default topic=%s\n") | |
3150 | _T("Index file=%s.hhk\n") | |
3151 | _T("Title="), | |
2b5f62a0 VZ |
3152 | wxFileNameFromPath(fname), |
3153 | wxFileNameFromPath(fname), | |
3154 | wxFileNameFromPath(fname), | |
3155 | wxFileNameFromPath(TitlepageName), | |
3156 | wxFileNameFromPath(fname) | |
14204c7a | 3157 | ); |
119f7a8c | 3158 | |
14204c7a VS |
3159 | if (DocumentTitle) { |
3160 | SetCurrentOutput(f); | |
3161 | TraverseChildrenFromChunk(DocumentTitle); | |
3162 | } | |
6c155d33 | 3163 | else wxFprintf(f, _T("(unknown)")); |
119f7a8c | 3164 | |
6c155d33 JS |
3165 | wxFprintf(f, _T("\n\n[WINDOWS]\n") |
3166 | _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"), | |
2b5f62a0 VZ |
3167 | wxFileNameFromPath(fname), |
3168 | wxFileNameFromPath(fname), | |
3169 | wxFileNameFromPath(fname), | |
3170 | wxFileNameFromPath(TitlepageName)); | |
119f7a8c RD |
3171 | |
3172 | ||
6c155d33 JS |
3173 | wxFprintf(f, _T("\n\n[FILES]\n")); |
3174 | wxFprintf(f, _T("%s\n"), wxFileNameFromPath(TitlepageName)); | |
119f7a8c | 3175 | for (int i = 1; i <= fileId; i++) { |
14204c7a | 3176 | if (truncateFilenames) |
6c155d33 | 3177 | wxSprintf(buf, _T("%s%d.htm"), wxFileNameFromPath(FileRoot), i); |
14204c7a | 3178 | else |
66828481 | 3179 | wxStrcpy(buf, wxFileNameFromPath(gs_filenames[i].c_str())); |
6c155d33 | 3180 | wxFprintf(f, _T("%s\n"), buf); |
14204c7a VS |
3181 | } |
3182 | fclose(f); | |
3183 | ||
3184 | /* Generate index file : */ | |
3185 | ||
6c155d33 JS |
3186 | wxSprintf(buf, _T("%s.hhk"), fname); |
3187 | f = wxFopen(buf, _T("wt")); | |
14204c7a | 3188 | |
6c155d33 JS |
3189 | wxFprintf(f, |
3190 | _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n") | |
3191 | _T("<HTML>\n")); | |
6d8b260c | 3192 | HTMLHeadTo(f); |
6c155d33 JS |
3193 | wxFprintf(f, |
3194 | _T("\n") | |
3195 | _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n") | |
3196 | _T("<!-- Sitemap 1.0 -->\n") | |
3197 | _T("</HEAD><BODY>\n") | |
3198 | _T("<OBJECT type=\"text/site properties\">\n") | |
3199 | _T(" <param name=\"ImageType\" value=\"Folder\">\n") | |
3200 | _T("</OBJECT>\n") | |
3201 | _T("<UL>\n")); | |
14204c7a VS |
3202 | |
3203 | TopicTable.BeginFind(); | |
6c155d33 JS |
3204 | wxNode *node = TopicTable.Next(); |
3205 | while (node) | |
14204c7a | 3206 | { |
ddc4f3b5 | 3207 | TexTopic *texTopic = (TexTopic *)node->GetData(); |
6c155d33 | 3208 | const wxChar *topicName = node->GetKeyString(); |
14204c7a VS |
3209 | if (texTopic->filename && texTopic->keywords) |
3210 | { | |
ddc4f3b5 | 3211 | wxStringListNode *node1 = texTopic->keywords->GetFirst(); |
14204c7a VS |
3212 | while (node1) |
3213 | { | |
6c155d33 JS |
3214 | wxChar *s = (wxChar *)node1->GetData(); |
3215 | wxFprintf(f, | |
3216 | _T(" <LI> <OBJECT type=\"text/sitemap\">\n") | |
3217 | _T(" <param name=\"Local\" value=\"%s#%s\">\n") | |
3218 | _T(" <param name=\"Name\" value=\"%s\">\n") | |
3219 | _T(" </OBJECT>\n"), | |
14204c7a | 3220 | texTopic->filename, topicName, s); |
ddc4f3b5 | 3221 | node1 = node1->GetNext(); |
14204c7a VS |
3222 | } |
3223 | } | |
6c155d33 | 3224 | node = TopicTable.Next(); |
14204c7a | 3225 | } |
119f7a8c | 3226 | |
6c155d33 | 3227 | wxFprintf(f, _T("</UL>\n")); |
14204c7a VS |
3228 | fclose(f); |
3229 | } | |
3230 | ||
3231 | ||
3232 | ||
3233 | static FILE *HTMLWorkshopContents = NULL; | |
3234 | static int HTMLWorkshopLastLevel = 0; | |
3235 | ||
6c155d33 | 3236 | void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file) |
14204c7a VS |
3237 | { |
3238 | int i; | |
3239 | ||
3240 | if (level > HTMLWorkshopLastLevel) | |
3241 | for (i = HTMLWorkshopLastLevel; i < level; i++) | |
6c155d33 | 3242 | wxFprintf(HTMLWorkshopContents, _T("<UL>")); |
14204c7a VS |
3243 | if (level < HTMLWorkshopLastLevel) |
3244 | for (i = level; i < HTMLWorkshopLastLevel; i++) | |
6c155d33 | 3245 | wxFprintf(HTMLWorkshopContents, _T("</UL>")); |
119f7a8c | 3246 | |
14204c7a | 3247 | SetCurrentOutput(HTMLWorkshopContents); |
6c155d33 JS |
3248 | wxFprintf(HTMLWorkshopContents, |
3249 | _T(" <LI> <OBJECT type=\"text/sitemap\">\n") | |
3250 | _T(" <param name=\"Local\" value=\"%s#%s\">\n") | |
3251 | _T(" <param name=\"Name\" value=\""), | |
14204c7a VS |
3252 | file, s); |
3253 | OutputCurrentSection(); | |
6c155d33 JS |
3254 | wxFprintf(HTMLWorkshopContents, |
3255 | _T("\">\n") | |
3256 | _T(" </OBJECT>\n")); | |
14204c7a VS |
3257 | HTMLWorkshopLastLevel = level; |
3258 | } | |
3259 | ||
3260 | ||
3261 | void HTMLWorkshopStartContents() | |
3262 | { | |
6c155d33 JS |
3263 | wxChar buf[300]; |
3264 | wxSprintf(buf, _T("%s.hhc"), FileRoot); | |
3265 | HTMLWorkshopContents = wxFopen(buf, _T("wt")); | |
14204c7a VS |
3266 | HTMLWorkshopLastLevel = 0; |
3267 | ||
6c155d33 JS |
3268 | wxFprintf(HTMLWorkshopContents, |
3269 | _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n") | |
3270 | _T("<HTML>\n")); | |
6d8b260c | 3271 | HTMLHeadTo(HTMLWorkshopContents); |
6c155d33 JS |
3272 | wxFprintf(HTMLWorkshopContents, |
3273 | _T("\n") | |
3274 | _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n") | |
3275 | _T("<!-- Sitemap 1.0 -->\n") | |
3276 | _T("</HEAD><BODY>\n") | |
3277 | _T("<OBJECT type=\"text/site properties\">\n") | |
3278 | _T(" <param name=\"ImageType\" value=\"Folder\">\n") | |
3279 | _T("</OBJECT>\n") | |
3280 | _T("<UL>\n") | |
3281 | _T("<LI> <OBJECT type=\"text/sitemap\">\n") | |
3282 | _T("<param name=\"Local\" value=\"%s\">\n") | |
3283 | _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"), | |
2b5f62a0 | 3284 | wxFileNameFromPath(TitlepageName) |
119f7a8c RD |
3285 | ); |
3286 | ||
14204c7a VS |
3287 | } |
3288 | ||
3289 | ||
3290 | void HTMLWorkshopEndContents() | |
3291 | { | |
3292 | for (int i = HTMLWorkshopLastLevel; i >= 0; i--) | |
6c155d33 | 3293 | wxFprintf(HTMLWorkshopContents, _T("</UL>\n")); |
14204c7a VS |
3294 | fclose(HTMLWorkshopContents); |
3295 | } |