]>
Commit | Line | Data |
---|---|---|
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 |
34 | static inline wxChar* copystring(const wxChar* s) | |
35 | { return wxStrcpy(new wxChar[wxStrlen(s) + 1], s); } | |
36 | #endif | |
3924dd22 GT |
37 | |
38 | extern wxHashTable TexReferences; | |
39 | ||
40 | ||
6c155d33 JS |
41 | extern void DecToHex(int, wxChar *); |
42 | void GenerateHTMLIndexFile(wxChar *fname); | |
14204c7a | 43 | |
6c155d33 JS |
44 | void GenerateHTMLWorkshopFiles(wxChar *fname); |
45 | void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file); | |
14204c7a VS |
46 | void HTMLWorkshopStartContents(); |
47 | void HTMLWorkshopEndContents(); | |
48 | ||
9a29912f JS |
49 | void OutputContentsFrame(void); |
50 | ||
51 | #include "readshg.h" // Segmented hypergraphics parsing | |
52 | ||
6c155d33 JS |
53 | wxChar *ChaptersName = NULL; |
54 | wxChar *SectionsName = NULL; | |
55 | wxChar *SubsectionsName = NULL; | |
56 | wxChar *SubsubsectionsName = NULL; | |
57 | wxChar *TitlepageName = NULL; | |
58 | wxChar *lastFileName = NULL; | |
59 | wxChar *lastTopic = NULL; | |
60 | wxChar *currentFileName = NULL; | |
61 | wxChar *contentsFrameName = NULL; | |
9a29912f JS |
62 | |
63 | static TexChunk *descriptionItemArg = NULL; | |
64 | static TexChunk *helpRefFilename = NULL; | |
65 | static TexChunk *helpRefText = NULL; | |
66 | static int indentLevel = 0; | |
67 | static int citeCount = 1; | |
68 | extern FILE *Contents; | |
69 | FILE *FrameContents = NULL; | |
70 | FILE *Titlepage = NULL; | |
71 | // FILE *FrameTitlepage = NULL; | |
72 | int fileId = 0; | |
b63b07a8 | 73 | bool subsectionStarted = false; |
9a29912f JS |
74 | |
75 | // Which column of a row are we in? (Assumes no nested tables, of course) | |
76 | int currentColumn = 0; | |
77 | ||
78 | // Are we in verbatim mode? If so, format differently. | |
b63b07a8 | 79 | static 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 |
83 | static bool inFigure = false; |
84 | static bool inTable = false; | |
9a29912f JS |
85 | |
86 | // This is defined in the Tex2Any library. | |
6c155d33 | 87 | extern wxChar *BigBuffer; |
9a29912f | 88 | |
c103ca4b JS |
89 | // DHS Two-column table dimensions. |
90 | static int TwoColWidthA = -1; | |
91 | static int TwoColWidthB = -1; | |
92 | ||
93 | ||
9a29912f JS |
94 | class 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 | ||
106 | class 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 | ||
123 | wxHashTable TexNextPages(wxKEY_STRING); | |
124 | ||
6c155d33 JS |
125 | static wxChar *CurrentChapterName = NULL; |
126 | static wxChar *CurrentChapterFile = NULL; | |
127 | static wxChar *CurrentSectionName = NULL; | |
128 | static wxChar *CurrentSectionFile = NULL; | |
129 | static wxChar *CurrentSubsectionName = NULL; | |
130 | static wxChar *CurrentSubsectionFile = NULL; | |
131 | static wxChar *CurrentSubsubsectionName = NULL; | |
132 | static wxChar *CurrentSubsubsectionFile = NULL; | |
133 | static wxChar *CurrentTopic = NULL; | |
134 | ||
135 | static void SetCurrentTopic(wxChar *s) | |
9a29912f JS |
136 | { |
137 | if (CurrentTopic) delete[] CurrentTopic; | |
138 | CurrentTopic = copystring(s); | |
139 | } | |
140 | ||
6c155d33 | 141 | void 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 | 152 | void 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 | 162 | void 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 | 171 | void 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: | |
183 | static wxArrayString gs_filenames; | |
184 | ||
185 | ||
9a29912f JS |
186 | /* |
187 | * Close former filedescriptor and reopen using another filename. | |
188 | * | |
189 | */ | |
190 | ||
66828481 | 191 | void 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 | 222 | static wxChar *SectionContentsFilename = NULL; |
9a29912f JS |
223 | static FILE *SectionContentsFD = NULL; |
224 | ||
225 | void 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 |
256 | void 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 < | |
289 | { | |
290 | BigBuffer[ptr] = 0; | |
6c155d33 | 291 | wxStrcat(BigBuffer, _T("<")); |
9a29912f JS |
292 | ptr += 4; |
293 | i += 1; | |
b63b07a8 | 294 | changed = true; |
9a29912f JS |
295 | } |
296 | else if (ch == '>') // Change > to > | |
297 | { | |
298 | BigBuffer[ptr] = 0; | |
6c155d33 | 299 | wxStrcat(BigBuffer, _T(">")); |
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 |
328 | void 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 |
384 | void 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("<<"); |
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(">>"); |
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 | 583 | wxChar *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 |
626 | void 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 |
641 | void 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 |
701 | void 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 | ||
711 | void 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 |
720 | void 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 | { | |
af318c88 JS |
877 | fflush(Sections); |
878 | ||
9a29912f | 879 | // Read old .con file in at this point |
6c155d33 JS |
880 | wxChar buf[256]; |
881 | wxStrcpy(buf, CurrentSectionFile); | |
9a29912f | 882 | wxStripExtension(buf); |
6c155d33 JS |
883 | wxStrcat(buf, _T(".con")); |
884 | FILE *fd = wxFopen(buf, _T("r")); | |
9a29912f JS |
885 | if ( fd ) |
886 | { | |
887 | int ch = getc(fd); | |
888 | while (ch != EOF) | |
889 | { | |
7f997541 | 890 | wxPutc(ch, Sections); |
9a29912f JS |
891 | ch = getc(fd); |
892 | } | |
893 | fclose(fd); | |
894 | } | |
6c155d33 | 895 | wxFprintf(Sections, _T("<P>\n")); |
9a29912f JS |
896 | |
897 | // Close old file, create a new file for the sub(sub)section contents entries | |
898 | ReopenSectionContentsFile(); | |
899 | } | |
900 | ||
b63b07a8 RL |
901 | startedSections = true; |
902 | subsectionStarted = true; | |
9a29912f | 903 | |
6c155d33 | 904 | wxChar *topicName = FindTopicName(GetNextChunk()); |
9a29912f JS |
905 | |
906 | if ( !combineSubSections ) | |
907 | { | |
908 | SetCurrentOutput(NULL); | |
66828481 | 909 | ReopenFile(&Subsections, &SubsectionsName, topicName); |
9a29912f JS |
910 | AddTexRef(topicName, SubsectionsName, SubsectionNameString); |
911 | SetCurrentSubsectionName(topicName, SubsectionsName); | |
14204c7a | 912 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SubsectionsName); |
9a29912f JS |
913 | SetCurrentOutput(Subsections); |
914 | ||
4fe30bce | 915 | HTMLHead(); |
6c155d33 | 916 | TexOutput(_T("<title>")); |
9a29912f | 917 | OutputCurrentSection(); |
6c155d33 | 918 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
919 | OutputBodyStart(); |
920 | ||
6c155d33 | 921 | wxFprintf(Subsections, _T("<A NAME=\"%s\"></A>"), topicName); |
9a29912f JS |
922 | AddBrowseButtons(CurrentSectionName, CurrentSectionFile, // Up |
923 | lastTopic, lastFileName, // Last topic | |
924 | topicName, SubsectionsName); // This topic | |
925 | ||
926 | SetCurrentOutputs(Sections, Subsections); | |
6c155d33 | 927 | wxFprintf(Sections, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsectionsName), topicName); |
9a29912f | 928 | |
6c155d33 | 929 | wxFprintf(Subsections, _T("\n<H3>")); |
9a29912f | 930 | OutputCurrentSection(); |
6c155d33 JS |
931 | wxFprintf(Sections, _T("</B></A><BR>\n")); |
932 | wxFprintf(Subsections, _T("</H3>\n")); | |
9a29912f JS |
933 | |
934 | SetCurrentOutput(Subsections); | |
935 | } | |
936 | else | |
937 | { | |
938 | AddTexRef(topicName, SectionsName, SubsectionNameString); | |
939 | SetCurrentSubsectionName(topicName, SectionsName); | |
14204c7a | 940 | |
9a29912f | 941 | // if ( subsectionNo != 0 ) |
6c155d33 | 942 | wxFprintf(Sections, _T("\n<HR>\n")); |
9a29912f JS |
943 | |
944 | // We're putting everything into the section file | |
6c155d33 JS |
945 | wxFprintf(Sections, _T("<A NAME=\"%s\"></A>"), topicName); |
946 | wxFprintf(Sections, _T("\n<H3>")); | |
9a29912f | 947 | OutputCurrentSection(); |
6c155d33 | 948 | wxFprintf(Sections, _T("</H3>\n")); |
9a29912f JS |
949 | |
950 | SetCurrentOutput(SectionContentsFD); | |
6c155d33 | 951 | wxFprintf(SectionContentsFD, _T("<A HREF=\"#%s\">"), topicName); |
9a29912f | 952 | OutputCurrentSection(); |
6c155d33 | 953 | TexOutput(_T("</A><BR>\n")); |
9a29912f | 954 | |
14204c7a | 955 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); |
9a29912f JS |
956 | SetCurrentOutput(Sections); |
957 | } | |
958 | // Add this section title to the list of keywords | |
959 | if (htmlIndex) | |
960 | { | |
aed3314d JS |
961 | OutputCurrentSectionToString(wxTex2RTFBuffer); |
962 | AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); | |
9a29912f JS |
963 | } |
964 | ||
965 | } | |
966 | } | |
967 | break; | |
968 | } | |
969 | case ltSUBSUBSECTION: | |
970 | case ltSUBSUBSECTIONSTAR: | |
971 | { | |
972 | if (!start) | |
973 | { | |
974 | if (!Subsections && !combineSubSections) | |
975 | { | |
6c155d33 | 976 | OnError(_T("You cannot have a subsubsection before a subsection!")); |
9a29912f JS |
977 | } |
978 | else | |
979 | { | |
980 | if (macroId != ltSUBSUBSECTIONSTAR) | |
981 | subsubsectionNo ++; | |
982 | ||
b63b07a8 | 983 | startedSections = true; |
9a29912f | 984 | |
6c155d33 | 985 | wxChar *topicName = FindTopicName(GetNextChunk()); |
9a29912f JS |
986 | |
987 | if ( !combineSubSections ) | |
988 | { | |
989 | SetCurrentOutput(NULL); | |
66828481 | 990 | ReopenFile(&Subsubsections, &SubsubsectionsName, topicName); |
9a29912f JS |
991 | AddTexRef(topicName, SubsubsectionsName, SubsubsectionNameString); |
992 | SetCurrentSubsubsectionName(topicName, SubsubsectionsName); | |
14204c7a | 993 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(3, topicName, SubsubsectionsName); |
9a29912f JS |
994 | |
995 | SetCurrentOutput(Subsubsections); | |
4fe30bce | 996 | HTMLHead(); |
6c155d33 | 997 | TexOutput(_T("<title>")); |
9a29912f | 998 | OutputCurrentSection(); |
6c155d33 | 999 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
1000 | OutputBodyStart(); |
1001 | ||
6c155d33 | 1002 | wxFprintf(Subsubsections, _T("<A NAME=\"%s\"></A>"), topicName); |
9a29912f JS |
1003 | |
1004 | AddBrowseButtons(CurrentSubsectionName, CurrentSubsectionFile, // Up | |
1005 | lastTopic, lastFileName, // Last topic | |
1006 | topicName, SubsubsectionsName); // This topic | |
1007 | ||
1008 | SetCurrentOutputs(Subsections, Subsubsections); | |
6c155d33 | 1009 | wxFprintf(Subsections, _T("\n<A HREF=\"%s#%s\"><B>"), ConvertCase(SubsubsectionsName), topicName); |
9a29912f | 1010 | |
6c155d33 | 1011 | wxFprintf(Subsubsections, _T("\n<H3>")); |
9a29912f | 1012 | OutputCurrentSection(); |
6c155d33 JS |
1013 | wxFprintf(Subsections, _T("</B></A><BR>\n")); |
1014 | wxFprintf(Subsubsections, _T("</H3>\n")); | |
9a29912f JS |
1015 | } |
1016 | else | |
1017 | { | |
1018 | AddTexRef(topicName, SectionsName, SubsubsectionNameString); | |
1019 | SetCurrentSubsectionName(topicName, SectionsName); | |
6c155d33 | 1020 | wxFprintf(Sections, _T("\n<HR>\n")); |
9a29912f JS |
1021 | |
1022 | // We're putting everything into the section file | |
6c155d33 JS |
1023 | wxFprintf(Sections, _T("<A NAME=\"%s\"></A>"), topicName); |
1024 | wxFprintf(Sections, _T("\n<H3>")); | |
9a29912f | 1025 | OutputCurrentSection(); |
6c155d33 | 1026 | wxFprintf(Sections, _T("</H3>\n")); |
9a29912f JS |
1027 | /* TODO: where do we put subsubsection contents entry - indented, with subsection entries? |
1028 | SetCurrentOutput(SectionContentsFD); | |
6c155d33 | 1029 | wxFprintf(SectionContentsFD, "<A HREF=\"#%s\">", topicName); |
9a29912f | 1030 | OutputCurrentSection(); |
6c155d33 | 1031 | TexOutput(_T("</A><BR>")); |
9a29912f | 1032 | */ |
119f7a8c | 1033 | if (htmlWorkshopFiles) HTMLWorkshopAddToContents(2, topicName, SectionsName); |
9a29912f JS |
1034 | SetCurrentOutput(Sections); |
1035 | } | |
1036 | ||
1037 | // Add this section title to the list of keywords | |
1038 | if (htmlIndex) | |
1039 | { | |
aed3314d JS |
1040 | OutputCurrentSectionToString(wxTex2RTFBuffer); |
1041 | AddKeyWordForTopic(topicName, wxTex2RTFBuffer, currentFileName); | |
9a29912f JS |
1042 | } |
1043 | } | |
1044 | } | |
1045 | break; | |
1046 | } | |
1047 | case ltFUNC: | |
1048 | case ltPFUNC: | |
1049 | { | |
1050 | if ( !combineSubSections ) | |
1051 | SetCurrentOutput(Subsections); | |
1052 | else | |
1053 | SetCurrentOutput(Sections); | |
1054 | if (start) | |
1055 | { | |
1056 | } | |
1057 | else | |
1058 | { | |
1059 | } | |
1060 | break; | |
1061 | } | |
1062 | case ltCLIPSFUNC: | |
1063 | { | |
1064 | if ( !combineSubSections ) | |
1065 | SetCurrentOutput(Subsections); | |
1066 | else | |
1067 | SetCurrentOutput(Sections); | |
1068 | if (start) | |
1069 | { | |
1070 | } | |
1071 | else | |
1072 | { | |
1073 | } | |
1074 | break; | |
1075 | } | |
1076 | case ltMEMBER: | |
1077 | { | |
1078 | if ( !combineSubSections ) | |
1079 | SetCurrentOutput(Subsections); | |
1080 | else | |
1081 | SetCurrentOutput(Sections); | |
1082 | if (start) | |
1083 | { | |
1084 | } | |
1085 | else | |
1086 | { | |
1087 | } | |
1088 | break; | |
1089 | } | |
1090 | case ltVOID: | |
1091 | // if (start) | |
6c155d33 | 1092 | // TexOutput(_T("<B>void</B>")); |
9a29912f JS |
1093 | break; |
1094 | case ltHARDY: | |
1095 | if (start) | |
6c155d33 | 1096 | TexOutput(_T("HARDY")); |
9a29912f JS |
1097 | break; |
1098 | case ltWXCLIPS: | |
1099 | if (start) | |
6c155d33 | 1100 | TexOutput(_T("wxCLIPS")); |
9a29912f JS |
1101 | break; |
1102 | case ltAMPERSAND: | |
1103 | if (start) | |
6c155d33 | 1104 | TexOutput(_T("&")); |
9a29912f JS |
1105 | break; |
1106 | case ltSPECIALAMPERSAND: | |
1107 | { | |
1108 | if (start) | |
1109 | { | |
1110 | if (inTabular) | |
1111 | { | |
1112 | // End cell, start cell | |
d7d17624 | 1113 | |
6c155d33 | 1114 | TexOutput(_T("</FONT></TD>")); |
119f7a8c | 1115 | |
9a29912f JS |
1116 | // Start new row and cell, setting alignment for the first cell. |
1117 | if (currentColumn < noColumns) | |
1118 | currentColumn ++; | |
1119 | ||
6c155d33 | 1120 | wxChar buf[100]; |
9a29912f | 1121 | if (TableData[currentColumn].justification == 'c') |
b63b07a8 | 1122 | wxSnprintf(buf, sizeof(buf), _T("\n<TD ALIGN=CENTER>")); |
9a29912f | 1123 | else if (TableData[currentColumn].justification == 'r') |
b63b07a8 | 1124 | wxSnprintf(buf, sizeof(buf), _T("\n<TD ALIGN=RIGHT>")); |
9a29912f JS |
1125 | else if (TableData[currentColumn].absWidth) |
1126 | { | |
1127 | // Convert from points * 20 into pixels. | |
1128 | int points = TableData[currentColumn].width / 20; | |
119f7a8c | 1129 | |
9a29912f JS |
1130 | // Say the display is 100 DPI (dots/pixels per inch). |
1131 | // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. | |
1132 | int pixels = (int)(points * 100.0 / 72.0); | |
b63b07a8 | 1133 | wxSnprintf(buf, sizeof(buf), _T("<TD ALIGN=CENTER WIDTH=%d>"), pixels); |
9a29912f JS |
1134 | } |
1135 | else | |
b63b07a8 | 1136 | wxSnprintf(buf, sizeof(buf), _T("\n<TD ALIGN=LEFT>")); |
9a29912f | 1137 | TexOutput(buf); |
4fe30bce | 1138 | OutputFont(); |
9a29912f JS |
1139 | } |
1140 | else | |
6c155d33 | 1141 | TexOutput(_T("&")); |
9a29912f JS |
1142 | } |
1143 | break; | |
1144 | } | |
1145 | case ltBACKSLASHCHAR: | |
1146 | { | |
1147 | if (start) | |
1148 | { | |
1149 | if (inTabular) | |
1150 | { | |
1151 | // End row. In fact, tables without use of \row or \ruledrow isn't supported for | |
1152 | // HTML: the syntax is too different (e.g. how do we know where to put the first </TH> | |
1153 | // if we've ended the last row?). So normally you wouldn't use \\ to end a row. | |
6c155d33 | 1154 | TexOutput(_T("</TR>\n")); |
9a29912f JS |
1155 | } |
1156 | else | |
6c155d33 | 1157 | TexOutput(_T("<BR>\n")); |
9a29912f JS |
1158 | } |
1159 | break; | |
1160 | } | |
1161 | case ltROW: | |
1162 | case ltRULEDROW: | |
1163 | { | |
1164 | if (start) | |
1165 | { | |
1166 | currentColumn = 0; | |
119f7a8c | 1167 | |
9a29912f | 1168 | // Start new row and cell, setting alignment for the first cell. |
6c155d33 | 1169 | wxChar buf[100]; |
9a29912f | 1170 | if (TableData[currentColumn].justification == 'c') |
b63b07a8 | 1171 | wxSnprintf(buf, sizeof(buf), _T("<TR>\n<TD ALIGN=CENTER>")); |
9a29912f | 1172 | else if (TableData[currentColumn].justification == 'r') |
b63b07a8 | 1173 | wxSnprintf(buf, sizeof(buf), _T("<TR>\n<TD ALIGN=RIGHT>")); |
9a29912f JS |
1174 | else if (TableData[currentColumn].absWidth) |
1175 | { | |
1176 | // Convert from points * 20 into pixels. | |
1177 | int points = TableData[currentColumn].width / 20; | |
119f7a8c | 1178 | |
9a29912f JS |
1179 | // Say the display is 100 DPI (dots/pixels per inch). |
1180 | // There are 72 pts to the inch. So 1pt = 1/72 inch, or 100 * 1/72 dots. | |
1181 | int pixels = (int)(points * 100.0 / 72.0); | |
b63b07a8 | 1182 | wxSnprintf(buf, sizeof(buf), _T("<TR>\n<TD ALIGN=CENTER WIDTH=%d>"), pixels); |
9a29912f JS |
1183 | } |
1184 | else | |
b63b07a8 | 1185 | wxSnprintf(buf, sizeof(buf), _T("<TR>\n<TD ALIGN=LEFT>")); |
9a29912f | 1186 | TexOutput(buf); |
4fe30bce | 1187 | OutputFont(); |
9a29912f JS |
1188 | } |
1189 | else | |
1190 | { | |
1191 | // End cell and row | |
1192 | // Start new row and cell | |
6c155d33 | 1193 | TexOutput(_T("</FONT></TD>\n</TR>\n")); |
9a29912f JS |
1194 | } |
1195 | break; | |
1196 | } | |
1197 | // HTML-only: break until the end of the picture (both margins are clear). | |
1198 | case ltBRCLEAR: | |
1199 | { | |
1200 | if (start) | |
6c155d33 | 1201 | TexOutput(_T("<BR CLEAR=ALL>")); |
9a29912f JS |
1202 | break; |
1203 | } | |
1204 | case ltRTFSP: // Explicit space, RTF only | |
1205 | break; | |
1206 | case ltSPECIALTILDE: | |
1207 | { | |
1208 | if (start) | |
1209 | { | |
b63b07a8 | 1210 | #if (1) // if(inVerbatim) |
6c155d33 | 1211 | TexOutput(_T("~")); |
b63b07a8 | 1212 | #else |
6c155d33 | 1213 | TexOutput(_T(" ")); |
b63b07a8 | 1214 | #endif |
9a29912f JS |
1215 | } |
1216 | break; | |
1217 | } | |
1218 | case ltINDENTED : | |
1219 | { | |
1220 | if ( start ) | |
6c155d33 | 1221 | TexOutput(_T("<UL><UL>\n")); |
9a29912f | 1222 | else |
6c155d33 | 1223 | TexOutput(_T("</UL></UL>\n")); |
9a29912f JS |
1224 | break; |
1225 | } | |
1226 | case ltITEMIZE: | |
1227 | case ltENUMERATE: | |
1228 | case ltDESCRIPTION: | |
1229 | // case ltTWOCOLLIST: | |
1230 | { | |
1231 | if (start) | |
1232 | { | |
1233 | indentLevel ++; | |
1234 | ||
1235 | int listType; | |
1236 | if (macroId == ltENUMERATE) | |
1237 | listType = LATEX_ENUMERATE; | |
1238 | else if (macroId == ltITEMIZE) | |
1239 | listType = LATEX_ITEMIZE; | |
1240 | else | |
1241 | listType = LATEX_DESCRIPTION; | |
1242 | ||
1243 | itemizeStack.Insert(new ItemizeStruc(listType)); | |
1244 | switch (listType) | |
1245 | { | |
1246 | case LATEX_ITEMIZE: | |
6c155d33 | 1247 | TexOutput(_T("<UL>\n")); |
9a29912f JS |
1248 | break; |
1249 | case LATEX_ENUMERATE: | |
6c155d33 | 1250 | TexOutput(_T("<OL>\n")); |
9a29912f JS |
1251 | break; |
1252 | case LATEX_DESCRIPTION: | |
1253 | default: | |
6c155d33 | 1254 | TexOutput(_T("<DL>\n")); |
9a29912f JS |
1255 | break; |
1256 | } | |
1257 | } | |
1258 | else | |
1259 | { | |
1260 | indentLevel --; | |
ddc4f3b5 | 1261 | if (itemizeStack.GetFirst()) |
9a29912f | 1262 | { |
ddc4f3b5 | 1263 | ItemizeStruc *struc = (ItemizeStruc *)itemizeStack.GetFirst()->GetData(); |
9a29912f JS |
1264 | switch (struc->listType) |
1265 | { | |
1266 | case LATEX_ITEMIZE: | |
6c155d33 | 1267 | TexOutput(_T("</UL>\n")); |
9a29912f JS |
1268 | break; |
1269 | case LATEX_ENUMERATE: | |
6c155d33 | 1270 | TexOutput(_T("</OL>\n")); |
9a29912f JS |
1271 | break; |
1272 | case LATEX_DESCRIPTION: | |
1273 | default: | |
6c155d33 | 1274 | TexOutput(_T("</DL>\n")); |
9a29912f JS |
1275 | break; |
1276 | } | |
1277 | ||
1278 | delete struc; | |
ddc4f3b5 | 1279 | delete itemizeStack.GetFirst(); |
9a29912f JS |
1280 | } |
1281 | } | |
1282 | break; | |
1283 | } | |
1284 | case ltTWOCOLLIST : | |
1285 | { | |
1286 | if ( start ) | |
6c155d33 | 1287 | TexOutput(_T("\n<TABLE>\n")); |
c103ca4b | 1288 | else { |
6c155d33 | 1289 | TexOutput(_T("\n</TABLE>\n")); |
c103ca4b JS |
1290 | // DHS |
1291 | TwoColWidthA = -1; | |
1292 | TwoColWidthB = -1; | |
1293 | } | |
9a29912f JS |
1294 | break; |
1295 | } | |
1296 | case ltPAR: | |
1297 | { | |
1298 | if (start) | |
6c155d33 | 1299 | TexOutput(_T("<P>\n")); |
9a29912f JS |
1300 | break; |
1301 | } | |
1302 | /* For footnotes we need to output the text at the bottom of the page and | |
1303 | * insert a reference to it. Is it worth the trouble... | |
1304 | case ltFOOTNOTE: | |
1305 | case ltFOOTNOTEPOPUP: | |
1306 | { | |
1307 | if (start) | |
1308 | { | |
6c155d33 | 1309 | TexOutput(_T("<FN>")); |
9a29912f | 1310 | } |
6c155d33 | 1311 | else TexOutput(_T("</FN>")); |
9a29912f JS |
1312 | break; |
1313 | } | |
1314 | */ | |
1315 | case ltVERB: | |
1316 | { | |
1317 | if (start) | |
6c155d33 JS |
1318 | TexOutput(_T("<TT>")); |
1319 | else TexOutput(_T("</TT>")); | |
9a29912f JS |
1320 | break; |
1321 | } | |
1322 | case ltVERBATIM: | |
1323 | { | |
1324 | if (start) | |
1325 | { | |
6c155d33 | 1326 | wxChar buf[100]; |
b63b07a8 | 1327 | wxSnprintf(buf, sizeof(buf), _T("<PRE>\n")); |
9a29912f JS |
1328 | TexOutput(buf); |
1329 | } | |
6c155d33 | 1330 | else TexOutput(_T("</PRE>\n")); |
9a29912f JS |
1331 | break; |
1332 | } | |
1333 | case ltCENTERLINE: | |
1334 | case ltCENTER: | |
1335 | { | |
1336 | if (start) | |
1337 | { | |
6c155d33 | 1338 | TexOutput(_T("<CENTER>")); |
9a29912f | 1339 | } |
6c155d33 | 1340 | else TexOutput(_T("</CENTER>")); |
9a29912f JS |
1341 | break; |
1342 | } | |
1343 | case ltFLUSHLEFT: | |
1344 | { | |
1345 | /* | |
1346 | if (start) | |
1347 | { | |
6c155d33 | 1348 | TexOutput(_T("{\\ql ")); |
9a29912f | 1349 | } |
6c155d33 | 1350 | else TexOutput(_T("}\\par\\pard\n")); |
9a29912f JS |
1351 | */ |
1352 | break; | |
1353 | } | |
1354 | case ltFLUSHRIGHT: | |
1355 | { | |
1356 | /* | |
1357 | if (start) | |
1358 | { | |
6c155d33 | 1359 | TexOutput(_T("{\\qr ")); |
9a29912f | 1360 | } |
6c155d33 | 1361 | else TexOutput(_T("}\\par\\pard\n")); |
9a29912f JS |
1362 | */ |
1363 | break; | |
1364 | } | |
1365 | case ltSMALL: | |
1366 | { | |
1367 | if (start) | |
1368 | { | |
1369 | // Netscape extension | |
6c155d33 | 1370 | TexOutput(_T("<FONT SIZE=2>")); |
9a29912f | 1371 | } |
6c155d33 | 1372 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1373 | break; |
1374 | } | |
1375 | case ltTINY: | |
1376 | { | |
1377 | if (start) | |
1378 | { | |
1379 | // Netscape extension | |
6c155d33 | 1380 | TexOutput(_T("<FONT SIZE=1>")); |
9a29912f | 1381 | } |
6c155d33 | 1382 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1383 | break; |
1384 | } | |
1385 | case ltNORMALSIZE: | |
1386 | { | |
1387 | if (start) | |
1388 | { | |
1389 | // Netscape extension | |
6c155d33 | 1390 | TexOutput(_T("<FONT SIZE=3>")); |
9a29912f | 1391 | } |
6c155d33 | 1392 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1393 | break; |
1394 | } | |
1395 | case ltlarge: | |
1396 | { | |
1397 | if (start) | |
1398 | { | |
1399 | // Netscape extension | |
6c155d33 | 1400 | TexOutput(_T("<FONT SIZE=4>")); |
9a29912f | 1401 | } |
6c155d33 | 1402 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1403 | break; |
1404 | } | |
1405 | case ltLarge: | |
1406 | { | |
1407 | if (start) | |
1408 | { | |
1409 | // Netscape extension | |
6c155d33 | 1410 | TexOutput(_T("<FONT SIZE=5>")); |
9a29912f | 1411 | } |
6c155d33 | 1412 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1413 | break; |
1414 | } | |
1415 | case ltLARGE: | |
1416 | { | |
1417 | if (start) | |
1418 | { | |
1419 | // Netscape extension | |
6c155d33 | 1420 | TexOutput(_T("<FONT SIZE=6>")); |
9a29912f | 1421 | } |
6c155d33 | 1422 | else TexOutput(_T("</FONT>")); |
9a29912f JS |
1423 | break; |
1424 | } | |
1425 | case ltBFSERIES: | |
1426 | case ltTEXTBF: | |
1427 | case ltBF: | |
1428 | { | |
1429 | if (start) | |
1430 | { | |
6c155d33 | 1431 | TexOutput(_T("<B>")); |
9a29912f | 1432 | } |
6c155d33 | 1433 | else TexOutput(_T("</B>")); |
9a29912f JS |
1434 | break; |
1435 | } | |
1436 | case ltITSHAPE: | |
1437 | case ltTEXTIT: | |
1438 | case ltIT: | |
1439 | { | |
1440 | if (start) | |
1441 | { | |
6c155d33 | 1442 | TexOutput(_T("<I>")); |
9a29912f | 1443 | } |
6c155d33 | 1444 | else TexOutput(_T("</I>")); |
9a29912f JS |
1445 | break; |
1446 | } | |
1447 | case ltEMPH: | |
1448 | case ltEM: | |
1449 | { | |
1450 | if (start) | |
1451 | { | |
6c155d33 | 1452 | TexOutput(_T("<EM>")); |
9a29912f | 1453 | } |
6c155d33 | 1454 | else TexOutput(_T("</EM>")); |
9a29912f JS |
1455 | break; |
1456 | } | |
1457 | case ltUNDERLINE: | |
1458 | { | |
1459 | if (start) | |
1460 | { | |
6c155d33 | 1461 | TexOutput(_T("<UL>")); |
9a29912f | 1462 | } |
6c155d33 | 1463 | else TexOutput(_T("</UL>")); |
9a29912f JS |
1464 | break; |
1465 | } | |
1466 | case ltTTFAMILY: | |
1467 | case ltTEXTTT: | |
1468 | case ltTT: | |
1469 | { | |
1470 | if (start) | |
1471 | { | |
6c155d33 | 1472 | TexOutput(_T("<TT>")); |
9a29912f | 1473 | } |
6c155d33 | 1474 | else TexOutput(_T("</TT>")); |
9a29912f JS |
1475 | break; |
1476 | } | |
1477 | case ltCOPYRIGHT: | |
1478 | { | |
1479 | if (start) | |
b63b07a8 | 1480 | TexOutput(_T("©"), true); |
9a29912f JS |
1481 | break; |
1482 | } | |
1483 | case ltREGISTERED: | |
1484 | { | |
1485 | if (start) | |
b63b07a8 | 1486 | TexOutput(_T("®"), true); |
9a29912f JS |
1487 | break; |
1488 | } | |
1489 | // Arrows | |
1490 | case ltLEFTARROW: | |
1491 | { | |
6c155d33 | 1492 | if (start) TexOutput(_T("<--")); |
9a29912f JS |
1493 | break; |
1494 | } | |
1495 | case ltLEFTARROW2: | |
1496 | { | |
6c155d33 | 1497 | if (start) TexOutput(_T("<==")); |
9a29912f JS |
1498 | break; |
1499 | } | |
1500 | case ltRIGHTARROW: | |
1501 | { | |
6c155d33 | 1502 | if (start) TexOutput(_T("-->")); |
9a29912f JS |
1503 | break; |
1504 | } | |
1505 | case ltRIGHTARROW2: | |
1506 | { | |
6c155d33 | 1507 | if (start) TexOutput(_T("==>")); |
9a29912f JS |
1508 | break; |
1509 | } | |
1510 | case ltLEFTRIGHTARROW: | |
1511 | { | |
6c155d33 | 1512 | if (start) TexOutput(_T("<-->")); |
9a29912f JS |
1513 | break; |
1514 | } | |
1515 | case ltLEFTRIGHTARROW2: | |
1516 | { | |
6c155d33 | 1517 | if (start) TexOutput(_T("<==>")); |
9a29912f JS |
1518 | break; |
1519 | } | |
1520 | /* | |
1521 | case ltSC: | |
1522 | { | |
1523 | break; | |
1524 | } | |
1525 | */ | |
1526 | case ltITEM: | |
1527 | { | |
1528 | if (!start) | |
1529 | { | |
ddc4f3b5 | 1530 | wxNode *node = itemizeStack.GetFirst(); |
9a29912f JS |
1531 | if (node) |
1532 | { | |
ddc4f3b5 | 1533 | ItemizeStruc *struc = (ItemizeStruc *)node->GetData(); |
9a29912f JS |
1534 | struc->currentItem += 1; |
1535 | if (struc->listType == LATEX_DESCRIPTION) | |
1536 | { | |
1537 | if (descriptionItemArg) | |
1538 | { | |
6c155d33 | 1539 | TexOutput(_T("<DT> ")); |
9a29912f | 1540 | TraverseChildrenFromChunk(descriptionItemArg); |
6c155d33 | 1541 | TexOutput(_T("\n")); |
9a29912f JS |
1542 | descriptionItemArg = NULL; |
1543 | } | |
6c155d33 | 1544 | TexOutput(_T("<DD>")); |
9a29912f JS |
1545 | } |
1546 | else | |
6c155d33 | 1547 | TexOutput(_T("<LI>")); |
9a29912f JS |
1548 | } |
1549 | } | |
1550 | break; | |
1551 | } | |
1552 | case ltMAKETITLE: | |
1553 | { | |
1554 | if (start && DocumentTitle && DocumentAuthor) | |
1555 | { | |
1556 | // Add a special label for the contents page. | |
6c155d33 JS |
1557 | // TexOutput(_T("<CENTER>\n")); |
1558 | TexOutput(_T("<A NAME=\"contents\">")); | |
1559 | TexOutput(_T("<H2 ALIGN=CENTER>\n")); | |
9a29912f | 1560 | TraverseChildrenFromChunk(DocumentTitle); |
6c155d33 JS |
1561 | TexOutput(_T("</H2>")); |
1562 | TexOutput(_T("<P>")); | |
1563 | TexOutput(_T("</A>\n")); | |
1564 | TexOutput(_T("<P>\n\n")); | |
1565 | TexOutput(_T("<H3 ALIGN=CENTER>")); | |
9a29912f | 1566 | TraverseChildrenFromChunk(DocumentAuthor); |
6c155d33 | 1567 | TexOutput(_T("</H3><P>\n\n")); |
9a29912f JS |
1568 | if (DocumentDate) |
1569 | { | |
6c155d33 | 1570 | TexOutput(_T("<H3 ALIGN=CENTER>")); |
9a29912f | 1571 | TraverseChildrenFromChunk(DocumentDate); |
6c155d33 | 1572 | TexOutput(_T("</H3><P>\n\n")); |
9a29912f | 1573 | } |
6c155d33 JS |
1574 | // TexOutput(_T("\n</CENTER>\n")); |
1575 | TexOutput(_T("\n<P><HR><P>\n")); | |
9a29912f JS |
1576 | |
1577 | /* | |
1578 | // Now do optional frame contents page | |
1579 | if (htmlFrameContents && FrameContents) | |
1580 | { | |
1581 | SetCurrentOutput(FrameContents); | |
119f7a8c | 1582 | |
9a29912f | 1583 | // Add a special label for the contents page. |
6c155d33 JS |
1584 | TexOutput(_T("<CENTER>\n")); |
1585 | TexOutput(_T("<H3>\n")); | |
9a29912f | 1586 | TraverseChildrenFromChunk(DocumentTitle); |
6c155d33 JS |
1587 | TexOutput(_T("</H3>")); |
1588 | TexOutput(_T("<P>")); | |
1589 | TexOutput(_T("</A>\n")); | |
1590 | TexOutput(_T("<P>\n\n")); | |
1591 | TexOutput(_T("<H3>")); | |
9a29912f | 1592 | TraverseChildrenFromChunk(DocumentAuthor); |
6c155d33 | 1593 | TexOutput(_T("</H3><P>\n\n")); |
9a29912f JS |
1594 | if (DocumentDate) |
1595 | { | |
6c155d33 | 1596 | TexOutput(_T("<H4>")); |
9a29912f | 1597 | TraverseChildrenFromChunk(DocumentDate); |
6c155d33 | 1598 | TexOutput(_T("</H4><P>\n\n")); |
9a29912f | 1599 | } |
6c155d33 JS |
1600 | TexOutput(_T("\n</CENTER>\n")); |
1601 | TexOutput(_T("<P><HR><P>\n")); | |
119f7a8c | 1602 | |
9a29912f JS |
1603 | SetCurrentOutput(Titlepage); |
1604 | } | |
1605 | */ | |
1606 | } | |
1607 | break; | |
1608 | } | |
1609 | case ltHELPREF: | |
1610 | case ltHELPREFN: | |
1611 | case ltPOPREF: | |
1612 | case ltURLREF: | |
1613 | { | |
1614 | if (start) | |
1615 | { | |
1616 | helpRefFilename = NULL; | |
1617 | helpRefText = NULL; | |
1618 | } | |
1619 | break; | |
1620 | } | |
1621 | case ltBIBLIOGRAPHY: | |
1622 | { | |
1623 | if (start) | |
1624 | { | |
1625 | DefaultOnMacro(macroId, no_args, start); | |
1626 | } | |
1627 | else | |
1628 | { | |
1629 | DefaultOnMacro(macroId, no_args, start); | |
6c155d33 | 1630 | TexOutput(_T("</DL>\n")); |
9a29912f JS |
1631 | } |
1632 | break; | |
1633 | } | |
1634 | case ltHRULE: | |
1635 | { | |
1636 | if (start) | |
1637 | { | |
6c155d33 | 1638 | TexOutput(_T("<HR>\n")); |
9a29912f JS |
1639 | } |
1640 | break; | |
1641 | } | |
1642 | case ltRULE: | |
1643 | { | |
1644 | if (start) | |
1645 | { | |
6c155d33 | 1646 | TexOutput(_T("<HR>\n")); |
9a29912f JS |
1647 | } |
1648 | break; | |
1649 | } | |
1650 | case ltTABLEOFCONTENTS: | |
1651 | { | |
1652 | if (start) | |
1653 | { | |
af318c88 JS |
1654 | // NB: if this is uncommented, the table of contents |
1655 | // completely disappears. If left commented, it's in the wrong | |
1656 | // place. | |
1657 | //fflush(Titlepage); | |
1658 | ||
6c155d33 | 1659 | FILE *fd = wxFopen(ContentsName, _T("r")); |
9a29912f JS |
1660 | if (fd) |
1661 | { | |
1662 | int ch = getc(fd); | |
1663 | while (ch != EOF) | |
1664 | { | |
7f997541 | 1665 | wxPutc(ch, Titlepage); |
9a29912f JS |
1666 | ch = getc(fd); |
1667 | } | |
1668 | fclose(fd); | |
af318c88 | 1669 | fflush(Titlepage); |
9a29912f JS |
1670 | } |
1671 | else | |
1672 | { | |
6c155d33 JS |
1673 | TexOutput(_T("RUN TEX2RTF AGAIN FOR CONTENTS PAGE\n")); |
1674 | OnInform(_T("Run Tex2RTF again to include contents page.")); | |
9a29912f JS |
1675 | } |
1676 | } | |
1677 | break; | |
1678 | } | |
1679 | case ltLANGLEBRA: | |
1680 | { | |
1681 | if (start) | |
6c155d33 | 1682 | TexOutput(_T("<")); |
9a29912f JS |
1683 | break; |
1684 | } | |
1685 | case ltRANGLEBRA: | |
1686 | { | |
1687 | if (start) | |
6c155d33 | 1688 | TexOutput(_T(">")); |
9a29912f JS |
1689 | break; |
1690 | } | |
1691 | case ltQUOTE: | |
1692 | case ltQUOTATION: | |
1693 | { | |
1694 | if (start) | |
6c155d33 | 1695 | TexOutput(_T("<BLOCKQUOTE>")); |
9a29912f | 1696 | else |
6c155d33 | 1697 | TexOutput(_T("</BLOCKQUOTE>")); |
9a29912f JS |
1698 | break; |
1699 | } | |
1700 | case ltCAPTION: | |
1701 | case ltCAPTIONSTAR: | |
1702 | { | |
1703 | if (start) | |
1704 | { | |
1705 | if (inTabular) | |
6c155d33 | 1706 | TexOutput(_T("\n<CAPTION>")); |
9a29912f | 1707 | |
6c155d33 | 1708 | wxChar figBuf[40]; |
9a29912f JS |
1709 | |
1710 | if ( inFigure ) | |
1711 | { | |
1712 | figureNo ++; | |
1713 | ||
1714 | if (DocumentStyle != LATEX_ARTICLE) | |
b63b07a8 | 1715 | wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d.%d: "), FigureNameString, chapterNo, figureNo); |
9a29912f | 1716 | else |
b63b07a8 | 1717 | wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d: "), FigureNameString, figureNo); |
9a29912f JS |
1718 | } |
1719 | else | |
1720 | { | |
1721 | tableNo ++; | |
1722 | ||
1723 | if (DocumentStyle != LATEX_ARTICLE) | |
b63b07a8 | 1724 | wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d.%d: "), TableNameString, chapterNo, tableNo); |
9a29912f | 1725 | else |
b63b07a8 | 1726 | wxSnprintf(figBuf, sizeof(figBuf), _T("%s %d: "), TableNameString, tableNo); |
9a29912f JS |
1727 | } |
1728 | ||
1729 | TexOutput(figBuf); | |
1730 | } | |
1731 | else | |
1732 | { | |
1733 | if (inTabular) | |
6c155d33 | 1734 | TexOutput(_T("\n</CAPTION>\n")); |
9a29912f | 1735 | |
6c155d33 | 1736 | wxChar *topicName = FindTopicName(GetNextChunk()); |
9a29912f JS |
1737 | |
1738 | int n = inFigure ? figureNo : tableNo; | |
1739 | ||
1740 | AddTexRef(topicName, NULL, NULL, | |
1741 | ((DocumentStyle != LATEX_ARTICLE) ? chapterNo : n), | |
1742 | ((DocumentStyle != LATEX_ARTICLE) ? n : 0)); | |
1743 | } | |
1744 | break; | |
1745 | } | |
1746 | case ltSS: | |
1747 | { | |
6c155d33 | 1748 | if (start) TexOutput(_T("ß")); |
9a29912f JS |
1749 | break; |
1750 | } | |
1751 | case ltFIGURE: | |
1752 | { | |
b63b07a8 RL |
1753 | if (start) inFigure = true; |
1754 | else inFigure = false; | |
9a29912f JS |
1755 | break; |
1756 | } | |
1757 | case ltTABLE: | |
1758 | { | |
b63b07a8 RL |
1759 | if (start) inTable = true; |
1760 | else inTable = false; | |
9a29912f JS |
1761 | break; |
1762 | } | |
1763 | default: | |
1764 | DefaultOnMacro(macroId, no_args, start); | |
1765 | break; | |
1766 | } | |
1767 | } | |
1768 | ||
1769 | // Called on start/end of argument examination | |
1770 | bool HTMLOnArgument(int macroId, int arg_no, bool start) | |
1771 | { | |
1772 | switch (macroId) | |
1773 | { | |
1774 | case ltCHAPTER: | |
1775 | case ltCHAPTERSTAR: | |
1776 | case ltCHAPTERHEADING: | |
1777 | case ltSECTION: | |
1778 | case ltSECTIONSTAR: | |
1779 | case ltSECTIONHEADING: | |
1780 | case ltSUBSECTION: | |
1781 | case ltSUBSECTIONSTAR: | |
1782 | case ltSUBSUBSECTION: | |
1783 | case ltSUBSUBSECTIONSTAR: | |
1784 | case ltGLOSS: | |
1785 | case ltMEMBERSECTION: | |
1786 | case ltFUNCTIONSECTION: | |
1787 | { | |
1788 | if (!start && (arg_no == 1)) | |
1789 | currentSection = GetArgChunk(); | |
b63b07a8 | 1790 | return false; |
9a29912f JS |
1791 | } |
1792 | case ltFUNC: | |
1793 | { | |
1794 | if (start && (arg_no == 1)) | |
6c155d33 | 1795 | TexOutput(_T("<B>")); |
9a29912f JS |
1796 | |
1797 | if (!start && (arg_no == 1)) | |
6c155d33 | 1798 | TexOutput(_T("</B> ")); |
9a29912f JS |
1799 | |
1800 | if (start && (arg_no == 2)) | |
1801 | { | |
6c155d33 | 1802 | if (!suppressNameDecoration) TexOutput(_T("<B>")); |
9a29912f JS |
1803 | currentMember = GetArgChunk(); |
1804 | } | |
1805 | if (!start && (arg_no == 2)) | |
1806 | { | |
6c155d33 | 1807 | if (!suppressNameDecoration) TexOutput(_T("</B>")); |
9a29912f | 1808 | } |
119f7a8c | 1809 | |
9a29912f | 1810 | if (start && (arg_no == 3)) |
6c155d33 | 1811 | TexOutput(_T("(")); |
9a29912f | 1812 | if (!start && (arg_no == 3)) |
6c155d33 | 1813 | TexOutput(_T(")")); |
9a29912f JS |
1814 | break; |
1815 | } | |
1816 | case ltCLIPSFUNC: | |
1817 | { | |
1818 | if (start && (arg_no == 1)) | |
6c155d33 | 1819 | TexOutput(_T("<B>")); |
9a29912f | 1820 | if (!start && (arg_no == 1)) |
6c155d33 | 1821 | TexOutput(_T("</B> ")); |
9a29912f JS |
1822 | |
1823 | if (start && (arg_no == 2)) | |
1824 | { | |
6c155d33 | 1825 | if (!suppressNameDecoration) TexOutput(_T("( ")); |
9a29912f JS |
1826 | currentMember = GetArgChunk(); |
1827 | } | |
1828 | if (!start && (arg_no == 2)) | |
1829 | { | |
1830 | } | |
1831 | ||
1832 | if (!start && (arg_no == 3)) | |
6c155d33 | 1833 | TexOutput(_T(")")); |
9a29912f JS |
1834 | break; |
1835 | } | |
1836 | case ltPFUNC: | |
1837 | { | |
1838 | if (!start && (arg_no == 1)) | |
6c155d33 | 1839 | TexOutput(_T(" ")); |
9a29912f JS |
1840 | |
1841 | if (start && (arg_no == 2)) | |
6c155d33 | 1842 | TexOutput(_T("(*")); |
9a29912f | 1843 | if (!start && (arg_no == 2)) |
6c155d33 | 1844 | TexOutput(_T(")")); |
9a29912f JS |
1845 | |
1846 | if (start && (arg_no == 2)) | |
1847 | currentMember = GetArgChunk(); | |
1848 | ||
1849 | if (start && (arg_no == 3)) | |
6c155d33 | 1850 | TexOutput(_T("(")); |
9a29912f | 1851 | if (!start && (arg_no == 3)) |
6c155d33 | 1852 | TexOutput(_T(")")); |
9a29912f JS |
1853 | break; |
1854 | } | |
1855 | case ltPARAM: | |
1856 | { | |
1857 | if (start && (arg_no == 1)) | |
6c155d33 | 1858 | TexOutput(_T("<B>")); |
9a29912f | 1859 | if (!start && (arg_no == 1)) |
6c155d33 | 1860 | TexOutput(_T("</B>")); |
9a29912f JS |
1861 | if (start && (arg_no == 2)) |
1862 | { | |
6c155d33 | 1863 | TexOutput(_T("<I>")); |
9a29912f JS |
1864 | } |
1865 | if (!start && (arg_no == 2)) | |
1866 | { | |
6c155d33 | 1867 | TexOutput(_T("</I>")); |
9a29912f JS |
1868 | } |
1869 | break; | |
1870 | } | |
1871 | case ltCPARAM: | |
1872 | { | |
1873 | if (start && (arg_no == 1)) | |
6c155d33 | 1874 | TexOutput(_T("<B>")); |
9a29912f | 1875 | if (!start && (arg_no == 1)) |
6c155d33 | 1876 | TexOutput(_T("</B> ")); // This is the difference from param - one space! |
9a29912f JS |
1877 | if (start && (arg_no == 2)) |
1878 | { | |
6c155d33 | 1879 | TexOutput(_T("<I>")); |
9a29912f JS |
1880 | } |
1881 | if (!start && (arg_no == 2)) | |
1882 | { | |
6c155d33 | 1883 | TexOutput(_T("</I>")); |
9a29912f JS |
1884 | } |
1885 | break; | |
1886 | } | |
1887 | case ltMEMBER: | |
1888 | { | |
1889 | if (!start && (arg_no == 1)) | |
6c155d33 | 1890 | TexOutput(_T(" ")); |
9a29912f JS |
1891 | |
1892 | if (start && (arg_no == 2)) | |
1893 | currentMember = GetArgChunk(); | |
1894 | break; | |
1895 | } | |
1896 | case ltREF: | |
1897 | { | |
1898 | if (start) | |
1899 | { | |
6c155d33 | 1900 | wxChar *sec = NULL; |
119f7a8c | 1901 | |
6c155d33 | 1902 | wxChar *refName = GetArgData(); |
9a29912f JS |
1903 | if (refName) |
1904 | { | |
1905 | TexRef *texRef = FindReference(refName); | |
1906 | if (texRef) | |
1907 | { | |
1908 | sec = texRef->sectionNumber; | |
1909 | } | |
1910 | } | |
1911 | if (sec) | |
1912 | { | |
1913 | TexOutput(sec); | |
1914 | } | |
b63b07a8 | 1915 | return false; |
9a29912f JS |
1916 | } |
1917 | break; | |
1918 | } | |
1919 | case ltURLREF: | |
1920 | { | |
1921 | if (IsArgOptional()) | |
b63b07a8 | 1922 | return false; |
9a29912f JS |
1923 | else if ((GetNoArgs() - arg_no) == 1) |
1924 | { | |
1925 | if (start) | |
1926 | helpRefText = GetArgChunk(); | |
b63b07a8 | 1927 | return false; |
9a29912f JS |
1928 | } |
1929 | else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional | |
1930 | { | |
1931 | if (start) | |
1932 | { | |
1933 | TexChunk *ref = GetArgChunk(); | |
6c155d33 | 1934 | TexOutput(_T("<A HREF=\"")); |
b63b07a8 | 1935 | inVerbatim = true; |
9a29912f | 1936 | TraverseChildrenFromChunk(ref); |
b63b07a8 | 1937 | inVerbatim = false; |
6c155d33 | 1938 | TexOutput(_T("\">")); |
9a29912f JS |
1939 | if (helpRefText) |
1940 | TraverseChildrenFromChunk(helpRefText); | |
6c155d33 | 1941 | TexOutput(_T("</A>")); |
9a29912f | 1942 | } |
b63b07a8 | 1943 | return false; |
9a29912f JS |
1944 | } |
1945 | break; | |
1946 | } | |
1947 | case ltHELPREF: | |
1948 | case ltHELPREFN: | |
1949 | case ltPOPREF: | |
1950 | { | |
1951 | if (IsArgOptional()) | |
1952 | { | |
1953 | if (start) | |
1954 | helpRefFilename = GetArgChunk(); | |
b63b07a8 | 1955 | return false; |
9a29912f JS |
1956 | } |
1957 | if ((GetNoArgs() - arg_no) == 1) | |
1958 | { | |
1959 | if (start) | |
1960 | helpRefText = GetArgChunk(); | |
b63b07a8 | 1961 | return false; |
9a29912f JS |
1962 | } |
1963 | else if ((GetNoArgs() - arg_no) == 0) // Arg = 2, or 3 if first is optional | |
1964 | { | |
1965 | if (start) | |
1966 | { | |
6c155d33 JS |
1967 | wxChar *refName = GetArgData(); |
1968 | wxChar *refFilename = NULL; | |
9a29912f JS |
1969 | |
1970 | if (refName) | |
1971 | { | |
1972 | TexRef *texRef = FindReference(refName); | |
1973 | if (texRef) | |
1974 | { | |
6c155d33 | 1975 | if (texRef->refFile && wxStrcmp(texRef->refFile, _T("??")) != 0) |
9a29912f JS |
1976 | refFilename = texRef->refFile; |
1977 | ||
6c155d33 | 1978 | TexOutput(_T("<A HREF=\"")); |
9a29912f JS |
1979 | // If a filename is supplied, use it, otherwise try to |
1980 | // use the filename associated with the reference (from this document). | |
1981 | if (helpRefFilename) | |
4fe30bce | 1982 | { |
9a29912f | 1983 | TraverseChildrenFromChunk(helpRefFilename); |
6c155d33 | 1984 | TexOutput(_T("#")); |
4fe30bce | 1985 | } |
9a29912f | 1986 | else if (refFilename) |
4fe30bce | 1987 | { |
9a29912f | 1988 | TexOutput(ConvertCase(refFilename)); |
6c155d33 | 1989 | TexOutput(_T("#")); |
4fe30bce | 1990 | } |
9a29912f | 1991 | TexOutput(refName); |
6c155d33 | 1992 | TexOutput(_T("\">")); |
9a29912f JS |
1993 | if (helpRefText) |
1994 | TraverseChildrenFromChunk(helpRefText); | |
6c155d33 | 1995 | TexOutput(_T("</A>")); |
9a29912f JS |
1996 | } |
1997 | else | |
1998 | { | |
1999 | if (helpRefText) | |
2000 | TraverseChildrenFromChunk(helpRefText); | |
bf16085d | 2001 | if (!ignoreBadRefs) |
6c155d33 | 2002 | TexOutput(_T(" (REF NOT FOUND)")); |
31ad62bc | 2003 | wxString errBuf; |
6c155d33 JS |
2004 | errBuf.Printf(_T("Warning: unresolved reference '%s'"), refName); |
2005 | OnInform((wxChar *)errBuf.c_str()); | |
9a29912f JS |
2006 | } |
2007 | } | |
6c155d33 | 2008 | else TexOutput(_T("??")); |
9a29912f | 2009 | } |
b63b07a8 | 2010 | return false; |
9a29912f JS |
2011 | } |
2012 | break; | |
2013 | } | |
2014 | case ltIMAGE: | |
2015 | case ltIMAGEL: | |
2016 | case ltIMAGER: | |
2017 | case ltPSBOXTO: | |
2018 | { | |
2019 | if (arg_no == 2) | |
2020 | { | |
2021 | if (start) | |
2022 | { | |
6c155d33 | 2023 | wxChar *alignment = _T(""); |
9a29912f | 2024 | if (macroId == ltIMAGEL) |
6c155d33 | 2025 | alignment = _T(" align=left"); |
9a29912f | 2026 | else if (macroId == ltIMAGER) |
6c155d33 | 2027 | alignment = _T(" align=right"); |
119f7a8c | 2028 | |
9a29912f | 2029 | // Try to find an XBM or GIF image first. |
6c155d33 JS |
2030 | wxChar *filename = copystring(GetArgData()); |
2031 | wxChar buf[500]; | |
119f7a8c | 2032 | |
6c155d33 | 2033 | wxStrcpy(buf, filename); |
9a29912f | 2034 | StripExtension(buf); |
6c155d33 | 2035 | wxStrcat(buf, _T(".xbm")); |
9a29912f JS |
2036 | wxString f = TexPathList.FindValidPath(buf); |
2037 | ||
6c155d33 | 2038 | if (f == _T("")) // Try for a GIF instead |
9a29912f | 2039 | { |
6c155d33 | 2040 | wxStrcpy(buf, filename); |
9a29912f | 2041 | StripExtension(buf); |
6c155d33 | 2042 | wxStrcat(buf, _T(".gif")); |
9a29912f JS |
2043 | f = TexPathList.FindValidPath(buf); |
2044 | } | |
14204c7a | 2045 | |
6c155d33 | 2046 | if (f == _T("")) // Try for a JPEG instead |
14204c7a | 2047 | { |
6c155d33 | 2048 | wxStrcpy(buf, filename); |
14204c7a | 2049 | StripExtension(buf); |
6c155d33 | 2050 | wxStrcat(buf, _T(".jpg")); |
14204c7a VS |
2051 | f = TexPathList.FindValidPath(buf); |
2052 | } | |
2053 | ||
6c155d33 | 2054 | if (f == _T("")) // Try for a PNG instead |
14204c7a | 2055 | { |
6c155d33 | 2056 | wxStrcpy(buf, filename); |
14204c7a | 2057 | StripExtension(buf); |
6c155d33 | 2058 | wxStrcat(buf, _T(".png")); |
14204c7a VS |
2059 | f = TexPathList.FindValidPath(buf); |
2060 | } | |
2061 | ||
6c155d33 | 2062 | if (f != _T("")) |
9a29912f | 2063 | { |
6c155d33 | 2064 | wxChar *inlineFilename = copystring(f); |
9a29912f | 2065 | #if 0 |
6c155d33 | 2066 | wxChar *originalFilename = TexPathList.FindValidPath(filename); |
9a29912f JS |
2067 | // If we have found the existing filename, make the inline |
2068 | // image point to the original file (could be PS, for example) | |
6c155d33 | 2069 | if (originalFilename && (wxStrcmp(inlineFilename, originalFilename) != 0)) |
4fe30bce | 2070 | { |
6c155d33 | 2071 | TexOutput(_T("<A HREF=\"")); |
9a29912f | 2072 | TexOutput(ConvertCase(originalFilename)); |
6c155d33 JS |
2073 | TexOutput(_T("\">")); |
2074 | TexOutput(_T("<img src=\"")); | |
9a29912f | 2075 | TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename))); |
6c155d33 JS |
2076 | TexOutput(_T("\"")); |
2077 | TexOutput(alignment); | |
2078 | TexOutput(_T("></A>")); | |
4fe30bce | 2079 | } |
9a29912f JS |
2080 | else |
2081 | #endif | |
4fe30bce | 2082 | { |
6c155d33 | 2083 | TexOutput(_T("<img src=\"")); |
9a29912f | 2084 | TexOutput(ConvertCase(wxFileNameFromPath(inlineFilename))); |
6c155d33 JS |
2085 | TexOutput(_T("\"")); |
2086 | TexOutput(alignment); | |
2087 | TexOutput(_T(">")); | |
9a29912f | 2088 | delete[] inlineFilename; |
4fe30bce | 2089 | } |
9a29912f JS |
2090 | } |
2091 | else | |
2092 | { | |
2093 | // Last resort - a link to a PS file. | |
6c155d33 | 2094 | TexOutput(_T("<A HREF=\"")); |
9a29912f | 2095 | TexOutput(ConvertCase(wxFileNameFromPath(filename))); |
6c155d33 | 2096 | TexOutput(_T("\">Picture</A>\n")); |
b63b07a8 | 2097 | wxSnprintf(buf, sizeof(buf), _T("Warning: could not find an inline XBM/GIF for %s."), filename); |
9a29912f JS |
2098 | OnInform(buf); |
2099 | } | |
2100 | } | |
2101 | } | |
b63b07a8 | 2102 | return false; |
9a29912f JS |
2103 | } |
2104 | // First arg is PSBOX spec (ignored), second is image file, third is map name. | |
2105 | case ltIMAGEMAP: | |
2106 | { | |
6c155d33 | 2107 | static wxChar *imageFile = NULL; |
9a29912f JS |
2108 | if (start && (arg_no == 2)) |
2109 | { | |
2110 | // Try to find an XBM or GIF image first. | |
6c155d33 JS |
2111 | wxChar *filename = copystring(GetArgData()); |
2112 | wxChar buf[500]; | |
119f7a8c | 2113 | |
6c155d33 | 2114 | wxStrcpy(buf, filename); |
9a29912f | 2115 | StripExtension(buf); |
6c155d33 | 2116 | wxStrcat(buf, _T(".xbm")); |
9a29912f JS |
2117 | wxString f = TexPathList.FindValidPath(buf); |
2118 | ||
6c155d33 | 2119 | if (f == _T("")) // Try for a GIF instead |
9a29912f | 2120 | { |
6c155d33 | 2121 | wxStrcpy(buf, filename); |
9a29912f | 2122 | StripExtension(buf); |
6c155d33 | 2123 | wxStrcat(buf, _T(".gif")); |
9a29912f JS |
2124 | f = TexPathList.FindValidPath(buf); |
2125 | } | |
6c155d33 | 2126 | if (f == _T("")) |
9a29912f | 2127 | { |
6c155d33 | 2128 | wxChar buf[300]; |
b63b07a8 | 2129 | wxSnprintf(buf, sizeof(buf), _T("Warning: could not find an inline XBM/GIF for %s."), filename); |
9a29912f JS |
2130 | OnInform(buf); |
2131 | } | |
2132 | delete[] filename; | |
2133 | if (imageFile) | |
2134 | delete[] imageFile; | |
2135 | imageFile = NULL; | |
48c12cb1 | 2136 | if (!f.IsEmpty()) |
9a29912f JS |
2137 | { |
2138 | imageFile = copystring(f); | |
2139 | } | |
2140 | } | |
2141 | else if (start && (arg_no == 3)) | |
2142 | { | |
2143 | if (imageFile) | |
2144 | { | |
2145 | // First, try to find a .shg (segmented hypergraphics file) | |
2146 | // that we can convert to a map file | |
6c155d33 JS |
2147 | wxChar buf[256]; |
2148 | wxStrcpy(buf, imageFile); | |
9a29912f | 2149 | StripExtension(buf); |
6c155d33 | 2150 | wxStrcat(buf, _T(".shg")); |
9a29912f JS |
2151 | wxString f = TexPathList.FindValidPath(buf); |
2152 | ||
6c155d33 | 2153 | if (f != _T("")) |
9a29912f JS |
2154 | { |
2155 | // The default HTML file to go to is THIS file (so a no-op) | |
6c155d33 | 2156 | SHGToMap((wxChar *)f.c_str(), currentFileName); |
9a29912f JS |
2157 | } |
2158 | ||
6c155d33 JS |
2159 | wxChar *mapName = GetArgData(); |
2160 | TexOutput(_T("<A HREF=\"/cgi-bin/imagemap/")); | |
9a29912f JS |
2161 | if (mapName) |
2162 | TexOutput(mapName); | |
2163 | else | |
6c155d33 JS |
2164 | TexOutput(_T("unknown")); |
2165 | TexOutput(_T("\">")); | |
2166 | TexOutput(_T("<img src=\"")); | |
9a29912f | 2167 | TexOutput(ConvertCase(wxFileNameFromPath(imageFile))); |
6c155d33 | 2168 | TexOutput(_T("\" ISMAP></A><P>")); |
9a29912f JS |
2169 | delete[] imageFile; |
2170 | imageFile = NULL; | |
2171 | } | |
2172 | } | |
b63b07a8 | 2173 | return false; |
9a29912f JS |
2174 | } |
2175 | case ltINDENTED : | |
2176 | { | |
2177 | if ( arg_no == 1 ) | |
b63b07a8 | 2178 | return false; |
9a29912f JS |
2179 | else |
2180 | { | |
b63b07a8 | 2181 | return true; |
9a29912f JS |
2182 | } |
2183 | } | |
2184 | case ltITEM: | |
2185 | { | |
2186 | if (start) | |
2187 | { | |
2188 | descriptionItemArg = GetArgChunk(); | |
b63b07a8 | 2189 | return false; |
9a29912f | 2190 | } |
b63b07a8 | 2191 | return true; |
9a29912f JS |
2192 | } |
2193 | case ltTWOCOLITEM: | |
2194 | case ltTWOCOLITEMRULED: | |
2195 | { | |
2196 | /* | |
2197 | if (start && (arg_no == 1)) | |
6c155d33 | 2198 | TexOutput(_T("\n<DT> ")); |
9a29912f | 2199 | if (start && (arg_no == 2)) |
6c155d33 | 2200 | TexOutput(_T("<DD> ")); |
9a29912f JS |
2201 | */ |
2202 | if (arg_no == 1) | |
2203 | { | |
c103ca4b JS |
2204 | if ( start ) { |
2205 | // DHS | |
4fe30bce WS |
2206 | if (TwoColWidthA > -1) |
2207 | { | |
6c155d33 | 2208 | wxChar buf[100]; |
b63b07a8 | 2209 | wxSnprintf(buf, sizeof(buf), _T("\n<TR><TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthA); |
c103ca4b | 2210 | TexOutput(buf); |
4fe30bce WS |
2211 | } |
2212 | else | |
2213 | { | |
6c155d33 | 2214 | TexOutput(_T("\n<TR><TD VALIGN=TOP>\n")); |
4fe30bce WS |
2215 | } |
2216 | OutputFont(); | |
c103ca4b | 2217 | } else |
6c155d33 | 2218 | TexOutput(_T("\n</FONT></TD>\n")); |
9a29912f JS |
2219 | } |
2220 | if (arg_no == 2) | |
2221 | { | |
c103ca4b | 2222 | // DHS |
4fe30bce WS |
2223 | if ( start ) |
2224 | { | |
2225 | if (TwoColWidthB > -1) | |
2226 | { | |
6c155d33 | 2227 | wxChar buf[100]; |
b63b07a8 | 2228 | wxSnprintf(buf, sizeof(buf), _T("\n<TD VALIGN=TOP WIDTH=%d>\n"),TwoColWidthB); |
c103ca4b | 2229 | TexOutput(buf); |
4fe30bce WS |
2230 | } |
2231 | else | |
2232 | { | |
2233 | TexOutput(_T("\n<TD VALIGN=TOP>\n")); | |
2234 | } | |
2235 | OutputFont(); | |
c103ca4b | 2236 | } else |
6c155d33 | 2237 | TexOutput(_T("\n</FONT></TD></TR>\n")); |
9a29912f | 2238 | } |
b63b07a8 | 2239 | return true; |
9a29912f JS |
2240 | } |
2241 | case ltNUMBEREDBIBITEM: | |
2242 | { | |
2243 | if (arg_no == 1 && start) | |
2244 | { | |
6c155d33 | 2245 | TexOutput(_T("\n<DT> ")); |
9a29912f JS |
2246 | } |
2247 | if (arg_no == 2 && !start) | |
6c155d33 | 2248 | TexOutput(_T("<P>\n")); |
9a29912f JS |
2249 | break; |
2250 | } | |
2251 | case ltBIBITEM: | |
2252 | { | |
6c155d33 | 2253 | wxChar buf[100]; |
9a29912f JS |
2254 | if (arg_no == 1 && start) |
2255 | { | |
6c155d33 | 2256 | wxChar *citeKey = GetArgData(); |
9a29912f JS |
2257 | TexRef *ref = (TexRef *)TexReferences.Get(citeKey); |
2258 | if (ref) | |
2259 | { | |
2260 | if (ref->sectionNumber) delete[] ref->sectionNumber; | |
b63b07a8 | 2261 | wxSnprintf(buf, sizeof(buf), _T("[%d]"), citeCount); |
9a29912f JS |
2262 | ref->sectionNumber = copystring(buf); |
2263 | } | |
2264 | ||
b63b07a8 | 2265 | wxSnprintf(buf, sizeof(buf), _T("\n<DT> [%d] "), citeCount); |
9a29912f JS |
2266 | TexOutput(buf); |
2267 | citeCount ++; | |
b63b07a8 | 2268 | return false; |
9a29912f JS |
2269 | } |
2270 | if (arg_no == 2 && !start) | |
6c155d33 | 2271 | TexOutput(_T("<P>\n")); |
b63b07a8 | 2272 | return true; |
9a29912f JS |
2273 | } |
2274 | case ltMARGINPAR: | |
2275 | case ltMARGINPARODD: | |
2276 | case ltMARGINPAREVEN: | |
2277 | case ltNORMALBOX: | |
2278 | case ltNORMALBOXD: | |
2279 | { | |
2280 | if (start) | |
2281 | { | |
6c155d33 | 2282 | TexOutput(_T("<HR>\n")); |
b63b07a8 | 2283 | return true; |
9a29912f JS |
2284 | } |
2285 | else | |
6c155d33 | 2286 | TexOutput(_T("<HR><P>\n")); |
9a29912f JS |
2287 | break; |
2288 | } | |
c103ca4b JS |
2289 | // DHS |
2290 | case ltTWOCOLWIDTHA: | |
2291 | { | |
2292 | if (start) | |
2293 | { | |
6c155d33 | 2294 | wxChar *val = GetArgData(); |
c103ca4b JS |
2295 | float points = ParseUnitArgument(val); |
2296 | TwoColWidthA = (int)((points * 100.0) / 72.0); | |
2297 | } | |
b63b07a8 | 2298 | return false; |
c103ca4b JS |
2299 | } |
2300 | // DHS | |
2301 | case ltTWOCOLWIDTHB: | |
2302 | { | |
2303 | if (start) | |
2304 | { | |
6c155d33 | 2305 | wxChar *val = GetArgData(); |
c103ca4b JS |
2306 | float points = ParseUnitArgument(val); |
2307 | TwoColWidthB = (int)((points * 100.0) / 72.0); | |
2308 | } | |
b63b07a8 | 2309 | return false; |
c103ca4b | 2310 | } |
9a29912f JS |
2311 | /* |
2312 | * Accents | |
2313 | * | |
2314 | */ | |
2315 | case ltACCENT_GRAVE: | |
2316 | { | |
2317 | if (start) | |
2318 | { | |
6c155d33 | 2319 | wxChar *val = GetArgData(); |
9a29912f JS |
2320 | if (val) |
2321 | { | |
2322 | switch (val[0]) | |
2323 | { | |
2324 | case 'a': | |
6c155d33 | 2325 | TexOutput(_T("à")); |
9a29912f JS |
2326 | break; |
2327 | case 'e': | |
6c155d33 | 2328 | TexOutput(_T("è")); |
9a29912f JS |
2329 | break; |
2330 | case 'i': | |
6c155d33 | 2331 | TexOutput(_T("ì")); |
9a29912f JS |
2332 | break; |
2333 | case 'o': | |
6c155d33 | 2334 | TexOutput(_T("ò")); |
9a29912f JS |
2335 | break; |
2336 | case 'u': | |
6c155d33 | 2337 | TexOutput(_T("ù")); |
9a29912f JS |
2338 | break; |
2339 | case 'A': | |
6c155d33 | 2340 | TexOutput(_T("À")); |
9a29912f JS |
2341 | break; |
2342 | case 'E': | |
6c155d33 | 2343 | TexOutput(_T("È")); |
9a29912f JS |
2344 | break; |
2345 | case 'I': | |
6c155d33 | 2346 | TexOutput(_T("Ì")); |
9a29912f JS |
2347 | break; |
2348 | case 'O': | |
6c155d33 | 2349 | TexOutput(_T("Ò")); |
9a29912f JS |
2350 | break; |
2351 | case 'U': | |
6c155d33 | 2352 | TexOutput(_T("Ì")); |
9a29912f JS |
2353 | break; |
2354 | default: | |
2355 | break; | |
2356 | } | |
2357 | } | |
2358 | } | |
b63b07a8 | 2359 | return false; |
9a29912f JS |
2360 | } |
2361 | case ltACCENT_ACUTE: | |
2362 | { | |
2363 | if (start) | |
2364 | { | |
6c155d33 | 2365 | wxChar *val = GetArgData(); |
9a29912f JS |
2366 | if (val) |
2367 | { | |
2368 | switch (val[0]) | |
2369 | { | |
2370 | case 'a': | |
6c155d33 | 2371 | TexOutput(_T("á")); |
9a29912f JS |
2372 | break; |
2373 | case 'e': | |
6c155d33 | 2374 | TexOutput(_T("é")); |
9a29912f JS |
2375 | break; |
2376 | case 'i': | |
6c155d33 | 2377 | TexOutput(_T("í")); |
9a29912f JS |
2378 | break; |
2379 | case 'o': | |
6c155d33 | 2380 | TexOutput(_T("ó")); |
9a29912f JS |
2381 | break; |
2382 | case 'u': | |
6c155d33 | 2383 | TexOutput(_T("ú")); |
9a29912f JS |
2384 | break; |
2385 | case 'y': | |
6c155d33 | 2386 | TexOutput(_T("ý")); |
9a29912f JS |
2387 | break; |
2388 | case 'A': | |
6c155d33 | 2389 | TexOutput(_T("Á")); |
9a29912f JS |
2390 | break; |
2391 | case 'E': | |
6c155d33 | 2392 | TexOutput(_T("É")); |
9a29912f JS |
2393 | break; |
2394 | case 'I': | |
6c155d33 | 2395 | TexOutput(_T("Í")); |
9a29912f JS |
2396 | break; |
2397 | case 'O': | |
6c155d33 | 2398 | TexOutput(_T("Ó")); |
9a29912f JS |
2399 | break; |
2400 | case 'U': | |
6c155d33 | 2401 | TexOutput(_T("Ú")); |
9a29912f JS |
2402 | break; |
2403 | case 'Y': | |
6c155d33 | 2404 | TexOutput(_T("Ý")); |
9a29912f JS |
2405 | break; |
2406 | default: | |
2407 | break; | |
2408 | } | |
2409 | } | |
2410 | } | |
b63b07a8 | 2411 | return false; |
9a29912f JS |
2412 | } |
2413 | case ltACCENT_CARET: | |
2414 | { | |
2415 | if (start) | |
2416 | { | |
6c155d33 | 2417 | wxChar *val = GetArgData(); |
9a29912f JS |
2418 | if (val) |
2419 | { | |
2420 | switch (val[0]) | |
2421 | { | |
2422 | case 'a': | |
6c155d33 | 2423 | TexOutput(_T("â")); |
9a29912f JS |
2424 | break; |
2425 | case 'e': | |
6c155d33 | 2426 | TexOutput(_T("ê")); |
9a29912f JS |
2427 | break; |
2428 | case 'i': | |
6c155d33 | 2429 | TexOutput(_T("î")); |
9a29912f JS |
2430 | break; |
2431 | case 'o': | |
6c155d33 | 2432 | TexOutput(_T("ô")); |
9a29912f JS |
2433 | break; |
2434 | case 'u': | |
6c155d33 | 2435 | TexOutput(_T("û")); |
9a29912f JS |
2436 | break; |
2437 | case 'A': | |
6c155d33 | 2438 | TexOutput(_T("Â")); |
9a29912f JS |
2439 | break; |
2440 | case 'E': | |
6c155d33 | 2441 | TexOutput(_T("Ê")); |
9a29912f JS |
2442 | break; |
2443 | case 'I': | |
6c155d33 | 2444 | TexOutput(_T("Î")); |
9a29912f JS |
2445 | break; |
2446 | case 'O': | |
6c155d33 | 2447 | TexOutput(_T("Ô")); |
9a29912f JS |
2448 | break; |
2449 | case 'U': | |
6c155d33 | 2450 | TexOutput(_T("Î")); |
9a29912f JS |
2451 | break; |
2452 | default: | |
2453 | break; | |
2454 | } | |
2455 | } | |
2456 | } | |
b63b07a8 | 2457 | return false; |
9a29912f JS |
2458 | } |
2459 | case ltACCENT_TILDE: | |
2460 | { | |
2461 | if (start) | |
2462 | { | |
6c155d33 | 2463 | wxChar *val = GetArgData(); |
9a29912f JS |
2464 | if (val) |
2465 | { | |
2466 | switch (val[0]) | |
2467 | { | |
2468 | case ' ': | |
6c155d33 | 2469 | TexOutput(_T("~")); |
9a29912f JS |
2470 | break; |
2471 | case 'a': | |
6c155d33 | 2472 | TexOutput(_T("ã")); |
9a29912f JS |
2473 | break; |
2474 | case 'n': | |
6c155d33 | 2475 | TexOutput(_T("ñ")); |
9a29912f JS |
2476 | break; |
2477 | case 'o': | |
6c155d33 | 2478 | TexOutput(_T("õ")); |
9a29912f JS |
2479 | break; |
2480 | case 'A': | |
6c155d33 | 2481 | TexOutput(_T("Ã")); |
9a29912f JS |
2482 | break; |
2483 | case 'N': | |
6c155d33 | 2484 | TexOutput(_T("Ñ")); |
9a29912f JS |
2485 | break; |
2486 | case 'O': | |
6c155d33 | 2487 | TexOutput(_T("Õ")); |
9a29912f JS |
2488 | break; |
2489 | default: | |
2490 | break; | |
2491 | } | |
2492 | } | |
2493 | } | |
b63b07a8 | 2494 | return false; |
9a29912f JS |
2495 | } |
2496 | case ltACCENT_UMLAUT: | |
2497 | { | |
2498 | if (start) | |
2499 | { | |
6c155d33 | 2500 | wxChar *val = GetArgData(); |
9a29912f JS |
2501 | if (val) |
2502 | { | |
2503 | switch (val[0]) | |
2504 | { | |
2505 | case 'a': | |
6c155d33 | 2506 | TexOutput(_T("ä")); |
9a29912f JS |
2507 | break; |
2508 | case 'e': | |
6c155d33 | 2509 | TexOutput(_T("ë")); |
9a29912f JS |
2510 | break; |
2511 | case 'i': | |
6c155d33 | 2512 | TexOutput(_T("ï")); |
9a29912f JS |
2513 | break; |
2514 | case 'o': | |
6c155d33 | 2515 | TexOutput(_T("ö")); |
9a29912f JS |
2516 | break; |
2517 | case 'u': | |
6c155d33 | 2518 | TexOutput(_T("ü")); |
9a29912f JS |
2519 | break; |
2520 | case 'y': | |
6c155d33 | 2521 | TexOutput(_T("ÿ")); |
9a29912f JS |
2522 | break; |
2523 | case 'A': | |
6c155d33 | 2524 | TexOutput(_T("Ä")); |
9a29912f JS |
2525 | break; |
2526 | case 'E': | |
6c155d33 | 2527 | TexOutput(_T("Ë")); |
9a29912f JS |
2528 | break; |
2529 | case 'I': | |
6c155d33 | 2530 | TexOutput(_T("Ï")); |
9a29912f JS |
2531 | break; |
2532 | case 'O': | |
6c155d33 | 2533 | TexOutput(_T("Ö")); |
9a29912f JS |
2534 | break; |
2535 | case 'U': | |
6c155d33 | 2536 | TexOutput(_T("Ü")); |
9a29912f JS |
2537 | break; |
2538 | case 'Y': | |
6c155d33 | 2539 | TexOutput(_T("Ÿ")); |
9a29912f JS |
2540 | break; |
2541 | default: | |
2542 | break; | |
2543 | } | |
2544 | } | |
2545 | } | |
b63b07a8 | 2546 | return false; |
9a29912f JS |
2547 | } |
2548 | case ltACCENT_DOT: | |
2549 | { | |
2550 | if (start) | |
2551 | { | |
6c155d33 | 2552 | wxChar *val = GetArgData(); |
9a29912f JS |
2553 | if (val) |
2554 | { | |
2555 | switch (val[0]) | |
2556 | { | |
2557 | case 'a': | |
6c155d33 | 2558 | TexOutput(_T("å")); |
9a29912f JS |
2559 | break; |
2560 | case 'A': | |
6c155d33 | 2561 | TexOutput(_T("Å")); |
9a29912f JS |
2562 | break; |
2563 | default: | |
2564 | break; | |
2565 | } | |
2566 | } | |
2567 | } | |
b63b07a8 | 2568 | return false; |
9a29912f JS |
2569 | } |
2570 | case ltBACKGROUND: | |
2571 | { | |
2572 | if (start) | |
2573 | { | |
6c155d33 | 2574 | wxChar *val = GetArgData(); |
9a29912f JS |
2575 | if (val) |
2576 | { | |
b63b07a8 | 2577 | bool isPicture = false; |
6a205442 | 2578 | ParseColourString(val, &isPicture); |
9a29912f JS |
2579 | if (isPicture) |
2580 | { | |
2581 | if (backgroundImageString) | |
2582 | delete[] backgroundImageString; | |
2583 | backgroundImageString = copystring(val); | |
2584 | } | |
2585 | else | |
2586 | { | |
2587 | if (backgroundColourString) | |
2588 | delete[] backgroundColourString; | |
2589 | backgroundColourString = copystring(val); | |
2590 | } | |
2591 | } | |
2592 | } | |
b63b07a8 | 2593 | return false; |
9a29912f JS |
2594 | } |
2595 | case ltBACKGROUNDIMAGE: | |
2596 | { | |
2597 | if (start) | |
2598 | { | |
6c155d33 | 2599 | wxChar *val = GetArgData(); |
9a29912f JS |
2600 | if (val) |
2601 | { | |
2602 | if (backgroundImageString) | |
2603 | delete[] backgroundImageString; | |
2604 | backgroundImageString = copystring(val); | |
2605 | } | |
2606 | } | |
b63b07a8 | 2607 | return false; |
9a29912f JS |
2608 | } |
2609 | case ltBACKGROUNDCOLOUR: | |
2610 | { | |
2611 | if (start) | |
2612 | { | |
6c155d33 | 2613 | wxChar *val = GetArgData(); |
9a29912f JS |
2614 | if (val) |
2615 | { | |
2616 | if (backgroundColourString) | |
2617 | delete[] backgroundColourString; | |
2618 | backgroundColourString = copystring(val); | |
2619 | } | |
2620 | } | |
b63b07a8 | 2621 | return false; |
9a29912f JS |
2622 | } |
2623 | case ltTEXTCOLOUR: | |
2624 | { | |
2625 | if (start) | |
2626 | { | |
6c155d33 | 2627 | wxChar *val = GetArgData(); |
9a29912f JS |
2628 | if (val) |
2629 | { | |
2630 | if (textColourString) | |
2631 | delete[] textColourString; | |
2632 | textColourString = copystring(val); | |
2633 | } | |
2634 | } | |
b63b07a8 | 2635 | return false; |
9a29912f JS |
2636 | } |
2637 | case ltLINKCOLOUR: | |
2638 | { | |
2639 | if (start) | |
2640 | { | |
6c155d33 | 2641 | wxChar *val = GetArgData(); |
9a29912f JS |
2642 | if (val) |
2643 | { | |
2644 | if (linkColourString) | |
2645 | delete[] linkColourString; | |
2646 | linkColourString = copystring(val); | |
2647 | } | |
2648 | } | |
b63b07a8 | 2649 | return false; |
9a29912f JS |
2650 | } |
2651 | case ltFOLLOWEDLINKCOLOUR: | |
2652 | { | |
2653 | if (start) | |
2654 | { | |
6c155d33 | 2655 | wxChar *val = GetArgData(); |
9a29912f JS |
2656 | if (val) |
2657 | { | |
2658 | if (followedLinkColourString) | |
2659 | delete[] followedLinkColourString; | |
2660 | followedLinkColourString = copystring(val); | |
2661 | } | |
2662 | } | |
b63b07a8 | 2663 | return false; |
9a29912f JS |
2664 | } |
2665 | case ltACCENT_CADILLA: | |
2666 | { | |
2667 | if (start) | |
2668 | { | |
6c155d33 | 2669 | wxChar *val = GetArgData(); |
9a29912f JS |
2670 | if (val) |
2671 | { | |
2672 | switch (val[0]) | |
2673 | { | |
2674 | case 'c': | |
6c155d33 | 2675 | TexOutput(_T("ç")); |
9a29912f JS |
2676 | break; |
2677 | case 'C': | |
6c155d33 | 2678 | TexOutput(_T("Ç")); |
9a29912f JS |
2679 | break; |
2680 | default: | |
2681 | break; | |
2682 | } | |
2683 | } | |
2684 | } | |
b63b07a8 | 2685 | return false; |
9a29912f JS |
2686 | } |
2687 | /* | |
2688 | case ltFOOTNOTE: | |
2689 | case ltFOOTNOTEPOPUP: | |
2690 | { | |
2691 | if (arg_no == 1) | |
b63b07a8 | 2692 | return true; |
9a29912f | 2693 | else |
b63b07a8 | 2694 | return false; |
9a29912f JS |
2695 | break; |
2696 | } | |
119f7a8c | 2697 | */ |
9a29912f JS |
2698 | case ltTABULAR: |
2699 | case ltSUPERTABULAR: | |
2700 | { | |
2701 | if (arg_no == 1) | |
2702 | { | |
2703 | if (start) | |
2704 | { | |
2705 | currentRowNumber = 0; | |
b63b07a8 RL |
2706 | inTabular = true; |
2707 | startRows = true; | |
2708 | tableVerticalLineLeft = false; | |
2709 | tableVerticalLineRight = false; | |
9a29912f | 2710 | |
6c155d33 | 2711 | wxChar *alignString = copystring(GetArgData()); |
9a29912f JS |
2712 | ParseTableArgument(alignString); |
2713 | ||
6c155d33 | 2714 | TexOutput(_T("<TABLE BORDER>\n")); |
9a29912f JS |
2715 | |
2716 | // Write the first row formatting for compatibility | |
2717 | // with standard Latex | |
2718 | if (compatibilityMode) | |
2719 | { | |
6c155d33 | 2720 | TexOutput(_T("<TR>\n<TD>")); |
4fe30bce | 2721 | OutputFont(); |
9a29912f JS |
2722 | /* |
2723 | for (int i = 0; i < noColumns; i++) | |
2724 | { | |
2725 | currentWidth += TableData[i].width; | |
b63b07a8 | 2726 | wxSnprintf(buf, sizeof(buf), _T("\\cellx%d"), currentWidth); |
9a29912f JS |
2727 | TexOutput(buf); |
2728 | } | |
6c155d33 | 2729 | TexOutput(_T("\\pard\\intbl\n")); |
9a29912f JS |
2730 | */ |
2731 | } | |
2732 | delete[] alignString; | |
2733 | ||
b63b07a8 | 2734 | return false; |
9a29912f JS |
2735 | } |
2736 | } | |
2737 | else if (arg_no == 2 && !start) | |
2738 | { | |
6c155d33 | 2739 | TexOutput(_T("</TABLE>\n")); |
b63b07a8 | 2740 | inTabular = false; |
9a29912f JS |
2741 | } |
2742 | break; | |
2743 | } | |
2744 | case ltTHEBIBLIOGRAPHY: | |
2745 | { | |
2746 | if (start && (arg_no == 1)) | |
2747 | { | |
66828481 | 2748 | ReopenFile(&Chapters, &ChaptersName, _T("bibliography")); |
6c155d33 JS |
2749 | AddTexRef(_T("bibliography"), ChaptersName, _T("bibliography")); |
2750 | SetCurrentSubsectionName(_T("bibliography"), ChaptersName); | |
9a29912f JS |
2751 | |
2752 | citeCount = 1; | |
2753 | ||
2754 | SetCurrentOutput(Chapters); | |
2755 | ||
6c155d33 | 2756 | wxChar titleBuf[150]; |
9a29912f | 2757 | if (truncateFilenames) |
b63b07a8 | 2758 | wxSnprintf(titleBuf, sizeof(titleBuf), _T("%s.htm"), wxFileNameFromPath(FileRoot)); |
9a29912f | 2759 | else |
b63b07a8 | 2760 | wxSnprintf(titleBuf, sizeof(titleBuf), _T("%s_contents.html"), wxFileNameFromPath(FileRoot)); |
9a29912f | 2761 | |
6d8b260c | 2762 | HTMLHead(); |
6c155d33 | 2763 | TexOutput(_T("<title>")); |
9a29912f | 2764 | TexOutput(ReferencesNameString); |
6c155d33 | 2765 | TexOutput(_T("</title></head>\n")); |
9a29912f JS |
2766 | OutputBodyStart(); |
2767 | ||
6c155d33 JS |
2768 | wxFprintf(Chapters, _T("<A NAME=\"%s\">\n<H2>%s"), _T("bibliography"), ReferencesNameString); |
2769 | AddBrowseButtons(_T("contents"), titleBuf, // Up | |
9a29912f | 2770 | lastTopic, lastFileName, // Last topic |
6c155d33 | 2771 | _T("bibliography"), ChaptersName); // This topic |
9a29912f JS |
2772 | |
2773 | SetCurrentOutputs(Contents, Chapters); | |
6c155d33 | 2774 | wxFprintf(Contents, _T("\n<LI><A HREF=\"%s#%s\">"), ConvertCase(ChaptersName), "bibliography"); |
9a29912f | 2775 | |
6c155d33 JS |
2776 | wxFprintf(Contents, _T("%s</A>\n"), ReferencesNameString); |
2777 | wxFprintf(Chapters, _T("</H2>\n</A>\n")); | |
9a29912f JS |
2778 | |
2779 | SetCurrentOutput(Chapters); | |
b63b07a8 | 2780 | return false; |
9a29912f JS |
2781 | } |
2782 | if (!start && (arg_no == 2)) | |
2783 | { | |
2784 | } | |
b63b07a8 | 2785 | return true; |
9a29912f JS |
2786 | } |
2787 | case ltINDEX: | |
2788 | { | |
2789 | /* Build up list of keywords associated with topics */ | |
2790 | if (start) | |
2791 | { | |
6c155d33 JS |
2792 | // wxChar *entry = GetArgData(); |
2793 | wxChar buf[300]; | |
9a29912f JS |
2794 | OutputChunkToString(GetArgChunk(), buf); |
2795 | if (CurrentTopic) | |
2796 | { | |
2797 | AddKeyWordForTopic(CurrentTopic, buf, currentFileName); | |
2798 | } | |
2799 | } | |
b63b07a8 | 2800 | return false; |
9a29912f JS |
2801 | } |
2802 | case ltFCOL: | |
2803 | // case ltBCOL: | |
2804 | { | |
2805 | if (start) | |
2806 | { | |
2807 | switch (arg_no) | |
2808 | { | |
2809 | case 1: | |
2810 | { | |
6c155d33 JS |
2811 | wxChar *name = GetArgData(); |
2812 | wxChar buf2[10]; | |
9a29912f JS |
2813 | if (!FindColourHTMLString(name, buf2)) |
2814 | { | |
6c155d33 JS |
2815 | wxStrcpy(buf2, _T("#000000")); |
2816 | wxChar buf[100]; | |
4fe30bce | 2817 | wxSnprintf(buf, sizeof(buf), _T("Could not find colour name %s"), name); |
9a29912f JS |
2818 | OnError(buf); |
2819 | } | |
6c155d33 | 2820 | TexOutput(_T("<FONT COLOR=\"")); |
9a29912f | 2821 | TexOutput(buf2); |
6c155d33 | 2822 | TexOutput(_T("\">")); |
9a29912f JS |
2823 | break; |
2824 | } | |
2825 | case 2: | |
2826 | { | |
b63b07a8 | 2827 | return true; |
9a29912f JS |
2828 | } |
2829 | default: | |
2830 | break; | |
2831 | } | |
2832 | } | |
2833 | else | |
2834 | { | |
6c155d33 | 2835 | if (arg_no == 2) TexOutput(_T("</FONT>")); |
9a29912f | 2836 | } |
b63b07a8 | 2837 | return false; |
9a29912f JS |
2838 | } |
2839 | case ltINSERTATLEVEL: | |
2840 | { | |
2841 | // This macro allows you to insert text at a different level | |
2842 | // from the current level, e.g. into the Sections from within a subsubsection. | |
2843 | if (useWord) | |
b63b07a8 | 2844 | return false; |
9a29912f JS |
2845 | static int currentLevelNo = 1; |
2846 | static FILE* oldLevelFile = Chapters; | |
2847 | if (start) | |
2848 | { | |
2849 | switch (arg_no) | |
2850 | { | |
2851 | case 1: | |
2852 | { | |
2853 | oldLevelFile = CurrentOutput1; | |
2854 | ||
6c155d33 JS |
2855 | wxChar *str = GetArgData(); |
2856 | currentLevelNo = wxAtoi(str); | |
9a29912f JS |
2857 | FILE* outputFile; |
2858 | // TODO: cope with article style (no chapters) | |
2859 | switch (currentLevelNo) | |
2860 | { | |
2861 | case 1: | |
2862 | { | |
2863 | outputFile = Chapters; | |
2864 | break; | |
2865 | } | |
2866 | case 2: | |
2867 | { | |
2868 | outputFile = Sections; | |
2869 | break; | |
2870 | } | |
2871 | case 3: | |
2872 | { | |
2873 | outputFile = Subsections; | |
2874 | break; | |
2875 | } | |
2876 | case 4: | |
2877 | { | |
2878 | outputFile = Subsubsections; | |
2879 | break; | |
2880 | } | |
2881 | default: | |
2882 | { | |
2883 | outputFile = NULL; | |
2884 | break; | |
2885 | } | |
2886 | } | |
2887 | if (outputFile) | |
2888 | CurrentOutput1 = outputFile; | |
b63b07a8 | 2889 | return false; |
9a29912f JS |
2890 | } |
2891 | case 2: | |
2892 | { | |
b63b07a8 | 2893 | return true; |
9a29912f JS |
2894 | } |
2895 | default: | |
2896 | break; | |
2897 | } | |
b63b07a8 | 2898 | return true; |
9a29912f JS |
2899 | } |
2900 | else | |
2901 | { | |
2902 | if (arg_no == 2) | |
2903 | { | |
2904 | CurrentOutput1 = oldLevelFile; | |
2905 | } | |
b63b07a8 | 2906 | return true; |
9a29912f JS |
2907 | } |
2908 | } | |
2909 | default: | |
2910 | return DefaultOnArgument(macroId, arg_no, start); | |
9a29912f | 2911 | } |
b63b07a8 | 2912 | return true; |
9a29912f JS |
2913 | } |
2914 | ||
2915 | bool HTMLGo(void) | |
2916 | { | |
2917 | fileId = 0; | |
b63b07a8 | 2918 | inVerbatim = false; |
9a29912f | 2919 | indentLevel = 0; |
b63b07a8 RL |
2920 | inTabular = false; |
2921 | startRows = false; | |
2922 | tableVerticalLineLeft = false; | |
2923 | tableVerticalLineRight = false; | |
9a29912f JS |
2924 | noColumns = 0; |
2925 | ||
2926 | if (InputFile && OutputFile) | |
2927 | { | |
2928 | // Do some HTML-specific transformations on all the strings, | |
2929 | // recursively | |
2930 | Text2HTML(GetTopLevelChunk()); | |
2931 | ||
6c155d33 | 2932 | wxChar buf[300]; |
9a29912f | 2933 | if (truncateFilenames) |
b63b07a8 | 2934 | wxSnprintf(buf, sizeof(buf), _T("%s.htm"), FileRoot); |
9a29912f | 2935 | else |
b63b07a8 | 2936 | wxSnprintf(buf, sizeof(buf), _T("%s_contents.html"), FileRoot); |
9a29912f JS |
2937 | if (TitlepageName) delete[] TitlepageName; |
2938 | TitlepageName = copystring(buf); | |
6c155d33 | 2939 | Titlepage = wxFopen(buf, _T("w")); |
119f7a8c | 2940 | |
9a29912f | 2941 | if (truncateFilenames) |
b63b07a8 | 2942 | wxSnprintf(buf, sizeof(buf), _T("%s_fc.htm"), FileRoot); |
9a29912f | 2943 | else |
b63b07a8 | 2944 | wxSnprintf(buf, sizeof(buf), _T("%s_fcontents.html"), FileRoot); |
9a29912f JS |
2945 | |
2946 | contentsFrameName = copystring(buf); | |
2947 | ||
6c155d33 | 2948 | Contents = wxFopen(TmpContentsName, _T("w")); |
9a29912f JS |
2949 | |
2950 | if (htmlFrameContents) | |
2951 | { | |
6c155d33 JS |
2952 | // FrameContents = wxFopen(TmpFrameContentsName, _T("w")); |
2953 | FrameContents = wxFopen(contentsFrameName, _T("w")); | |
2954 | wxFprintf(FrameContents, _T("<HTML>\n<UL>\n")); | |
9a29912f JS |
2955 | } |
2956 | ||
2957 | if (!Titlepage || !Contents) | |
2958 | { | |
6c155d33 | 2959 | OnError(_T("Cannot open output file!")); |
b63b07a8 | 2960 | return false; |
9a29912f | 2961 | } |
6c155d33 | 2962 | AddTexRef(_T("contents"), wxFileNameFromPath(TitlepageName), ContentsNameString); |
9a29912f | 2963 | |
6c155d33 | 2964 | wxFprintf(Contents, _T("<P><P><H2>%s</H2><P><P>\n"), ContentsNameString); |
9a29912f | 2965 | |
6c155d33 | 2966 | wxFprintf(Contents, _T("<UL>\n")); |
9a29912f JS |
2967 | |
2968 | SetCurrentOutput(Titlepage); | |
14204c7a | 2969 | if (htmlWorkshopFiles) HTMLWorkshopStartContents(); |
6c155d33 | 2970 | OnInform(_T("Converting...")); |
9a29912f JS |
2971 | |
2972 | TraverseDocument(); | |
6c155d33 | 2973 | wxFprintf(Contents, _T("</UL>\n\n")); |
9a29912f JS |
2974 | |
2975 | // SetCurrentOutput(Titlepage); | |
2976 | fclose(Titlepage); | |
2977 | ||
2978 | if (Contents) | |
2979 | { | |
6c155d33 | 2980 | // wxFprintf(Titlepage, _T("\n</BODY></HTML>\n")); |
9a29912f JS |
2981 | fclose(Contents); |
2982 | Contents = NULL; | |
2983 | } | |
2984 | ||
2985 | if (FrameContents) | |
2986 | { | |
6c155d33 JS |
2987 | wxFprintf(FrameContents, _T("\n</UL>\n")); |
2988 | wxFprintf(FrameContents, _T("</HTML>\n")); | |
9a29912f JS |
2989 | fclose(FrameContents); |
2990 | FrameContents = NULL; | |
2991 | } | |
2992 | ||
2993 | if (Chapters) | |
2994 | { | |
6c155d33 | 2995 | wxFprintf(Chapters, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
2996 | fclose(Chapters); |
2997 | Chapters = NULL; | |
2998 | } | |
2999 | if (Sections) | |
3000 | { | |
6c155d33 | 3001 | wxFprintf(Sections, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
3002 | fclose(Sections); |
3003 | Sections = NULL; | |
3004 | } | |
3005 | if (Subsections && !combineSubSections) | |
3006 | { | |
6c155d33 | 3007 | wxFprintf(Subsections, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
3008 | fclose(Subsections); |
3009 | Subsections = NULL; | |
3010 | } | |
3011 | if (Subsubsections && !combineSubSections) | |
3012 | { | |
6c155d33 | 3013 | wxFprintf(Subsubsections, _T("\n</FONT></BODY></HTML>\n")); |
9a29912f JS |
3014 | fclose(Subsubsections); |
3015 | Subsubsections = NULL; | |
3016 | } | |
3017 | if ( SectionContentsFD ) | |
3018 | { | |
3019 | fclose(SectionContentsFD); | |
3020 | SectionContentsFD = NULL; | |
3021 | } | |
3022 | ||
3023 | // Create a temporary file for the title page header, add some info, | |
3024 | // and concat the titlepage just generated. | |
3025 | // This is necessary in order to put the title of the document | |
3026 | // at the TOP of the file within <HEAD>, even though we only find out | |
3027 | // what it is later on. | |
6c155d33 | 3028 | FILE *tmpTitle = wxFopen(_T("title.tmp"), _T("w")); |
9a29912f JS |
3029 | if (tmpTitle) |
3030 | { | |
3031 | if (DocumentTitle) | |
3032 | { | |
3033 | SetCurrentOutput(tmpTitle); | |
4fe30bce | 3034 | HTMLHead(); |
af318c88 | 3035 | TexOutput(_T("\n<TITLE>")); |
9a29912f | 3036 | TraverseChildrenFromChunk(DocumentTitle); |
6c155d33 | 3037 | TexOutput(_T("</TITLE></HEAD>\n")); |
9a29912f JS |
3038 | } |
3039 | else | |
3040 | { | |
3041 | SetCurrentOutput(tmpTitle); | |
4fe30bce | 3042 | HTMLHeadTo(tmpTitle); |
9a29912f | 3043 | if (contentsString) |
6c155d33 | 3044 | wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), contentsString); |
9a29912f | 3045 | else |
6c155d33 | 3046 | wxFprintf(tmpTitle, _T("<TITLE>%s</TITLE></HEAD>\n\n"), wxFileNameFromPath(FileRoot)); |
9a29912f | 3047 | } |
119f7a8c | 3048 | |
9a29912f JS |
3049 | // Output frame information |
3050 | if (htmlFrameContents) | |
3051 | { | |
6c155d33 | 3052 | wxChar firstFileName[300]; |
9a29912f | 3053 | if (truncateFilenames) |
b63b07a8 | 3054 | wxSnprintf(firstFileName, sizeof(firstFileName), _T("%s1.htm"), FileRoot); |
9a29912f | 3055 | else |
66828481 | 3056 | wxStrcpy(firstFileName, gs_filenames[1].c_str()); |
9a29912f | 3057 | |
6c155d33 | 3058 | wxFprintf(tmpTitle, _T("<FRAMESET COLS=\"30%%,70%%\">\n")); |
9a29912f | 3059 | |
6c155d33 JS |
3060 | wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\">\n"), ConvertCase(wxFileNameFromPath(contentsFrameName))); |
3061 | wxFprintf(tmpTitle, _T("<FRAME SRC=\"%s\" NAME=\"mainwindow\">\n"), ConvertCase(wxFileNameFromPath(firstFileName))); | |
3062 | wxFprintf(tmpTitle, _T("</FRAMESET>\n")); | |
119f7a8c | 3063 | |
6c155d33 | 3064 | wxFprintf(tmpTitle, _T("<NOFRAMES>\n")); |
9a29912f JS |
3065 | } |
3066 | ||
3067 | // Output <BODY...> to temporary title page | |
3068 | OutputBodyStart(); | |
af318c88 | 3069 | fflush(tmpTitle); |
119f7a8c | 3070 | |
9a29912f | 3071 | // Concat titlepage |
6c155d33 | 3072 | FILE *fd = wxFopen(TitlepageName, _T("r")); |
9a29912f JS |
3073 | if (fd) |
3074 | { | |
3075 | int ch = getc(fd); | |
3076 | while (ch != EOF) | |
3077 | { | |
7f997541 | 3078 | wxPutc(ch, tmpTitle); |
9a29912f JS |
3079 | ch = getc(fd); |
3080 | } | |
3081 | fclose(fd); | |
3082 | } | |
3083 | ||
6c155d33 | 3084 | wxFprintf(tmpTitle, _T("\n</FONT></BODY>\n")); |
9a29912f JS |
3085 | |
3086 | if (htmlFrameContents) | |
3087 | { | |
6c155d33 | 3088 | wxFprintf(tmpTitle, _T("\n</NOFRAMES>\n")); |
9a29912f | 3089 | } |
6c155d33 | 3090 | wxFprintf(tmpTitle, _T("\n</HTML>\n")); |
9a29912f JS |
3091 | |
3092 | fclose(tmpTitle); | |
2b5f62a0 | 3093 | if (wxFileExists(TitlepageName)) wxRemoveFile(TitlepageName); |
6c155d33 | 3094 | if (!wxRenameFile(_T("title.tmp"), TitlepageName)) |
9a29912f | 3095 | { |
6c155d33 JS |
3096 | wxCopyFile(_T("title.tmp"), TitlepageName); |
3097 | wxRemoveFile(_T("title.tmp")); | |
9a29912f JS |
3098 | } |
3099 | } | |
3100 | ||
3101 | if (lastFileName) delete[] lastFileName; | |
3102 | lastFileName = NULL; | |
3103 | if (lastTopic) delete[] lastTopic; | |
3104 | lastTopic = NULL; | |
3105 | ||
2b5f62a0 | 3106 | if (wxFileExists(ContentsName)) wxRemoveFile(ContentsName); |
9a29912f JS |
3107 | |
3108 | if (!wxRenameFile(TmpContentsName, ContentsName)) | |
3109 | { | |
3110 | wxCopyFile(TmpContentsName, ContentsName); | |
3111 | wxRemoveFile(TmpContentsName); | |
3112 | } | |
3113 | ||
3114 | // Generate .htx file if requested | |
3115 | if (htmlIndex) | |
3116 | { | |
6c155d33 | 3117 | wxChar htmlIndexName[300]; |
b63b07a8 | 3118 | wxSnprintf(htmlIndexName, sizeof(htmlIndexName), _T("%s.htx"), FileRoot); |
9a29912f JS |
3119 | GenerateHTMLIndexFile(htmlIndexName); |
3120 | } | |
3121 | ||
14204c7a VS |
3122 | // Generate HTML Help Workshop files if requested |
3123 | if (htmlWorkshopFiles) | |
3124 | { | |
3125 | HTMLWorkshopEndContents(); | |
3126 | GenerateHTMLWorkshopFiles(FileRoot); | |
3127 | } | |
3128 | ||
3129 | ||
b63b07a8 | 3130 | return true; |
9a29912f | 3131 | } |
14204c7a | 3132 | |
b63b07a8 | 3133 | return false; |
9a29912f JS |
3134 | } |
3135 | ||
3136 | // Output .htx index file | |
6c155d33 | 3137 | void GenerateHTMLIndexFile(wxChar *fname) |
9a29912f | 3138 | { |
6c155d33 | 3139 | FILE *fd = wxFopen(fname, _T("w")); |
9a29912f JS |
3140 | if (!fd) |
3141 | return; | |
3142 | ||
3143 | TopicTable.BeginFind(); | |
f6fe5318 | 3144 | wxHashTable::Node *node = TopicTable.Next(); |
6c155d33 | 3145 | while (node) |
9a29912f | 3146 | { |
ddc4f3b5 | 3147 | TexTopic *texTopic = (TexTopic *)node->GetData(); |
6c155d33 | 3148 | const wxChar *topicName = node->GetKeyString(); |
9a29912f JS |
3149 | if (texTopic->filename && texTopic->keywords) |
3150 | { | |
ddc4f3b5 | 3151 | wxStringListNode *node1 = texTopic->keywords->GetFirst(); |
9a29912f JS |
3152 | while (node1) |
3153 | { | |
6c155d33 JS |
3154 | wxChar *s = (wxChar *)node1->GetData(); |
3155 | wxFprintf(fd, _T("%s|%s|%s\n"), topicName, texTopic->filename, s); | |
ddc4f3b5 | 3156 | node1 = node1->GetNext(); |
9a29912f JS |
3157 | } |
3158 | } | |
6c155d33 | 3159 | node = TopicTable.Next(); |
9a29912f JS |
3160 | } |
3161 | fclose(fd); | |
3162 | } | |
14204c7a VS |
3163 | |
3164 | ||
3165 | ||
3166 | ||
3167 | ||
3168 | ||
3169 | ||
3170 | // output .hpp, .hhc and .hhk files: | |
3171 | ||
3172 | ||
6c155d33 | 3173 | void GenerateHTMLWorkshopFiles(wxChar *fname) |
14204c7a VS |
3174 | { |
3175 | FILE *f; | |
6c155d33 | 3176 | wxChar buf[300]; |
14204c7a VS |
3177 | |
3178 | /* Generate project file : */ | |
3179 | ||
b63b07a8 | 3180 | wxSnprintf(buf, sizeof(buf), _T("%s.hhp"), fname); |
6c155d33 JS |
3181 | f = wxFopen(buf, _T("wt")); |
3182 | wxFprintf(f, | |
3183 | _T("[OPTIONS]\n") | |
3184 | _T("Compatibility=1.1\n") | |
3185 | _T("Full-text search=Yes\n") | |
3186 | _T("Contents file=%s.hhc\n") | |
3187 | _T("Compiled file=%s.chm\n") | |
3188 | _T("Default Window=%sHelp\n") | |
3189 | _T("Default topic=%s\n") | |
3190 | _T("Index file=%s.hhk\n") | |
3191 | _T("Title="), | |
2b5f62a0 VZ |
3192 | wxFileNameFromPath(fname), |
3193 | wxFileNameFromPath(fname), | |
3194 | wxFileNameFromPath(fname), | |
3195 | wxFileNameFromPath(TitlepageName), | |
3196 | wxFileNameFromPath(fname) | |
14204c7a | 3197 | ); |
119f7a8c | 3198 | |
14204c7a VS |
3199 | if (DocumentTitle) { |
3200 | SetCurrentOutput(f); | |
3201 | TraverseChildrenFromChunk(DocumentTitle); | |
3202 | } | |
6c155d33 | 3203 | else wxFprintf(f, _T("(unknown)")); |
119f7a8c | 3204 | |
6c155d33 JS |
3205 | wxFprintf(f, _T("\n\n[WINDOWS]\n") |
3206 | _T("%sHelp=,\"%s.hhc\",\"%s.hhk\",\"%s\",,,,,,0x2420,,0x380e,,,,,0,,,"), | |
2b5f62a0 VZ |
3207 | wxFileNameFromPath(fname), |
3208 | wxFileNameFromPath(fname), | |
3209 | wxFileNameFromPath(fname), | |
3210 | wxFileNameFromPath(TitlepageName)); | |
119f7a8c RD |
3211 | |
3212 | ||
6c155d33 JS |
3213 | wxFprintf(f, _T("\n\n[FILES]\n")); |
3214 | wxFprintf(f, _T("%s\n"), wxFileNameFromPath(TitlepageName)); | |
119f7a8c | 3215 | for (int i = 1; i <= fileId; i++) { |
14204c7a | 3216 | if (truncateFilenames) |
b63b07a8 | 3217 | wxSnprintf(buf, sizeof(buf), _T("%s%d.htm"), wxFileNameFromPath(FileRoot), i); |
14204c7a | 3218 | else |
66828481 | 3219 | wxStrcpy(buf, wxFileNameFromPath(gs_filenames[i].c_str())); |
6c155d33 | 3220 | wxFprintf(f, _T("%s\n"), buf); |
14204c7a VS |
3221 | } |
3222 | fclose(f); | |
3223 | ||
3224 | /* Generate index file : */ | |
3225 | ||
b63b07a8 | 3226 | wxSnprintf(buf, sizeof(buf), _T("%s.hhk"), fname); |
6c155d33 | 3227 | f = wxFopen(buf, _T("wt")); |
14204c7a | 3228 | |
6c155d33 JS |
3229 | wxFprintf(f, |
3230 | _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n") | |
3231 | _T("<HTML>\n")); | |
6d8b260c | 3232 | HTMLHeadTo(f); |
6c155d33 JS |
3233 | wxFprintf(f, |
3234 | _T("\n") | |
3235 | _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n") | |
3236 | _T("<!-- Sitemap 1.0 -->\n") | |
3237 | _T("</HEAD><BODY>\n") | |
3238 | _T("<OBJECT type=\"text/site properties\">\n") | |
3239 | _T(" <param name=\"ImageType\" value=\"Folder\">\n") | |
3240 | _T("</OBJECT>\n") | |
3241 | _T("<UL>\n")); | |
14204c7a VS |
3242 | |
3243 | TopicTable.BeginFind(); | |
f6fe5318 | 3244 | wxHashTable::Node *node = TopicTable.Next(); |
6c155d33 | 3245 | while (node) |
14204c7a | 3246 | { |
ddc4f3b5 | 3247 | TexTopic *texTopic = (TexTopic *)node->GetData(); |
6c155d33 | 3248 | const wxChar *topicName = node->GetKeyString(); |
14204c7a VS |
3249 | if (texTopic->filename && texTopic->keywords) |
3250 | { | |
ddc4f3b5 | 3251 | wxStringListNode *node1 = texTopic->keywords->GetFirst(); |
14204c7a VS |
3252 | while (node1) |
3253 | { | |
6c155d33 JS |
3254 | wxChar *s = (wxChar *)node1->GetData(); |
3255 | wxFprintf(f, | |
3256 | _T(" <LI> <OBJECT type=\"text/sitemap\">\n") | |
3257 | _T(" <param name=\"Local\" value=\"%s#%s\">\n") | |
3258 | _T(" <param name=\"Name\" value=\"%s\">\n") | |
3259 | _T(" </OBJECT>\n"), | |
4fe30bce | 3260 | texTopic->filename, topicName, s); |
ddc4f3b5 | 3261 | node1 = node1->GetNext(); |
14204c7a VS |
3262 | } |
3263 | } | |
6c155d33 | 3264 | node = TopicTable.Next(); |
14204c7a | 3265 | } |
119f7a8c | 3266 | |
6c155d33 | 3267 | wxFprintf(f, _T("</UL>\n")); |
14204c7a VS |
3268 | fclose(f); |
3269 | } | |
3270 | ||
3271 | ||
3272 | ||
3273 | static FILE *HTMLWorkshopContents = NULL; | |
3274 | static int HTMLWorkshopLastLevel = 0; | |
3275 | ||
6c155d33 | 3276 | void HTMLWorkshopAddToContents(int level, wxChar *s, wxChar *file) |
14204c7a VS |
3277 | { |
3278 | int i; | |
3279 | ||
3280 | if (level > HTMLWorkshopLastLevel) | |
3281 | for (i = HTMLWorkshopLastLevel; i < level; i++) | |
6c155d33 | 3282 | wxFprintf(HTMLWorkshopContents, _T("<UL>")); |
14204c7a VS |
3283 | if (level < HTMLWorkshopLastLevel) |
3284 | for (i = level; i < HTMLWorkshopLastLevel; i++) | |
6c155d33 | 3285 | wxFprintf(HTMLWorkshopContents, _T("</UL>")); |
119f7a8c | 3286 | |
14204c7a | 3287 | SetCurrentOutput(HTMLWorkshopContents); |
6c155d33 JS |
3288 | wxFprintf(HTMLWorkshopContents, |
3289 | _T(" <LI> <OBJECT type=\"text/sitemap\">\n") | |
3290 | _T(" <param name=\"Local\" value=\"%s#%s\">\n") | |
3291 | _T(" <param name=\"Name\" value=\""), | |
4fe30bce | 3292 | file, s); |
14204c7a | 3293 | OutputCurrentSection(); |
6c155d33 | 3294 | wxFprintf(HTMLWorkshopContents, |
4fe30bce | 3295 | _T("\">\n") |
6c155d33 | 3296 | _T(" </OBJECT>\n")); |
14204c7a VS |
3297 | HTMLWorkshopLastLevel = level; |
3298 | } | |
3299 | ||
3300 | ||
3301 | void HTMLWorkshopStartContents() | |
3302 | { | |
6c155d33 | 3303 | wxChar buf[300]; |
b63b07a8 | 3304 | wxSnprintf(buf, sizeof(buf), _T("%s.hhc"), FileRoot); |
6c155d33 | 3305 | HTMLWorkshopContents = wxFopen(buf, _T("wt")); |
14204c7a VS |
3306 | HTMLWorkshopLastLevel = 0; |
3307 | ||
6c155d33 JS |
3308 | wxFprintf(HTMLWorkshopContents, |
3309 | _T("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n") | |
3310 | _T("<HTML>\n")); | |
6d8b260c | 3311 | HTMLHeadTo(HTMLWorkshopContents); |
6c155d33 JS |
3312 | wxFprintf(HTMLWorkshopContents, |
3313 | _T("\n") | |
3314 | _T("<meta name=\"GENERATOR\" content=\"tex2rtf\">\n") | |
3315 | _T("<!-- Sitemap 1.0 -->\n") | |
3316 | _T("</HEAD><BODY>\n") | |
3317 | _T("<OBJECT type=\"text/site properties\">\n") | |
3318 | _T(" <param name=\"ImageType\" value=\"Folder\">\n") | |
3319 | _T("</OBJECT>\n") | |
3320 | _T("<UL>\n") | |
3321 | _T("<LI> <OBJECT type=\"text/sitemap\">\n") | |
3322 | _T("<param name=\"Local\" value=\"%s\">\n") | |
3323 | _T("<param name=\"Name\" value=\"Contents\">\n</OBJECT>\n"), | |
2b5f62a0 | 3324 | wxFileNameFromPath(TitlepageName) |
119f7a8c RD |
3325 | ); |
3326 | ||
14204c7a VS |
3327 | } |
3328 | ||
3329 | ||
3330 | void HTMLWorkshopEndContents() | |
3331 | { | |
3332 | for (int i = HTMLWorkshopLastLevel; i >= 0; i--) | |
6c155d33 | 3333 | wxFprintf(HTMLWorkshopContents, _T("</UL>\n")); |
14204c7a VS |
3334 | fclose(HTMLWorkshopContents); |
3335 | } |