multimarkdown 4.5.0.r1

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