mmd-ruby 5.2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +78 -0
  3. data/MultiMarkdown-5/src/GLibFacade.c +310 -0
  4. data/MultiMarkdown-5/src/GLibFacade.h +100 -0
  5. data/MultiMarkdown-5/src/beamer.c +182 -0
  6. data/MultiMarkdown-5/src/beamer.h +11 -0
  7. data/MultiMarkdown-5/src/critic.c +117 -0
  8. data/MultiMarkdown-5/src/critic.h +15 -0
  9. data/MultiMarkdown-5/src/glib.h +11 -0
  10. data/MultiMarkdown-5/src/html.c +1171 -0
  11. data/MultiMarkdown-5/src/html.h +14 -0
  12. data/MultiMarkdown-5/src/latex.c +1234 -0
  13. data/MultiMarkdown-5/src/latex.h +16 -0
  14. data/MultiMarkdown-5/src/libMultiMarkdown.h +257 -0
  15. data/MultiMarkdown-5/src/lyx.c +2269 -0
  16. data/MultiMarkdown-5/src/lyx.h +37 -0
  17. data/MultiMarkdown-5/src/lyxbeamer.c +265 -0
  18. data/MultiMarkdown-5/src/lyxbeamer.h +11 -0
  19. data/MultiMarkdown-5/src/memoir.c +80 -0
  20. data/MultiMarkdown-5/src/memoir.h +10 -0
  21. data/MultiMarkdown-5/src/multimarkdown.c +559 -0
  22. data/MultiMarkdown-5/src/odf.c +1241 -0
  23. data/MultiMarkdown-5/src/odf.h +18 -0
  24. data/MultiMarkdown-5/src/opml.c +189 -0
  25. data/MultiMarkdown-5/src/opml.h +15 -0
  26. data/MultiMarkdown-5/src/parse_utilities.c +912 -0
  27. data/MultiMarkdown-5/src/parser.c +17341 -0
  28. data/MultiMarkdown-5/src/parser.h +190 -0
  29. data/MultiMarkdown-5/src/rng.c +117 -0
  30. data/MultiMarkdown-5/src/rtf.c +665 -0
  31. data/MultiMarkdown-5/src/rtf.h +17 -0
  32. data/MultiMarkdown-5/src/strtok.c +56 -0
  33. data/MultiMarkdown-5/src/strtok.h +9 -0
  34. data/MultiMarkdown-5/src/text.c +56 -0
  35. data/MultiMarkdown-5/src/text.h +11 -0
  36. data/MultiMarkdown-5/src/toc.c +157 -0
  37. data/MultiMarkdown-5/src/toc.h +15 -0
  38. data/MultiMarkdown-5/src/transclude.c +335 -0
  39. data/MultiMarkdown-5/src/transclude.h +28 -0
  40. data/MultiMarkdown-5/src/version.h +59 -0
  41. data/MultiMarkdown-5/src/writer.c +767 -0
  42. data/MultiMarkdown-5/src/writer.h +38 -0
  43. data/README.md +77 -0
  44. data/Rakefile +88 -0
  45. data/bin/mmd-ruby +123 -0
  46. data/ext/extconf.h +3 -0
  47. data/ext/extconf.rb +10 -0
  48. data/ext/multimarkdown.c +133 -0
  49. data/lib/mmd-jekyll.rb +19 -0
  50. data/lib/mmd-ruby.rb +1 -0
  51. data/lib/mmd.rb +1 -0
  52. data/lib/multimarkdown-ruby.rb +1 -0
  53. data/lib/multimarkdown.bundle +0 -0
  54. data/lib/multimarkdown.rb +69 -0
  55. data/lib/multimarkdown/version.rb +6 -0
  56. data/mmd-ruby.gemspec +37 -0
  57. data/test/extensions_test.rb +174 -0
  58. data/test/multimarkdown_test.rb +77 -0
  59. metadata +120 -0
