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