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