@@ -0,0 +1,1241 @@
1
+ /*
2
+
3
+ odf.c -- ODF (Flat OpenDocument format) writer
4
+
5
+ (c) 2013-2016 Fletcher T. Penney (http://fletcherpenney.net/).
6
+
7
+ This program is free software; you can redistribute it and/or modify
8
+ it under the terms of the GNU General Public License or the MIT
9
+ license. See LICENSE for details.
10
+
11
+ This program is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ GNU General Public License for more details.
15
+
16
+ */
17
+
18
+ #include "odf.h"
19
+
20
+ /* begin_odf_output -- handle the initial prefix, if any */
21
+ void begin_odf_output(GString *out, node* list, scratch_pad *scratch) {
22
+ #ifdef DEBUG_ON
23
+ fprintf(stderr, "begin_odf_output\n");
24
+ #endif
25
+ print_odf_header(out);
26
+
27
+ if (list == NULL) {
28
+ g_string_append_printf(out, "<office:body>\n<office:text>\n");
29
+ }
30
+ }
31
+
32
+ /* end_odf_output -- close the document */
33
+ void end_odf_output(GString *out, node* list, scratch_pad *scratch) {
34
+ #ifdef DEBUG_ON
35
+ fprintf(stderr, "end_odf_output\n");
36
+ #endif
37
+ print_odf_footer(out);
38
+ }
39
+
40
+ /* print_odf_node_tree -- convert node tree to LaTeX */
41
+ void print_odf_node_tree(GString *out, node *list, scratch_pad *scratch) {
42
+ #ifdef DEBUG_ON
43
+ fprintf(stderr, "print_odf_node_tree\n");
44
+ #endif
45
+ while (list != NULL) {
46
+ print_odf_node(out, list, scratch);
47
+ list = list->next;
48
+ }
49
+ }
50
+
51
+ /* print_odf_node -- convert given node to odf and append */
52
+ void print_odf_node(GString *out, node *n, scratch_pad *scratch) {
53
+ node *temp_node;
54
+ link_data *temp_link_data = NULL;
55
+ char *temp;
56
+ int lev;
57
+ int old_type;
58
+ char *width = NULL;
59
+ char *height = NULL;
60
+ GString *temp_str;
61
+ int i;
62
+
63
+ if (n == NULL)
64
+ return;
65
+
66
+ /* debugging statement */
67
+ #ifdef DEBUG_ON
68
+ fprintf(stderr, "print_odf_node: %d\n",n->key);
69
+ #endif
70
+
71
+ /* If we are forcing a complete document, and METADATA isn't the first thing,
72
+ we need to close <head> */
73
+ if (!(scratch->extensions & EXT_HEAD_CLOSED) &&
74
+ !((n->key == FOOTER) || (n->key == METADATA))) {
75
+ g_string_append_printf(out, "<office:body>\n<office:text>\n");
76
+ scratch->extensions = scratch->extensions | EXT_HEAD_CLOSED;
77
+ }
78
+
79
+ switch (n->key) {
80
+ case NO_TYPE:
81
+ case ABBREVIATION:
82
+ break;
83
+ case LIST:
84
+ print_odf_node_tree(out,n->children,scratch);
85
+ break;
86
+ case STR:
87
+ case ABBR:
88
+ case ABBRSTART:
89
+ case ABBRSTOP:
90
+ /* TODO: Need something a bit better here for abbreviations */
91
+ print_html_string(out,n->str, scratch);
92
+ break;
93
+ case SPACE:
94
+ g_string_append_printf(out,"%s",n->str);
95
+ break;
96
+ case PLAIN:
97
+ pad(out,1, scratch);
98
+ print_odf_node_tree(out,n->children, scratch);
99
+ scratch->padded = 0;
100
+ break;
101
+ case PARA:
102
+ pad(out, 2, scratch);
103
+ g_string_append_printf(out, "<text:p");
104
+ switch (scratch->odf_para_type) {
105
+ case DEFINITION:
106
+ case BLOCKQUOTE:
107
+ g_string_append_printf(out, " text:style-name=\"Quotations\"");
108
+ break;
109
+ case CODE:
110
+ case VERBATIM:
111
+ case VERBATIMFENCE:
112
+ g_string_append_printf(out, " text:style-name=\"Preformatted Text\"");
113
+ break;
114
+ case ORDEREDLIST:
115
+ g_string_append_printf(out, " text:style-name=\"P2\"");
116
+ break;
117
+ case BULLETLIST:
118
+ g_string_append_printf(out, " text:style-name=\"P1\"");
119
+ break;
120
+ case NOTEREFERENCE:
121
+ case NOTESOURCE:
122
+ case CITATION:
123
+ case NOCITATION:
124
+ g_string_append_printf(out, " text:style-name=\"Footnote\"");
125
+ break;
126
+ default:
127
+ g_string_append_printf(out, " text:style-name=\"Standard\"");
128
+ break;
129
+ }
130
+ g_string_append_printf(out, ">");
131
+ print_odf_node_tree(out,n->children,scratch);
132
+ g_string_append_printf(out, "</text:p>\n");
133
+ scratch->padded = 1;
134
+ break;
135
+ case HRULE:
136
+ pad(out, 2, scratch);
137
+ g_string_append_printf(out,"<text:p text:style-name=\"Horizontal_20_Line\"/>");
138
+ scratch->padded = 0;
139
+ break;
140
+ case HTMLBLOCK:
141
+ /* don't print HTML block */
142
+ /* but do print HTML comments for raw LaTeX */
143
+ if (strncmp(n->str,"<!--",4) == 0) {
144
+ pad(out, 2, scratch);
145
+ /* trim "-->" from end */
146
+ n->str[strlen(n->str)-3] = '\0';
147
+ g_string_append_printf(out, "<text:p text:style-name=\"Standard\">%s</text:p>", &n->str[4]);
148
+ scratch->padded = 0;
149
+ }
150
+ break;
151
+ case VERBATIM:
152
+ case VERBATIMFENCE:
153
+ old_type = scratch->odf_para_type;
154
+ scratch->odf_para_type = VERBATIM;
155
+ pad(out, 2, scratch);
156
+ g_string_append_printf(out, "<text:p text:style-name=\"Preformatted Text\">");
157
+ print_odf_code_string(out, n->str);
158
+ g_string_append_printf(out, "</text:p>\n");
159
+ scratch->padded = 0;
160
+ scratch->odf_para_type = old_type;
161
+ break;
162
+ case BULLETLIST:
163
+ case ORDEREDLIST:
164
+ old_type = scratch->odf_para_type;
165
+ scratch->odf_para_type = n->key;
166
+ if (scratch->odf_list_needs_end_p) {
167
+ g_string_append_printf(out, "</text:p>");
168
+ scratch->odf_list_needs_end_p = false;
169
+ }
170
+ pad(out, 2, scratch);
171
+ switch (n->key) {
172
+ case BULLETLIST:
173
+ g_string_append_printf(out, "<text:list text:style-name=\"L1\">");
174
+ break;
175
+ case ORDEREDLIST:
176
+ g_string_append_printf(out, "<text:list text:style-name=\"L2\">");
177
+ break;
178
+ }
179
+ scratch->padded = 1;
180
+ print_odf_node_tree(out, n->children, scratch);
181
+ pad(out, 1, scratch);
182
+ g_string_append_printf(out, "</text:list>");
183
+ scratch->padded = 0;
184
+ scratch->odf_para_type = old_type;
185
+ break;
186
+ case LISTITEM:
187
+ #ifdef DEBUG_ON
188
+ fprintf(stderr, "print list item\n");
189
+ #endif
190
+ pad(out, 1, scratch);
191
+ g_string_append_printf(out, "<text:list-item>\n");
192
+ if ((n->children != NULL) && (n->children->children != NULL) && (n->children->children->key != PARA)) {
193
+ switch (scratch->odf_para_type) {
194
+ case BULLETLIST:
195
+ g_string_append_printf(out, "<text:p text:style-name=\"P1\">");
196
+ break;
197
+ case ORDEREDLIST:
198
+ g_string_append_printf(out, "<text:p text:style-name=\"P2\">");
199
+ break;
200
+ }
201
+ scratch->odf_list_needs_end_p = true;
202
+ } else if ((n->children != NULL) &&
203
+ (((n->children->key == LIST) && (n->children->children == NULL)) ||
204
+ ((n->children->key == STR) && (strlen(n->children->str) == 0)))) {
205
+ /* This is an empty list item. ODF apparently requires something for the empty item to appear */
206
+ switch (scratch->odf_para_type) {
207
+ case BULLETLIST:
208
+ g_string_append_printf(out, "<text:p text:style-name=\"P1\"/>");
209
+ break;
210
+ case ORDEREDLIST:
211
+ g_string_append_printf(out, "<text:p text:style-name=\"P2\"/>");
212
+ break;
213
+ }
214
+ }
215
+ scratch->padded = 2;
216
+ print_odf_node_tree(out, n->children, scratch);
217
+ scratch->odf_list_needs_end_p = false;
218
+ #ifdef DEBUG_ON
219
+ fprintf(stderr, "print list tree\n");
220
+ #endif
221
+ if (!(tree_contains_key(n->children, BULLETLIST)) &&
222
+ !(tree_contains_key(n->children, ORDEREDLIST))) {
223
+ if ((n->children != NULL) && (n->children->children != NULL) && (n->children->children->key != PARA))
224
+ g_string_append_printf(out, "</text:p>");
225
+ }
226
+ g_string_append_printf(out, "</text:list-item>\n");
227
+ scratch->padded = 1;
228
+ #ifdef DEBUG_ON
229
+ fprintf(stderr, "finish print list item\n");
230
+ #endif
231
+ break;
232
+ case METADATA:
233
+ g_string_append_printf(out, "<office:meta>\n");
234
+ scratch->extensions = scratch->extensions | EXT_HEAD_CLOSED;
235
+ print_odf_node_tree(out, n->children, scratch);
236
+ g_string_append_printf(out, "</office:meta>\n");
237
+ temp_node = metadata_for_key("odfheader", n);
238
+ if (temp_node != NULL) {
239
+ print_raw_node(out, temp_node->children);
240
+ }
241
+ g_string_append_printf(out, "<office:body>\n<office:text>\n");
242
+ break;
243
+ case METAKEY:
244
+ temp = label_from_string(n->str);
245
+ if (strcmp(temp, "title") == 0) {
246
+ g_string_append_printf(out, "<dc:title>");
247
+ print_odf_node(out, n->children, scratch);
248
+ g_string_append_printf(out, "</dc:title>\n");
249
+ } else if (strcmp(temp, "css") == 0) {
250
+ } else if (strcmp(temp, "xhtmlheader") == 0) {
251
+ } else if (strcmp(temp, "htmlheader") == 0) {
252
+ } else if (strcmp(temp, "htmlfooter") == 0) {
253
+ } else if (strcmp(temp, "mmdfooter") == 0) {
254
+ } else if (strcmp(temp, "mmdheader") == 0) {
255
+ } else if (strcmp(temp, "baseheaderlevel") == 0) {
256
+ scratch->baseheaderlevel = atoi(n->children->str);
257
+ } else if (strcmp(temp, "odfheaderlevel") == 0) {
258
+ scratch->baseheaderlevel = atoi(n->children->str);
259
+ } else if (strcmp(temp, "htmlheaderlevel") == 0) {
260
+ } else if (strcmp(temp, "latexinput") == 0) {
261
+ } else if (strcmp(temp, "latexfooter") == 0) {
262
+ } else if (strcmp(temp, "latexmode") == 0) {
263
+ } else if (strcmp(temp, "keywords") == 0) {
264
+ g_string_append_printf(out, "<meta:keyword>");
265
+ print_odf_node(out, n->children, scratch);
266
+ g_string_append_printf(out, "</meta:keyword>\n");
267
+ } else if (strcmp(temp, "quoteslanguage") == 0) {
268
+ free(temp);
269
+ temp = label_from_node_tree(n->children);
270
+ if ((strcmp(temp, "nl") == 0) || (strcmp(temp, "dutch") == 0)) { scratch->language = DUTCH; } else
271
+ if ((strcmp(temp, "de") == 0) || (strcmp(temp, "german") == 0)) { scratch->language = GERMAN; } else
272
+ if (strcmp(temp, "germanguillemets") == 0) { scratch->language = GERMANGUILL; } else
273
+ if ((strcmp(temp, "fr") == 0) || (strcmp(temp, "french") == 0)) { scratch->language = FRENCH; } else
274
+ if ((strcmp(temp, "sv") == 0) || (strcmp(temp, "swedish") == 0)) { scratch->language = SWEDISH; }
275
+ } else if (strcmp(temp, "lang") == 0) {
276
+ } else {
277
+ g_string_append_printf(out,"<meta:user-defined meta:name=\"");
278
+ print_odf_string(out, n->str);
279
+ g_string_append_printf(out, "\">");
280
+ print_odf_node(out,n->children,scratch);
281
+ g_string_append_printf(out,"</meta:user-defined>\n");
282
+ }
283
+ free(temp);
284
+ break;
285
+ case METAVALUE:
286
+ trim_trailing_whitespace(n->str);
287
+ print_odf_string(out,n->str);
288
+ break;
289
+ case FOOTER:
290
+ break;
291
+ case HEADINGSECTION:
292
+ print_odf_node_tree(out,n->children,scratch);
293
+ break;
294
+ case H1: case H2: case H3: case H4: case H5: case H6:
295
+ lev = n->key - H1 + scratch->baseheaderlevel; /* assumes H1 ... H6 are in order */
296
+ pad(out, 2, scratch);
297
+ g_string_append_printf(out, "<text:h text:outline-level=\"%d\">", lev);
298
+ if (n->children->key == AUTOLABEL) {
299
+ /* use label for header since one was specified (MMD)*/
300
+ temp = label_from_string(n->children->str);
301
+ g_string_append_printf(out, "<text:bookmark text:name=\"%s\"/>", temp);
302
+ print_odf_node_tree(out, n->children->next, scratch);
303
+ g_string_append_printf(out, "<text:bookmark-end text:name=\"%s\"/>", temp);
304
+ free(temp);
305
+ } else {
306
+ /* generate a label by default for MMD */
307
+ temp = label_from_node_tree(n->children);
308
+ g_string_append_printf(out, "<text:bookmark text:name=\"%s\"/>", temp);
309
+ print_odf_node_tree(out, n->children, scratch);
310
+ g_string_append_printf(out, "<text:bookmark-end text:name=\"%s\"/>", temp);
311
+ free(temp);
312
+ }
313
+ g_string_append_printf(out, "</text:h>");
314
+ scratch->padded = 0;
315
+ break;
316
+ case APOSTROPHE:
317
+ print_html_localized_typography(out, APOS, scratch);
318
+ break;
319
+ case ELLIPSIS:
320
+ print_html_localized_typography(out, ELLIP, scratch);
321
+ break;
322
+ case EMDASH:
323
+ print_html_localized_typography(out, MDASH, scratch);
324
+ break;
325
+ case ENDASH:
326
+ print_html_localized_typography(out, NDASH, scratch);
327
+ break;
328
+ case SINGLEQUOTED:
329
+ print_html_localized_typography(out, LSQUOTE, scratch);
330
+ print_odf_node_tree(out, n->children, scratch);
331
+ print_html_localized_typography(out, RSQUOTE, scratch);
332
+ break;
333
+ case DOUBLEQUOTED:
334
+ print_html_localized_typography(out, LDQUOTE, scratch);
335
+ print_odf_node_tree(out, n->children, scratch);
336
+ print_html_localized_typography(out, RDQUOTE, scratch);
337
+ break;
338
+ case LINEBREAK:
339
+ g_string_append_printf(out, "<text:line-break/>");
340
+ break;
341
+ case MATHSPAN:
342
+ temp = strdup(n->str);
343
+ if (temp[0] == '$') {
344
+ g_string_append_printf(out, "<text:span text:style-name=\"math\">%s</text:span>",temp);
345
+ } else if (temp[strlen(temp) - 1] == ']') {
346
+ temp[strlen(temp) - 3] = '\0';
347
+ g_string_append_printf(out, "<text:span text:style-name=\"math\">%s\\]</text:span>",temp);
348
+ } else {
349
+ temp[strlen(temp) - 3] = '\0';
350
+ g_string_append_printf(out, "<text:span text:style-name=\"math\">%s\\)</text:span>",temp);
351
+ }
352
+ free(temp);
353
+ break;
354
+ case STRONG:
355
+ g_string_append_printf(out, "<text:span text:style-name=\"MMD-Bold\">");
356
+ print_odf_node_tree(out,n->children,scratch);
357
+ g_string_append_printf(out, "</text:span>");
358
+ break;
359
+ case EMPH:
360
+ g_string_append_printf(out, "<text:span text:style-name=\"MMD-Italic\">");
361
+ print_odf_node_tree(out,n->children,scratch);
362
+ g_string_append_printf(out, "</text:span>");
363
+ break;
364
+ case LINKREFERENCE:
365
+ break;
366
+ case LINK:
367
+ #ifdef DEBUG_ON
368
+ fprintf(stderr, "print odf link: '%s'\n",n->str);
369
+ #endif
370
+ /* Stash a copy of the link data */
371
+ if (n->link_data != NULL)
372
+ temp_link_data = mk_link_data(n->link_data->label, n->link_data->source, n->link_data->title, n->link_data->attr);
373
+
374
+ /* Do we have proper info? */
375
+ if (n->link_data == NULL) {
376
+ /* NULL link_data could occur if we parsed this link before and it didn't
377
+ match anything */
378
+ n->link_data = mk_link_data(NULL, NULL, NULL, NULL);
379
+ }
380
+
381
+ if ((n->link_data->label == NULL) &&
382
+ (n->link_data->source == NULL)) {
383
+ #ifdef DEBUG_ON
384
+ fprintf(stderr, "print odf link: '%s'\n",n->str);
385
+ #endif
386
+ /* we seem to be a [foo][] style link */
387
+ /* so load a label */
388
+ temp_str = g_string_new("");
389
+ print_raw_node_tree(temp_str, n->children);
390
+ free(n->link_data->label);
391
+ n->link_data->label = temp_str->str;
392
+ g_string_free(temp_str, FALSE);
393
+ }
394
+ #ifdef DEBUG_ON
395
+ fprintf(stderr, "look for reference data for odf link: '%s'\n",n->str);
396
+ #endif
397
+ /* Load reference data */
398
+ if (n->link_data->label != NULL) {
399
+ #ifdef DEBUG_ON
400
+ fprintf(stderr, "have label for odf link: '%s'\n",n->str);
401
+ #endif
402
+ temp = strdup(n->link_data->label);
403
+ free_link_data(n->link_data);
404
+ n->link_data = extract_link_data(temp, scratch);
405
+ if (n->link_data == NULL) {
406
+ /* replace original text since no definition found */
407
+ g_string_append_printf(out, "[");
408
+ print_odf_node(out, n->children, scratch);
409
+ g_string_append_printf(out,"]");
410
+ if (n->children->next != NULL) {
411
+ g_string_append_printf(out, "[");
412
+ print_odf_node_tree(out, n->children->next, scratch);
413
+ g_string_append_printf(out,"]");
414
+ } else if (n->str != NULL) {
415
+ /* no title label, so see if we stashed str*/
416
+ g_string_append_printf(out, "%s", n->str);
417
+ } else {
418
+ g_string_append_printf(out, "[%s]",temp);
419
+ }
420
+
421
+ free(temp);
422
+
423
+ /* Restore stashed copy */
424
+ n->link_data = temp_link_data;
425
+
426
+ break;
427
+ }
428
+ free(temp);
429
+ }
430
+ #ifdef DEBUG_ON
431
+ fprintf(stderr, "got link data for odf link: '%s'\n",n->str);
432
+ #endif
433
+ g_string_append_printf(out, "<text:a xlink:type=\"simple\"");
434
+ if (n->link_data->source != NULL) {
435
+ g_string_append_printf(out, " xlink:href=\"");
436
+ print_html_string(out,n->link_data->source, scratch);
437
+ g_string_append_printf(out, "\"");
438
+ }
439
+ if ((n->link_data->title != NULL) && (strlen(n->link_data->title) > 0)) {
440
+ g_string_append_printf(out, " office:name=\"");
441
+ print_html_string(out, n->link_data->title, scratch);
442
+ g_string_append_printf(out, "\"");
443
+ }
444
+ print_odf_node_tree(out, n->link_data->attr, scratch);
445
+ g_string_append_printf(out, ">");
446
+ if (n->children != NULL)
447
+ print_odf_node_tree(out,n->children,scratch);
448
+ g_string_append_printf(out, "</text:a>");
449
+
450
+ /* Restore stashed copy */
451
+ n->link_data->attr = NULL;
452
+ free_link_data(n->link_data);
453
+ n->link_data = temp_link_data;
454
+
455
+ break;
456
+ case ATTRKEY:
457
+ if ( (strcmp(n->str,"height") == 0) || (strcmp(n->str, "width") == 0)) {
458
+ }
459
+ break;
460
+ case REFNAME:
461
+ case SOURCE:
462
+ case TITLE:
463
+ break;
464
+ case IMAGEBLOCK:
465
+ pad(out,2, scratch);
466
+ case IMAGE:
467
+ #ifdef DEBUG_ON
468
+ fprintf(stderr, "print image\n");
469
+ #endif
470
+ /* Stash a copy of the link data */
471
+ if (n->link_data != NULL)
472
+ temp_link_data = mk_link_data(n->link_data->label, n->link_data->source, n->link_data->title, n->link_data->attr);
473
+
474
+ if (n->key == IMAGEBLOCK)
475
+ g_string_append_printf(out, "<text:p>\n");
476
+ /* Do we have proper info? */
477
+ if ((n->link_data->label == NULL) &&
478
+ (n->link_data->source == NULL)) {
479
+ /* we seem to be a [foo][] style link */
480
+ /* so load a label */
481
+ temp_str = g_string_new("");
482
+ print_raw_node_tree(temp_str, n->children);
483
+ n->link_data->label = temp_str->str;
484
+ g_string_free(temp_str, FALSE);
485
+ }
486
+ #ifdef DEBUG_ON
487
+ fprintf(stderr, "load reference data\n");
488
+ #endif
489
+ /* Load reference data */
490
+ if (n->link_data->label != NULL) {
491
+ temp = strdup(n->link_data->label);
492
+ free_link_data(n->link_data);
493
+ n->link_data = extract_link_data(temp, scratch);
494
+ if (n->link_data == NULL) {
495
+ g_string_append_printf(out, "![");
496
+ print_html_node_tree(out, n->children, scratch);
497
+ g_string_append_printf(out,"][%s]",temp);
498
+
499
+ /* Restore stashed copy */
500
+ n->link_data = temp_link_data;
501
+
502
+ free(temp);
503
+
504
+ break;
505
+ }
506
+ free(temp);
507
+ }
508
+ #ifdef DEBUG_ON
509
+ fprintf(stderr, "create img\n");
510
+ #endif
511
+ g_string_append_printf(out, "<draw:frame text:anchor-type=\"as-char\"\ndraw:z-index=\"0\" draw:style-name=\"fr1\" ");
512
+
513
+ if (n->link_data->attr != NULL) {
514
+ temp_node = node_for_attribute("height",n->link_data->attr);
515
+ if (temp_node != NULL)
516
+ height = correct_dimension_units(temp_node->children->str);
517
+ temp_node = node_for_attribute("width",n->link_data->attr);
518
+ if (temp_node != NULL)
519
+ width = correct_dimension_units(temp_node->children->str);
520
+ }
521
+
522
+ if (width != NULL) {
523
+ g_string_append_printf(out, "svg:width=\"%s\"\n", width);
524
+ } else {
525
+ g_string_append_printf(out, "svg:width=\"95%%\"\n");
526
+ }
527
+
528
+ g_string_append_printf(out, ">\n<draw:text-box><text:p><draw:frame text:anchor-type=\"as-char\" draw:z-index=\"1\" ");
529
+ if ((height != NULL) && (width != NULL)) {
530
+ g_string_append_printf(out, "svg:height=\"%s\"\n",height);
531
+ g_string_append_printf(out, "svg:width=\"%s\"\n", width);
532
+ }
533
+
534
+ if (n->link_data->source != NULL)
535
+ g_string_append_printf(out, "><draw:image xlink:href=\"%s\"",n->link_data->source);
536
+
537
+ g_string_append_printf(out," xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\" draw:filter-name=\"&lt;All formats&gt;\"/>\n</draw:frame></text:p>");
538
+
539
+ if (n->key == IMAGEBLOCK) {
540
+ if (n->children != NULL) {
541
+ temp_str = g_string_new("");
542
+ print_odf_node_tree(temp_str,n->children,scratch);
543
+ if (temp_str->currentStringLength > 0) {
544
+ g_string_append_printf(out, "<text:p>Figure <text:sequence text:name=\"Figure\" text:formula=\"ooow:Figure+1\" style:num-format=\"1\"> Update Fields to calculate numbers</text:sequence>: ");
545
+ g_string_append(out, temp_str->str);
546
+ g_string_append_printf(out, "</text:p>");
547
+ }
548
+ g_string_free(temp_str, true);
549
+ }
550
+ g_string_append_printf(out, "</draw:text-box></draw:frame>\n</text:p>\n");
551
+ } else {
552
+ g_string_append_printf(out, "</draw:text-box></draw:frame>\n");
553
+ }
554
+ scratch->padded = 1;
555
+
556
+ /* Restore stashed copy */
557
+ n->link_data->attr = NULL;
558
+ free_link_data(n->link_data);
559
+ n->link_data = temp_link_data;
560
+
561
+ free(height);
562
+ free(width);
563
+
564
+ break;
565
+ #ifdef DEBUG_ON
566
+ fprintf(stderr, "finish image\n");
567
+ #endif
568
+ case NOTEREFERENCE:
569
+ old_type = scratch->odf_para_type;
570
+ scratch->odf_para_type = NOTEREFERENCE;
571
+ lev = note_number_for_node(n, scratch);
572
+ temp_node = node_for_count(scratch->used_notes, lev);
573
+ scratch->padded = 2;
574
+ scratch->printing_notes = 1;
575
+ if (temp_node->key == GLOSSARYSOURCE) {
576
+ g_string_append_printf(out, "<text:note text:id=\"\" text:note-class=\"glossary\"><text:note-body>\n");
577
+ print_odf_node_tree(out, temp_node->children, scratch);
578
+ g_string_append_printf(out, "</text:note-body>\n</text:note>");
579
+ } else {
580
+ g_string_append_printf(out, "<text:note text:id=\"\" text:note-class=\"footnote\"><text:note-body>\n");
581
+ print_odf_node_tree(out, temp_node->children, scratch);
582
+ g_string_append_printf(out, "</text:note-body>\n</text:note>");
583
+ }
584
+ scratch->printing_notes = 0;
585
+ scratch->padded = 1;
586
+ scratch->odf_para_type = old_type;
587
+ break;
588
+ case NOCITATION:
589
+ case CITATION:
590
+ #ifdef DEBUG_ON
591
+ fprintf(stderr, "print cite\n");
592
+ #endif
593
+ if ((n->link_data != NULL) && (strncmp(n->link_data->label,"[#",2) == 0)) {
594
+ /* external citation */
595
+ #ifdef DEBUG_ON
596
+ fprintf(stderr, "external first??");
597
+ #endif
598
+ g_string_append_printf(out, "%s", n->link_data->label);
599
+ } else {
600
+ #ifdef DEBUG_ON
601
+ fprintf(stderr, "internal cite\n");
602
+ #endif
603
+ /* MMD citation, so output as footnote */
604
+ /* TODO: create separate stream from footnotes */
605
+ scratch->printing_notes = 1;
606
+ lev = 0;
607
+ if (n->link_data != NULL)
608
+ lev = note_number_for_label(n->link_data->label, scratch);
609
+ if (lev != 0) {
610
+ #ifdef DEBUG_ON
611
+ fprintf(stderr, "matching cite found - %d\n", lev);
612
+ #endif
613
+ temp_node = node_for_count(scratch->used_notes, lev);
614
+ /* flag that this is used as a citation */
615
+ temp_node->key = CITATIONSOURCE;
616
+ if (lev > scratch->max_footnote_num) {
617
+ /* first use of this citation */
618
+ scratch->max_footnote_num = lev;
619
+
620
+ old_type = scratch->odf_para_type;
621
+ scratch->odf_para_type = CITATION;
622
+
623
+ /* change to represent cite count only */
624
+ lev = cite_count_node_from_end(temp_node);
625
+ g_string_append_printf(out, "<text:note text:id=\"cite%d\" text:note-class=\"endnote\"><text:note-body>\n", lev);
626
+ scratch->padded = 2;
627
+ if (temp_node->children != NULL) {
628
+ print_odf_node(out, temp_node->children, scratch);
629
+ }
630
+ pad(out, 1, scratch);
631
+ g_string_append_printf(out, "</text:note-body>\n</text:note>");
632
+ scratch->odf_para_type = old_type;
633
+ } else {
634
+ /* We are reusing a previous citation */
635
+ #ifdef DEBUG_ON
636
+ fprintf(stderr, "link to existing cite %d\n", lev);
637
+ #endif
638
+ /* Change lev to represent cite count only */
639
+ lev = cite_count_node_from_end(temp_node);
640
+ #ifdef DEBUG_ON
641
+ fprintf(stderr, "renumbered to %d\n", lev);
642
+ #endif
643
+
644
+ g_string_append_printf(out, "<text:span text:style-name=\"Footnote_20_anchor\"><text:note-ref text:note-class=\"endnote\" text:reference-format=\"text\" text:ref-name=\"cite%d\">%d</text:note-ref></text:span>", lev, lev);
645
+ }
646
+ } else {
647
+ /* not located -- this is external cite */
648
+ #ifdef DEBUG_ON
649
+ fprintf(stderr, "no match for cite: '%s'\n",n->link_data->label);
650
+ #endif
651
+ if ((n->link_data != NULL) && (n->key == NOCITATION)) {
652
+ g_string_append_printf(out, "%s", n->link_data->label);
653
+ } else if (n->link_data != NULL) {
654
+ g_string_append_printf(out, "[");
655
+ if (n->children != NULL) {
656
+ print_odf_node(out, n->children, scratch);
657
+ g_string_append_printf(out, "][");
658
+ }
659
+ g_string_append_printf(out, "#%s]",n->link_data->label);
660
+ }
661
+ }
662
+ }
663
+ scratch->printing_notes = 0;
664
+ if ((n->next != NULL) && (n->next->key == CITATION)) {
665
+ g_string_append_printf(out, " ");
666
+ }
667
+ #ifdef DEBUG_ON
668
+ fprintf(stderr, "finish cite\n");
669
+ #endif
670
+ break;
671
+ case VARIABLE:
672
+ temp = metavalue_for_key(n->str,scratch->result_tree);
673
+ if (temp == NULL) {
674
+ g_string_append_printf(out, "[%%%s]",n->str);
675
+ } else {
676
+ print_odf_string(out, temp);
677
+ free(temp);
678
+ }
679
+ break;
680
+ case GLOSSARYTERM:
681
+ g_string_append_printf(out,"<text:p text:style-name=\"Glossary\">");
682
+ print_odf_string(out, n->children->str);
683
+ g_string_append_printf(out, ":</text:p>\n");
684
+ break;
685
+ case GLOSSARYSORTKEY:
686
+ break;
687
+ case CODE:
688
+ g_string_append_printf(out, "<text:span text:style-name=\"Source_20_Text\">");
689
+ print_html_string(out, n->str, scratch);
690
+ g_string_append_printf(out, "</text:span>");
691
+ break;
692
+ case BLOCKQUOTEMARKER:
693
+ print_odf_node_tree(out, n->children, scratch);
694
+ break;
695
+ case BLOCKQUOTE:
696
+ pad(out,2, scratch);
697
+ scratch->padded = 2;
698
+ old_type = scratch->odf_para_type;
699
+ scratch->odf_para_type = BLOCKQUOTE;
700
+ print_odf_node_tree(out, n->children, scratch);
701
+ scratch->odf_para_type = old_type;
702
+ break;
703
+ case RAW:
704
+ /* shouldn't happen */
705
+ assert(n->key != RAW);
706
+ break;
707
+ case HTML:
708
+ /* don't print HTML */
709
+ /* but do print HTML comments for raw ODF */
710
+ if (strncmp(n->str,"<!--",4) == 0) {
711
+ /* trim "-->" from end */
712
+ n->str[strlen(n->str)-3] = '\0';
713
+ g_string_append_printf(out, "%s", &n->str[4]);
714
+ }
715
+ break;
716
+ case DEFLIST:
717
+ print_odf_node_tree(out, n->children, scratch);
718
+ break;
719
+ case TERM:
720
+ pad(out,1, scratch);
721
+ g_string_append_printf(out, "<text:p><text:span text:style-name=\"MMD-Bold\">");
722
+ print_odf_node_tree(out, n->children, scratch);
723
+ g_string_append_printf(out, "</text:span></text:p>\n");
724
+ scratch->padded = 1;
725
+ break;
726
+ case DEFINITION:
727
+ old_type = scratch->odf_para_type;
728
+ scratch->odf_para_type = DEFINITION;
729
+ pad(out,1, scratch);
730
+ scratch->padded = 1;
731
+ g_string_append_printf(out, "<text:p text:style-name=\"Quotations\">");
732
+ print_odf_node_tree(out, n->children, scratch);
733
+ g_string_append_printf(out, "</text:p>\n");
734
+ scratch->padded = 0;
735
+ scratch->odf_para_type = old_type;
736
+ break;
737
+ case TABLE:
738
+ pad(out,2, scratch);
739
+ g_string_append_printf(out, "<table:table>\n");
740
+ print_odf_node_tree(out, n->children, scratch);
741
+ g_string_append_printf(out, "</table:table>\n");
742
+ /* caption if present */
743
+ if ((n->children != NULL) && (n->children->key == TABLECAPTION)) {
744
+ if (n->children->children->key == TABLELABEL) {
745
+ temp = label_from_string(n->children->children->str);
746
+ } else {
747
+ temp = label_from_node_tree(n->children->children);
748
+ }
749
+ g_string_append_printf(out,"<text:p><text:bookmark text:name=\"%s\"/>Table <text:sequence text:name=\"Table\" text:formula=\"ooow:Table+1\" style:num-format=\"1\"> Update Fields to calculate numbers</text:sequence>:", temp);
750
+ print_odf_node_tree(out,n->children->children, scratch);
751
+ g_string_append_printf(out, "<text:bookmark-end text:name=\"%s\"/></text:p>\n",temp);
752
+ free(temp);
753
+ }
754
+ scratch->padded = 1;
755
+ scratch->table_alignment = NULL;
756
+ break;
757
+ case TABLESEPARATOR:
758
+ scratch->table_alignment = n->str;
759
+ break;
760
+ case TABLECAPTION:
761
+ break;
762
+ case TABLELABEL:
763
+ break;
764
+ case TABLEHEAD:
765
+ for (i=0; i < strlen(scratch->table_alignment); i++) {
766
+ g_string_append_printf(out, "<table:table-column/>\n");
767
+ }
768
+ scratch->cell_type = 'h';
769
+ print_odf_node_tree(out, n->children, scratch);
770
+ scratch->cell_type = 'd';
771
+ break;
772
+ case TABLEBODY:
773
+ print_odf_node_tree(out, n->children, scratch);
774
+ break;
775
+ case TABLEROW:
776
+ g_string_append_printf(out, "<table:table-row>\n");
777
+ scratch->table_column = 0;
778
+ print_odf_node_tree(out, n->children, scratch);
779
+ g_string_append_printf(out, "</table:table-row>\n");
780
+ break;
781
+ case TABLECELL:
782
+ temp = scratch->table_alignment;
783
+ if (strncmp(&temp[scratch->table_column],"h",1) == 0) {
784
+ scratch->table_column++;
785
+ }
786
+ lev = scratch->table_column;
787
+ g_string_append_printf(out, "<table:table-cell");
788
+ if ((n->children != NULL) && (n->children->key == CELLSPAN)) {
789
+ g_string_append_printf(out, " table:number-columns-spanned=\"%d\"", strlen(n->children->str)+1);
790
+ scratch->table_column += (int)strlen(n->children->str);
791
+ }
792
+ g_string_append_printf(out, ">\n<text:p");
793
+ if (scratch->cell_type == 'h') {
794
+ g_string_append_printf(out, " text:style-name=\"Table_20_Heading\"");
795
+ } else {
796
+ if ( strncmp(&temp[lev],"r",1) == 0) {
797
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Right\"");
798
+ } else if ( strncmp(&temp[lev],"R",1) == 0) {
799
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Right\"");
800
+ } else if ( strncmp(&temp[lev],"c",1) == 0) {
801
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Center\"");
802
+ } else if ( strncmp(&temp[lev],"C",1) == 0) {
803
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Center\"");
804
+ } else {
805
+ g_string_append_printf(out, " text:style-name=\"MMD-Table\"");
806
+ }
807
+ }
808
+
809
+ g_string_append_printf(out, ">");
810
+ scratch->padded = 2;
811
+ print_odf_node_tree(out, n->children, scratch);
812
+ g_string_append_printf(out, "</text:p>\n</table:table-cell>\n", scratch->cell_type);
813
+ scratch->table_column++;
814
+ break;
815
+ case CELLSPAN:
816
+ break;
817
+ case GLOSSARYSOURCE:
818
+ if (scratch->printing_notes)
819
+ print_odf_node_tree(out, n->children, scratch);
820
+ break;
821
+ case CITATIONSOURCE:
822
+ case NOTESOURCE:
823
+ if (scratch->printing_notes)
824
+ print_odf_node(out, n->children, scratch);
825
+ break;
826
+ case SOURCEBRANCH:
827
+ fprintf(stderr,"SOURCEBRANCH\n");
828
+ break;
829
+ case NOTELABEL:
830
+ case GLOSSARYLABEL:
831
+ break;
832
+ case SUPERSCRIPT:
833
+ g_string_append_printf(out, "<text:span text:style-name=\"MMD-Superscript\">");
834
+ print_html_string(out,n->str, scratch);
835
+ g_string_append_printf(out, "</text:span>");
836
+ break;
837
+ case SUBSCRIPT:
838
+ g_string_append_printf(out, "<text:span text:style-name=\"MMD-Subscript\">");
839
+ print_html_string(out,n->str, scratch);
840
+ g_string_append_printf(out, "</text:span>");
841
+ break;
842
+ case KEY_COUNTER:
843
+ break;
844
+ case TOC:
845
+ print_odf_node_tree(out,n->children, scratch);
846
+ break;
847
+ default:
848
+ fprintf(stderr, "print_odf_node encountered unknown node key = %d\n",n->key);
849
+ exit(EXIT_FAILURE);
850
+ }
851
+
852
+ #ifdef DEBUG_ON
853
+ fprintf(stderr, "finish print_odf_node: %d\n",n->key);
854
+ #endif
855
+
856
+ }
857
+
858
+ /* print_odf_string - print string, escaping for odf */
859
+ void print_odf_string(GString *out, char *str) {
860
+ char *tmp;
861
+ while (*str != '\0') {
862
+ switch (*str) {
863
+ case '&':
864
+ g_string_append_printf(out, "&amp;");
865
+ break;
866
+ case '<':
867
+ g_string_append_printf(out, "&lt;");
868
+ break;
869
+ case '>':
870
+ g_string_append_printf(out, "&gt;");
871
+ break;
872
+ case '"':
873
+ g_string_append_printf(out, "&quot;");
874
+ break;
875
+ case '\n': case '\r':
876
+ tmp = str;
877
+ tmp--;
878
+ if (*tmp == ' ') {
879
+ tmp--;
880
+ if (*tmp == ' ') {
881
+ g_string_append_printf(out, "<text:line-break/>");
882
+ } else {
883
+ g_string_append_printf(out, "\n");
884
+ }
885
+ } else {
886
+ g_string_append_printf(out, "\n");
887
+ }
888
+ break;
889
+ case ' ':
890
+ tmp = str;
891
+ tmp++;
892
+ if (*tmp == ' ') {
893
+ tmp++;
894
+ if (*tmp == ' ') {
895
+ tmp++;
896
+ if (*tmp == ' ') {
897
+ g_string_append_printf(out, "<text:tab/>");
898
+ str = tmp;
899
+ } else {
900
+ g_string_append_printf(out, " ");
901
+ }
902
+ } else {
903
+ g_string_append_printf(out, " ");
904
+ }
905
+ } else {
906
+ g_string_append_printf(out, " ");
907
+ }
908
+ break;
909
+ default:
910
+ g_string_append_c(out, *str);
911
+ }
912
+ str++;
913
+ }
914
+ }
915
+
916
+ /* print_odf_code_string - print string, escaping for HTML and saving newlines
917
+ */
918
+ void print_odf_code_string(GString *out, char *str) {
919
+ char *tmp;
920
+ while (*str != '\0') {
921
+ switch (*str) {
922
+ case '&':
923
+ g_string_append_printf(out, "&amp;");
924
+ break;
925
+ case '<':
926
+ g_string_append_printf(out, "&lt;");
927
+ break;
928
+ case '>':
929
+ g_string_append_printf(out, "&gt;");
930
+ break;
931
+ case '"':
932
+ g_string_append_printf(out, "&quot;");
933
+ break;
934
+ case '\n':
935
+ g_string_append_printf(out, "<text:line-break/>");
936
+ break;
937
+ case ' ':
938
+ tmp = str;
939
+ tmp++;
940
+ if (*tmp == ' ') {
941
+ tmp++;
942
+ if (*tmp == ' ') {
943
+ tmp++;
944
+ if (*tmp == ' ') {
945
+ g_string_append_printf(out, "<text:tab/>");
946
+ str = tmp;
947
+ } else {
948
+ g_string_append_printf(out, " ");
949
+ }
950
+ } else {
951
+ g_string_append_printf(out, " ");
952
+ }
953
+ } else {
954
+ g_string_append_printf(out, " ");
955
+ }
956
+ break;
957
+ default:
958
+ g_string_append_c(out, *str);
959
+ }
960
+ str++;
961
+ }
962
+ }
963
+
964
+ void print_odf_header(GString *out){
965
+ /* Insert required XML header */
966
+ g_string_append_printf(out,
967
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
968
+ "<office:document xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"\n" \
969
+ " xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\"\n" \
970
+ " xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"\n" \
971
+ " xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"\n" \
972
+ " xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\"\n" \
973
+ " xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\"\n" \
974
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" \
975
+ " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" \
976
+ " xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"\n" \
977
+ " xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\"\n" \
978
+ " xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\"\n" \
979
+ " xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\"\n" \
980
+ " xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\"\n" \
981
+ " xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n" \
982
+ " xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\"\n" \
983
+ " xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\"\n" \
984
+ " xmlns:config=\"urn:oasis:names:tc:opendocument:xmlns:config:1.0\"\n" \
985
+ " xmlns:ooo=\"http://openoffice.org/2004/office\"\n" \
986
+ " xmlns:ooow=\"http://openoffice.org/2004/writer\"\n" \
987
+ " xmlns:oooc=\"http://openoffice.org/2004/calc\"\n" \
988
+ " xmlns:dom=\"http://www.w3.org/2001/xml-events\"\n" \
989
+ " xmlns:xforms=\"http://www.w3.org/2002/xforms\"\n" \
990
+ " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" \
991
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" \
992
+ " xmlns:rpt=\"http://openoffice.org/2005/report\"\n" \
993
+ " xmlns:of=\"urn:oasis:names:tc:opendocument:xmlns:of:1.2\"\n" \
994
+ " xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"\n" \
995
+ " xmlns:grddl=\"http://www.w3.org/2003/g/data-view#\"\n" \
996
+ " xmlns:tableooo=\"http://openoffice.org/2009/table\"\n" \
997
+ " xmlns:field=\"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0\"\n" \
998
+ " xmlns:formx=\"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0\"\n" \
999
+ " xmlns:css3t=\"http://www.w3.org/TR/css3-text/\"\n" \
1000
+ " office:version=\"1.2\"\n" \
1001
+ " grddl:transformation=\"http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl\"\n" \
1002
+ " office:mimetype=\"application/vnd.oasis.opendocument.text\">\n");
1003
+
1004
+ /* Font Declarations */
1005
+ g_string_append_printf(out, "<office:font-face-decls>\n" \
1006
+ " <style:font-face style:name=\"Courier New\" svg:font-family=\"'Courier New'\"\n" \
1007
+ " style:font-adornments=\"Regular\"\n" \
1008
+ " style:font-family-generic=\"modern\"\n" \
1009
+ " style:font-pitch=\"fixed\"/>\n" \
1010
+ "</office:font-face-decls>\n");
1011
+
1012
+ /* Append basic style information */
1013
+ g_string_append_printf(out, "<office:styles>\n" \
1014
+ "<style:style style:name=\"Standard\" style:family=\"paragraph\" style:class=\"text\">\n" \
1015
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.15in\"" \
1016
+ " fo:text-align=\"justify\" style:justify-single-word=\"false\"/>\n" \
1017
+ " </style:style>\n" \
1018
+ "<style:style style:name=\"Preformatted_20_Text\" style:display-name=\"Preformatted Text\"\n" \
1019
+ " style:family=\"paragraph\"\n" \
1020
+ " style:parent-style-name=\"Standard\"\n" \
1021
+ " style:class=\"html\">\n" \
1022
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0in\" fo:text-align=\"start\"\n" \
1023
+ " style:justify-single-word=\"false\"/>\n" \
1024
+ " <style:text-properties style:font-name=\"Courier New\" fo:font-size=\"11pt\"\n" \
1025
+ " style:font-name-asian=\"Courier New\"\n" \
1026
+ " style:font-size-asian=\"11pt\"\n" \
1027
+ " style:font-name-complex=\"Courier New\"\n" \
1028
+ " style:font-size-complex=\"11pt\"/>\n" \
1029
+ "</style:style>\n" \
1030
+ "<style:style style:name=\"Source_20_Text\" style:display-name=\"Source Text\"\n" \
1031
+ " style:family=\"text\">\n" \
1032
+ " <style:text-properties style:font-name=\"Courier New\" style:font-name-asian=\"Courier New\"\n" \
1033
+ " style:font-name-complex=\"Courier New\"\n" \
1034
+ " fo:font-size=\"11pt\"/>\n" \
1035
+ "</style:style>\n" \
1036
+ "<style:style style:name=\"List\" style:family=\"paragraph\"\n" \
1037
+ " style:parent-style-name=\"Standard\"\n" \
1038
+ " style:class=\"list\">\n" \
1039
+ " <style:paragraph-properties fo:text-align=\"start\" style:justify-single-word=\"false\"/>\n" \
1040
+ " <style:text-properties style:font-size-asian=\"12pt\"/>\n" \
1041
+ "</style:style>\n" \
1042
+ "<style:style style:name=\"Quotations\" style:family=\"paragraph\"\n" \
1043
+ " style:parent-style-name=\"Standard\"\n" \
1044
+ " style:class=\"html\">\n" \
1045
+ " <style:paragraph-properties fo:margin-left=\"0.3937in\" fo:margin-right=\"0.3937in\" fo:margin-top=\"0in\"\n" \
1046
+ " fo:margin-bottom=\"0.1965in\"\n" \
1047
+ " fo:text-align=\"justify\"" \
1048
+ " style:justify-single-word=\"false\"" \
1049
+ " fo:text-indent=\"0in\"\n" \
1050
+ " style:auto-text-indent=\"false\"/>\n" \
1051
+ "</style:style>\n" \
1052
+ "<style:style style:name=\"Table_20_Heading\" style:display-name=\"Table Heading\"\n" \
1053
+ " style:family=\"paragraph\"\n" \
1054
+ " style:parent-style-name=\"Table_20_Contents\"\n" \
1055
+ " style:class=\"extra\">\n" \
1056
+ " <style:paragraph-properties fo:text-align=\"center\" style:justify-single-word=\"false\"\n" \
1057
+ " text:number-lines=\"false\"\n" \
1058
+ " text:line-number=\"0\"/>\n" \
1059
+ " <style:text-properties fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"\n" \
1060
+ " style:font-weight-complex=\"bold\"/>\n" \
1061
+ "</style:style>\n" \
1062
+ "<style:style style:name=\"Horizontal_20_Line\" style:display-name=\"Horizontal Line\"\n" \
1063
+ " style:family=\"paragraph\"\n" \
1064
+ " style:parent-style-name=\"Standard\"\n" \
1065
+ " style:class=\"html\">\n" \
1066
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.1965in\"\n" \
1067
+ " style:border-line-width-bottom=\"0.0008in 0.0138in 0.0008in\"\n" \
1068
+ " fo:padding=\"0in\"\n" \
1069
+ " fo:border-left=\"none\"\n" \
1070
+ " fo:border-right=\"none\"\n" \
1071
+ " fo:border-top=\"none\"\n" \
1072
+ " fo:border-bottom=\"0.0154in double #808080\"\n" \
1073
+ " text:number-lines=\"false\"\n" \
1074
+ " text:line-number=\"0\"\n" \
1075
+ " style:join-border=\"false\"/>\n" \
1076
+ " <style:text-properties fo:font-size=\"6pt\" style:font-size-asian=\"6pt\" style:font-size-complex=\"6pt\"/>\n" \
1077
+ "</style:style>\n" \
1078
+ "<style:style style:name=\"Footnote_20_anchor\" style:display-name=\"Footnote anchor\"" \
1079
+ " style:family=\"text\">" \
1080
+ " <style:text-properties style:text-position=\"super 58%%\"/>" \
1081
+ " </style:style>\n" \
1082
+ " <text:notes-configuration text:note-class=\"footnote\" text:default-style-name=\"Footnote\" text:citation-style-name=\"Footnote_20_Symbol\" text:citation-body-style-name=\"Footnote_20_anchor\" text:master-page-name=\"Footnote\" style:num-format=\"a\" text:start-value=\"0\" text:footnotes-position=\"page\" text:start-numbering-at=\"page\"/>\n" \
1083
+ " <text:notes-configuration text:note-class=\"endnote\" text:default-style-name=\"Endnote\" text:citation-style-name=\"Endnote_20_Symbol\" text:citation-body-style-name=\"Endnote_20_anchor\" text:master-page-name=\"Endnote\" style:num-format=\"1\" text:start-value=\"0\"/>\n" \
1084
+ "</office:styles>\n");
1085
+
1086
+ /* Automatic style information */
1087
+ g_string_append_printf(out, "<office:automatic-styles>" \
1088
+ " <style:style style:name=\"MMD-Italic\" style:family=\"text\">\n" \
1089
+ " <style:text-properties fo:font-style=\"italic\" style:font-style-asian=\"italic\"\n" \
1090
+ " style:font-style-complex=\"italic\"/>\n" \
1091
+ " </style:style>\n" \
1092
+ " <style:style style:name=\"MMD-Bold\" style:family=\"text\">\n" \
1093
+ " <style:text-properties fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"\n" \
1094
+ " style:font-weight-complex=\"bold\"/>\n" \
1095
+ " </style:style>\n" \
1096
+ " <style:style style:name=\"MMD-Superscript\" style:family=\"text\">\n" \
1097
+ " <style:text-properties style:text-position=\"super 58%%\"/>\n" \
1098
+ " </style:style>\n" \
1099
+ " <style:style style:name=\"MMD-Subscript\" style:family=\"text\">\n" \
1100
+ " <style:text-properties style:text-position=\"sub 58%%\"/>\n" \
1101
+ " </style:style>\n" \
1102
+ "<style:style style:name=\"MMD-Table\" style:family=\"paragraph\" style:parent-style-name=\"Standard\">\n" \
1103
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.05in\"/>\n" \
1104
+ "</style:style>\n" \
1105
+ "<style:style style:name=\"MMD-Table-Center\" style:family=\"paragraph\" style:parent-style-name=\"MMD-Table\">\n" \
1106
+ " <style:paragraph-properties fo:text-align=\"center\" style:justify-single-word=\"false\"/>\n" \
1107
+ "</style:style>\n" \
1108
+ "<style:style style:name=\"MMD-Table-Right\" style:family=\"paragraph\" style:parent-style-name=\"MMD-Table\">\n" \
1109
+ " <style:paragraph-properties fo:text-align=\"right\" style:justify-single-word=\"false\"/>\n" \
1110
+ "</style:style>\n" \
1111
+ "<style:style style:name=\"P2\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"\n" \
1112
+ " style:list-style-name=\"L2\">\n" \
1113
+ "<style:paragraph-properties fo:text-align=\"start\" style:justify-single-word=\"false\"/>\n" \
1114
+ "</style:style>\n" \
1115
+ "<style:style style:name=\"fr1\" style:family=\"graphic\" style:parent-style-name=\"Frame\">\n" \
1116
+ " <style:graphic-properties style:print-content=\"false\" style:vertical-pos=\"top\"\n" \
1117
+ " style:vertical-rel=\"baseline\"\n" \
1118
+ " fo:padding=\"0in\"\n" \
1119
+ " fo:border=\"none\"\n" \
1120
+ " style:shadow=\"none\"/>\n" \
1121
+ "</style:style>\n" \
1122
+ "<style:style style:name=\"P1\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"\n" \
1123
+ " style:list-style-name=\"L1\"/>\n" \
1124
+ "<text:list-style style:name=\"L1\">\n" \
1125
+ " <text:list-level-style-bullet text:level=\"1\" text:style-name=\"Numbering_20_Symbols\" style:num-suffix=\".\" text:bullet-char=\"\">\n" \
1126
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1127
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"0.5in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"0.5in\"/>\n" \
1128
+ " </style:list-level-properties>\n" \
1129
+ " <style:text-properties fo:font-family=\"starbats\" style:font-charset=\"x-symbol\"/>\n" \
1130
+ " </text:list-level-style-bullet>\n" \
1131
+ " <text:list-level-style-bullet text:level=\"2\" text:style-name=\"Numbering_20_Symbols\" style:num-suffix=\".\" text:bullet-char=\"\">\n" \
1132
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1133
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"0.75in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"0.75in\"/>\n" \
1134
+ " </style:list-level-properties>\n" \
1135
+ " <style:text-properties fo:font-family=\"starbats\" style:font-charset=\"x-symbol\"/>\n" \
1136
+ " </text:list-level-style-bullet>\n" \
1137
+ " <text:list-level-style-bullet text:level=\"3\" text:style-name=\"Numbering_20_Symbols\" style:num-suffix=\".\" text:bullet-char=\"\">\n" \
1138
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1139
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1in\"/>\n" \
1140
+ " </style:list-level-properties>\n" \
1141
+ " <style:text-properties fo:font-family=\"starbats\" style:font-charset=\"x-symbol\"/>\n" \
1142
+ " </text:list-level-style-bullet>\n" \
1143
+ " <text:list-level-style-number text:level=\"4\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1144
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1145
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1.25in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1.25in\"/>\n" \
1146
+ " </style:list-level-properties>\n" \
1147
+ " </text:list-level-style-number>\n" \
1148
+ " <text:list-level-style-number text:level=\"5\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1149
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1150
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1.5in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1.5in\"/>\n" \
1151
+ " </style:list-level-properties>\n" \
1152
+ " </text:list-level-style-number>\n" \
1153
+ " <text:list-level-style-number text:level=\"6\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1154
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1155
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1.75in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1.75in\"/>\n" \
1156
+ " </style:list-level-properties>\n" \
1157
+ " </text:list-level-style-number>\n" \
1158
+ " <text:list-level-style-number text:level=\"7\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1159
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1160
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2in\"/>\n" \
1161
+ " </style:list-level-properties>\n" \
1162
+ " </text:list-level-style-number>\n" \
1163
+ " <text:list-level-style-number text:level=\"8\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1164
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1165
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2.25in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2.25in\"/>\n" \
1166
+ " </style:list-level-properties>\n" \
1167
+ " </text:list-level-style-number>\n" \
1168
+ " <text:list-level-style-number text:level=\"9\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1169
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1170
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2.5in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2.5in\"/>\n" \
1171
+ " </style:list-level-properties>\n" \
1172
+ " </text:list-level-style-number>\n" \
1173
+ " <text:list-level-style-number text:level=\"10\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1174
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1175
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2.75in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2.75in\"/>\n" \
1176
+ " </style:list-level-properties>\n" \
1177
+ " </text:list-level-style-number>\n" \
1178
+ "</text:list-style>\n" \
1179
+ "<text:list-style style:name=\"L2\">\n" \
1180
+ " <text:list-level-style-number text:level=\"1\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1181
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1182
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"0.5in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"0.5in\"/>\n" \
1183
+ " </style:list-level-properties>\n" \
1184
+ " </text:list-level-style-number>\n" \
1185
+ " <text:list-level-style-number text:level=\"2\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1186
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1187
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"0.75in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"0.75in\"/>\n" \
1188
+ " </style:list-level-properties>\n" \
1189
+ " </text:list-level-style-number>\n" \
1190
+ " <text:list-level-style-number text:level=\"3\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1191
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1192
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1in\"/>\n" \
1193
+ " </style:list-level-properties>\n" \
1194
+ " </text:list-level-style-number>\n" \
1195
+ " <text:list-level-style-number text:level=\"4\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1196
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1197
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1.25in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1.25in\"/>\n" \
1198
+ " </style:list-level-properties>\n" \
1199
+ " </text:list-level-style-number>\n" \
1200
+ " <text:list-level-style-number text:level=\"5\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1201
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1202
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1.5in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1.5in\"/>\n" \
1203
+ " </style:list-level-properties>\n" \
1204
+ " </text:list-level-style-number>\n" \
1205
+ " <text:list-level-style-number text:level=\"6\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1206
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1207
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"1.75in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"1.75in\"/>\n" \
1208
+ " </style:list-level-properties>\n" \
1209
+ " </text:list-level-style-number>\n" \
1210
+ " <text:list-level-style-number text:level=\"7\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1211
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1212
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2in\"/>\n" \
1213
+ " </style:list-level-properties>\n" \
1214
+ " </text:list-level-style-number>\n" \
1215
+ " <text:list-level-style-number text:level=\"8\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1216
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1217
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2.25in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2.25in\"/>\n" \
1218
+ " </style:list-level-properties>\n" \
1219
+ " </text:list-level-style-number>\n" \
1220
+ " <text:list-level-style-number text:level=\"9\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1221
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1222
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2.5in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2.5in\"/>\n" \
1223
+ " </style:list-level-properties>\n" \
1224
+ " </text:list-level-style-number>\n" \
1225
+ " <text:list-level-style-number text:level=\"10\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1226
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1227
+ " <style:list-level-label-alignment text:label-followed-by=\"listtab\" text:list-tab-stop-position=\"2.75in\" fo:text-indent=\"-0.25in\" fo:margin-left=\"2.75in\"/>\n" \
1228
+ " </style:list-level-properties>\n" \
1229
+ " </text:list-level-style-number>\n" \
1230
+ "</text:list-style>\n" \
1231
+ "</office:automatic-styles>\n" \
1232
+ " <office:master-styles>\n" \
1233
+ " <style:master-page style:name=\"Endnote\" >\n" \
1234
+ " <style:header><text:h text:outline-level=\"2\">Bibliography</text:h></style:header></style:master-page>\n" \
1235
+ " <style:master-page style:name=\"Footnote\" style:page-layout-name=\"pm2\"/>\n" \
1236
+ " </office:master-styles>\n") ;
1237
+ }
1238
+
1239
+ void print_odf_footer(GString *out) {
1240
+ g_string_append_printf(out, "</office:text>\n</office:body>\n</office:document>");
1241
+ }