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