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