rmultimarkdown 4.5.2.2

Sign up to get free protection for your applications and to get access to all the features.
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 +1062 -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 +157 -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 +469 -0
  21. data/MultiMarkdown-4/odf.c +1202 -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 +15679 -0
  27. data/MultiMarkdown-4/parser.h +188 -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 +218 -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 +75 -0
  40. data/Rakefile +85 -0
  41. data/bin/rmultimarkdown +128 -0
  42. data/ext/extconf.h +3 -0
  43. data/ext/extconf.rb +10 -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/rmultimarkdown.rb +1 -0
  49. data/rmultimarkdown.gemspec +37 -0
  50. data/test/multi_markdown_test.rb +64 -0
  51. metadata +122 -0
@@ -0,0 +1,1202 @@
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
+ scratch->table_column += (int)strlen(n->children->str);
756
+ }
757
+ g_string_append_printf(out, ">\n<text:p");
758
+ if (scratch->cell_type == 'h') {
759
+ g_string_append_printf(out, " text:style-name=\"Table_20_Heading\"");
760
+ } else {
761
+ if ( strncmp(&temp[lev],"r",1) == 0) {
762
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Right\"");
763
+ } else if ( strncmp(&temp[lev],"R",1) == 0) {
764
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Right\"");
765
+ } else if ( strncmp(&temp[lev],"c",1) == 0) {
766
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Center\"");
767
+ } else if ( strncmp(&temp[lev],"C",1) == 0) {
768
+ g_string_append_printf(out, " text:style-name=\"MMD-Table-Center\"");
769
+ } else {
770
+ g_string_append_printf(out, " text:style-name=\"MMD-Table\"");
771
+ }
772
+ }
773
+
774
+ g_string_append_printf(out, ">");
775
+ scratch->padded = 2;
776
+ print_odf_node_tree(out, n->children, scratch);
777
+ g_string_append_printf(out, "</text:p>\n</table:table-cell>\n", scratch->cell_type);
778
+ scratch->table_column++;
779
+ break;
780
+ case CELLSPAN:
781
+ break;
782
+ case GLOSSARYSOURCE:
783
+ if (scratch->printing_notes)
784
+ print_odf_node_tree(out, n->children, scratch);
785
+ break;
786
+ case CITATIONSOURCE:
787
+ case NOTESOURCE:
788
+ if (scratch->printing_notes)
789
+ print_odf_node(out, n->children, scratch);
790
+ break;
791
+ case SOURCEBRANCH:
792
+ fprintf(stderr,"SOURCEBRANCH\n");
793
+ break;
794
+ case NOTELABEL:
795
+ break;
796
+ case SUPERSCRIPT:
797
+ g_string_append_printf(out, "<text:span text:style-name=\"MMD-Superscript\">");
798
+ print_html_string(out,n->str, scratch);
799
+ g_string_append_printf(out, "</text:span>");
800
+ break;
801
+ case SUBSCRIPT:
802
+ g_string_append_printf(out, "<text:span text:style-name=\"MMD-Subscript\">");
803
+ print_html_string(out,n->str, scratch);
804
+ g_string_append_printf(out, "</text:span>");
805
+ break;
806
+ case KEY_COUNTER:
807
+ break;
808
+ default:
809
+ fprintf(stderr, "print_odf_node encountered unknown node key = %d\n",n->key);
810
+ exit(EXIT_FAILURE);
811
+ }
812
+
813
+ #ifdef DEBUG_ON
814
+ fprintf(stderr, "finish print_odf_node: %d\n",n->key);
815
+ #endif
816
+
817
+ }
818
+
819
+ /* print_odf_string - print string, escaping for odf */
820
+ void print_odf_string(GString *out, char *str) {
821
+ char *tmp;
822
+ while (*str != '\0') {
823
+ switch (*str) {
824
+ case '&':
825
+ g_string_append_printf(out, "&amp;");
826
+ break;
827
+ case '<':
828
+ g_string_append_printf(out, "&lt;");
829
+ break;
830
+ case '>':
831
+ g_string_append_printf(out, "&gt;");
832
+ break;
833
+ case '"':
834
+ g_string_append_printf(out, "&quot;");
835
+ break;
836
+ case '\n': case '\r':
837
+ tmp = str;
838
+ tmp--;
839
+ if (*tmp == ' ') {
840
+ tmp--;
841
+ if (*tmp == ' ') {
842
+ g_string_append_printf(out, "<text:line-break/>");
843
+ } else {
844
+ g_string_append_printf(out, "\n");
845
+ }
846
+ } else {
847
+ g_string_append_printf(out, "\n");
848
+ }
849
+ break;
850
+ case ' ':
851
+ tmp = str;
852
+ tmp++;
853
+ if (*tmp == ' ') {
854
+ tmp++;
855
+ if (*tmp == ' ') {
856
+ tmp++;
857
+ if (*tmp == ' ') {
858
+ g_string_append_printf(out, "<text:tab/>");
859
+ str = tmp;
860
+ } else {
861
+ g_string_append_printf(out, " ");
862
+ }
863
+ } else {
864
+ g_string_append_printf(out, " ");
865
+ }
866
+ } else {
867
+ g_string_append_printf(out, " ");
868
+ }
869
+ break;
870
+ default:
871
+ g_string_append_c(out, *str);
872
+ }
873
+ str++;
874
+ }
875
+ }
876
+
877
+ /* print_odf_code_string - print string, escaping for HTML and saving newlines
878
+ */
879
+ void print_odf_code_string(GString *out, char *str) {
880
+ char *tmp;
881
+ while (*str != '\0') {
882
+ switch (*str) {
883
+ case '&':
884
+ g_string_append_printf(out, "&amp;");
885
+ break;
886
+ case '<':
887
+ g_string_append_printf(out, "&lt;");
888
+ break;
889
+ case '>':
890
+ g_string_append_printf(out, "&gt;");
891
+ break;
892
+ case '"':
893
+ g_string_append_printf(out, "&quot;");
894
+ break;
895
+ case '\n':
896
+ g_string_append_printf(out, "<text:line-break/>");
897
+ break;
898
+ case ' ':
899
+ tmp = str;
900
+ tmp++;
901
+ if (*tmp == ' ') {
902
+ tmp++;
903
+ if (*tmp == ' ') {
904
+ tmp++;
905
+ if (*tmp == ' ') {
906
+ g_string_append_printf(out, "<text:tab/>");
907
+ str = tmp;
908
+ } else {
909
+ g_string_append_printf(out, " ");
910
+ }
911
+ } else {
912
+ g_string_append_printf(out, " ");
913
+ }
914
+ } else {
915
+ g_string_append_printf(out, " ");
916
+ }
917
+ break;
918
+ default:
919
+ g_string_append_c(out, *str);
920
+ }
921
+ str++;
922
+ }
923
+ }
924
+
925
+ void print_odf_header(GString *out){
926
+ /* Insert required XML header */
927
+ g_string_append_printf(out,
928
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
929
+ "<office:document xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\"\n" \
930
+ " xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\"\n" \
931
+ " xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\"\n" \
932
+ " xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\"\n" \
933
+ " xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\"\n" \
934
+ " xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\"\n" \
935
+ " xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" \
936
+ " xmlns:dc=\"http://purl.org/dc/elements/1.1/\"\n" \
937
+ " xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\"\n" \
938
+ " xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\"\n" \
939
+ " xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\"\n" \
940
+ " xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\"\n" \
941
+ " xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\"\n" \
942
+ " xmlns:math=\"http://www.w3.org/1998/Math/MathML\"\n" \
943
+ " xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\"\n" \
944
+ " xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\"\n" \
945
+ " xmlns:config=\"urn:oasis:names:tc:opendocument:xmlns:config:1.0\"\n" \
946
+ " xmlns:ooo=\"http://openoffice.org/2004/office\"\n" \
947
+ " xmlns:ooow=\"http://openoffice.org/2004/writer\"\n" \
948
+ " xmlns:oooc=\"http://openoffice.org/2004/calc\"\n" \
949
+ " xmlns:dom=\"http://www.w3.org/2001/xml-events\"\n" \
950
+ " xmlns:xforms=\"http://www.w3.org/2002/xforms\"\n" \
951
+ " xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n" \
952
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" \
953
+ " xmlns:rpt=\"http://openoffice.org/2005/report\"\n" \
954
+ " xmlns:of=\"urn:oasis:names:tc:opendocument:xmlns:of:1.2\"\n" \
955
+ " xmlns:xhtml=\"http://www.w3.org/1999/xhtml\"\n" \
956
+ " xmlns:grddl=\"http://www.w3.org/2003/g/data-view#\"\n" \
957
+ " xmlns:tableooo=\"http://openoffice.org/2009/table\"\n" \
958
+ " xmlns:field=\"urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0\"\n" \
959
+ " xmlns:formx=\"urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0\"\n" \
960
+ " xmlns:css3t=\"http://www.w3.org/TR/css3-text/\"\n" \
961
+ " office:version=\"1.2\"\n" \
962
+ " grddl:transformation=\"http://docs.oasis-open.org/office/1.2/xslt/odf2rdf.xsl\"\n" \
963
+ " office:mimetype=\"application/vnd.oasis.opendocument.text\">\n");
964
+
965
+ /* Font Declarations */
966
+ g_string_append_printf(out, "<office:font-face-decls>\n" \
967
+ " <style:font-face style:name=\"Courier New\" svg:font-family=\"'Courier New'\"\n" \
968
+ " style:font-adornments=\"Regular\"\n" \
969
+ " style:font-family-generic=\"modern\"\n" \
970
+ " style:font-pitch=\"fixed\"/>\n" \
971
+ "</office:font-face-decls>\n");
972
+
973
+ /* Append basic style information */
974
+ g_string_append_printf(out, "<office:styles>\n" \
975
+ "<style:style style:name=\"Standard\" style:family=\"paragraph\" style:class=\"text\">\n" \
976
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.15in\"" \
977
+ " fo:text-align=\"justify\" style:justify-single-word=\"false\"/>\n" \
978
+ " </style:style>\n" \
979
+ "<style:style style:name=\"Preformatted_20_Text\" style:display-name=\"Preformatted Text\"\n" \
980
+ " style:family=\"paragraph\"\n" \
981
+ " style:parent-style-name=\"Standard\"\n" \
982
+ " style:class=\"html\">\n" \
983
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0in\" fo:text-align=\"start\"\n" \
984
+ " style:justify-single-word=\"false\"/>\n" \
985
+ " <style:text-properties style:font-name=\"Courier New\" fo:font-size=\"11pt\"\n" \
986
+ " style:font-name-asian=\"Courier New\"\n" \
987
+ " style:font-size-asian=\"11pt\"\n" \
988
+ " style:font-name-complex=\"Courier New\"\n" \
989
+ " style:font-size-complex=\"11pt\"/>\n" \
990
+ "</style:style>\n" \
991
+ "<style:style style:name=\"Source_20_Text\" style:display-name=\"Source Text\"\n" \
992
+ " style:family=\"text\">\n" \
993
+ " <style:text-properties style:font-name=\"Courier New\" style:font-name-asian=\"Courier New\"\n" \
994
+ " style:font-name-complex=\"Courier New\"\n" \
995
+ " fo:font-size=\"11pt\"/>\n" \
996
+ "</style:style>\n" \
997
+ "<style:style style:name=\"List\" style:family=\"paragraph\"\n" \
998
+ " style:parent-style-name=\"Standard\"\n" \
999
+ " style:class=\"list\">\n" \
1000
+ " <style:paragraph-properties fo:text-align=\"start\" style:justify-single-word=\"false\"/>\n" \
1001
+ " <style:text-properties style:font-size-asian=\"12pt\"/>\n" \
1002
+ "</style:style>\n" \
1003
+ "<style:style style:name=\"Quotations\" style:family=\"paragraph\"\n" \
1004
+ " style:parent-style-name=\"Standard\"\n" \
1005
+ " style:class=\"html\">\n" \
1006
+ " <style:paragraph-properties fo:margin-left=\"0.3937in\" fo:margin-right=\"0.3937in\" fo:margin-top=\"0in\"\n" \
1007
+ " fo:margin-bottom=\"0.1965in\"\n" \
1008
+ " fo:text-align=\"justify\"" \
1009
+ " style:justify-single-word=\"false\"" \
1010
+ " fo:text-indent=\"0in\"\n" \
1011
+ " style:auto-text-indent=\"false\"/>\n" \
1012
+ "</style:style>\n" \
1013
+ "<style:style style:name=\"Table_20_Heading\" style:display-name=\"Table Heading\"\n" \
1014
+ " style:family=\"paragraph\"\n" \
1015
+ " style:parent-style-name=\"Table_20_Contents\"\n" \
1016
+ " style:class=\"extra\">\n" \
1017
+ " <style:paragraph-properties fo:text-align=\"center\" style:justify-single-word=\"false\"\n" \
1018
+ " text:number-lines=\"false\"\n" \
1019
+ " text:line-number=\"0\"/>\n" \
1020
+ " <style:text-properties fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"\n" \
1021
+ " style:font-weight-complex=\"bold\"/>\n" \
1022
+ "</style:style>\n" \
1023
+ "<style:style style:name=\"Horizontal_20_Line\" style:display-name=\"Horizontal Line\"\n" \
1024
+ " style:family=\"paragraph\"\n" \
1025
+ " style:parent-style-name=\"Standard\"\n" \
1026
+ " style:class=\"html\">\n" \
1027
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.1965in\"\n" \
1028
+ " style:border-line-width-bottom=\"0.0008in 0.0138in 0.0008in\"\n" \
1029
+ " fo:padding=\"0in\"\n" \
1030
+ " fo:border-left=\"none\"\n" \
1031
+ " fo:border-right=\"none\"\n" \
1032
+ " fo:border-top=\"none\"\n" \
1033
+ " fo:border-bottom=\"0.0154in double #808080\"\n" \
1034
+ " text:number-lines=\"false\"\n" \
1035
+ " text:line-number=\"0\"\n" \
1036
+ " style:join-border=\"false\"/>\n" \
1037
+ " <style:text-properties fo:font-size=\"6pt\" style:font-size-asian=\"6pt\" style:font-size-complex=\"6pt\"/>\n" \
1038
+ "</style:style>\n" \
1039
+ "<style:style style:name=\"Footnote_20_anchor\" style:display-name=\"Footnote anchor\"" \
1040
+ " style:family=\"text\">" \
1041
+ " <style:text-properties style:text-position=\"super 58%%\"/>" \
1042
+ " </style:style>\n" \
1043
+ " <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" \
1044
+ " <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" \
1045
+ "</office:styles>\n");
1046
+
1047
+ /* Automatic style information */
1048
+ g_string_append_printf(out, "<office:automatic-styles>" \
1049
+ " <style:style style:name=\"MMD-Italic\" style:family=\"text\">\n" \
1050
+ " <style:text-properties fo:font-style=\"italic\" style:font-style-asian=\"italic\"\n" \
1051
+ " style:font-style-complex=\"italic\"/>\n" \
1052
+ " </style:style>\n" \
1053
+ " <style:style style:name=\"MMD-Bold\" style:family=\"text\">\n" \
1054
+ " <style:text-properties fo:font-weight=\"bold\" style:font-weight-asian=\"bold\"\n" \
1055
+ " style:font-weight-complex=\"bold\"/>\n" \
1056
+ " </style:style>\n" \
1057
+ " <style:style style:name=\"MMD-Superscript\" style:family=\"text\">\n" \
1058
+ " <style:text-properties style:text-position=\"super 58%%\"/>\n" \
1059
+ " </style:style>\n" \
1060
+ " <style:style style:name=\"MMD-Subscript\" style:family=\"text\">\n" \
1061
+ " <style:text-properties style:text-position=\"sub 58%%\"/>\n" \
1062
+ " </style:style>\n" \
1063
+ "<style:style style:name=\"MMD-Table\" style:family=\"paragraph\" style:parent-style-name=\"Standard\">\n" \
1064
+ " <style:paragraph-properties fo:margin-top=\"0in\" fo:margin-bottom=\"0.05in\"/>\n" \
1065
+ "</style:style>\n" \
1066
+ "<style:style style:name=\"MMD-Table-Center\" style:family=\"paragraph\" style:parent-style-name=\"MMD-Table\">\n" \
1067
+ " <style:paragraph-properties fo:text-align=\"center\" style:justify-single-word=\"false\"/>\n" \
1068
+ "</style:style>\n" \
1069
+ "<style:style style:name=\"MMD-Table-Right\" style:family=\"paragraph\" style:parent-style-name=\"MMD-Table\">\n" \
1070
+ " <style:paragraph-properties fo:text-align=\"right\" style:justify-single-word=\"false\"/>\n" \
1071
+ "</style:style>\n" \
1072
+ "<style:style style:name=\"P2\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"\n" \
1073
+ " style:list-style-name=\"L2\">\n" \
1074
+ "<style:paragraph-properties fo:text-align=\"start\" style:justify-single-word=\"false\"/>\n" \
1075
+ "</style:style>\n" \
1076
+ "<style:style style:name=\"fr1\" style:family=\"graphic\" style:parent-style-name=\"Frame\">\n" \
1077
+ " <style:graphic-properties style:print-content=\"false\" style:vertical-pos=\"top\"\n" \
1078
+ " style:vertical-rel=\"baseline\"\n" \
1079
+ " fo:padding=\"0in\"\n" \
1080
+ " fo:border=\"none\"\n" \
1081
+ " style:shadow=\"none\"/>\n" \
1082
+ "</style:style>\n" \
1083
+ "<style:style style:name=\"P1\" style:family=\"paragraph\" style:parent-style-name=\"Standard\"\n" \
1084
+ " style:list-style-name=\"L1\"/>\n" \
1085
+ "<text:list-style style:name=\"L1\">\n" \
1086
+ " <text:list-level-style-bullet text:level=\"1\" text:style-name=\"Numbering_20_Symbols\" style:num-suffix=\".\" text:bullet-char=\"\">\n" \
1087
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1088
+ " <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" \
1089
+ " </style:list-level-properties>\n" \
1090
+ " <style:text-properties fo:font-family=\"starbats\" style:font-charset=\"x-symbol\"/>\n" \
1091
+ " </text:list-level-style-bullet>\n" \
1092
+ " <text:list-level-style-bullet text:level=\"2\" text:style-name=\"Numbering_20_Symbols\" style:num-suffix=\".\" text:bullet-char=\"\">\n" \
1093
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1094
+ " <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" \
1095
+ " </style:list-level-properties>\n" \
1096
+ " <style:text-properties fo:font-family=\"starbats\" style:font-charset=\"x-symbol\"/>\n" \
1097
+ " </text:list-level-style-bullet>\n" \
1098
+ " <text:list-level-style-bullet text:level=\"3\" text:style-name=\"Numbering_20_Symbols\" style:num-suffix=\".\" text:bullet-char=\"\">\n" \
1099
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1100
+ " <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" \
1101
+ " </style:list-level-properties>\n" \
1102
+ " <style:text-properties fo:font-family=\"starbats\" style:font-charset=\"x-symbol\"/>\n" \
1103
+ " </text:list-level-style-bullet>\n" \
1104
+ " <text:list-level-style-number text:level=\"4\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1105
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1106
+ " <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" \
1107
+ " </style:list-level-properties>\n" \
1108
+ " </text:list-level-style-number>\n" \
1109
+ " <text:list-level-style-number text:level=\"5\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1110
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1111
+ " <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" \
1112
+ " </style:list-level-properties>\n" \
1113
+ " </text:list-level-style-number>\n" \
1114
+ " <text:list-level-style-number text:level=\"6\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1115
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1116
+ " <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" \
1117
+ " </style:list-level-properties>\n" \
1118
+ " </text:list-level-style-number>\n" \
1119
+ " <text:list-level-style-number text:level=\"7\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1120
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1121
+ " <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" \
1122
+ " </style:list-level-properties>\n" \
1123
+ " </text:list-level-style-number>\n" \
1124
+ " <text:list-level-style-number text:level=\"8\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1125
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1126
+ " <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" \
1127
+ " </style:list-level-properties>\n" \
1128
+ " </text:list-level-style-number>\n" \
1129
+ " <text:list-level-style-number text:level=\"9\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1130
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1131
+ " <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" \
1132
+ " </style:list-level-properties>\n" \
1133
+ " </text:list-level-style-number>\n" \
1134
+ " <text:list-level-style-number text:level=\"10\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1135
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1136
+ " <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" \
1137
+ " </style:list-level-properties>\n" \
1138
+ " </text:list-level-style-number>\n" \
1139
+ "</text:list-style>\n" \
1140
+ "<text:list-style style:name=\"L2\">\n" \
1141
+ " <text:list-level-style-number text:level=\"1\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1142
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1143
+ " <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" \
1144
+ " </style:list-level-properties>\n" \
1145
+ " </text:list-level-style-number>\n" \
1146
+ " <text:list-level-style-number text:level=\"2\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1147
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1148
+ " <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" \
1149
+ " </style:list-level-properties>\n" \
1150
+ " </text:list-level-style-number>\n" \
1151
+ " <text:list-level-style-number text:level=\"3\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1152
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1153
+ " <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" \
1154
+ " </style:list-level-properties>\n" \
1155
+ " </text:list-level-style-number>\n" \
1156
+ " <text:list-level-style-number text:level=\"4\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1157
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1158
+ " <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" \
1159
+ " </style:list-level-properties>\n" \
1160
+ " </text:list-level-style-number>\n" \
1161
+ " <text:list-level-style-number text:level=\"5\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1162
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1163
+ " <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" \
1164
+ " </style:list-level-properties>\n" \
1165
+ " </text:list-level-style-number>\n" \
1166
+ " <text:list-level-style-number text:level=\"6\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1167
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1168
+ " <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" \
1169
+ " </style:list-level-properties>\n" \
1170
+ " </text:list-level-style-number>\n" \
1171
+ " <text:list-level-style-number text:level=\"7\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1172
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1173
+ " <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" \
1174
+ " </style:list-level-properties>\n" \
1175
+ " </text:list-level-style-number>\n" \
1176
+ " <text:list-level-style-number text:level=\"8\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1177
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1178
+ " <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" \
1179
+ " </style:list-level-properties>\n" \
1180
+ " </text:list-level-style-number>\n" \
1181
+ " <text:list-level-style-number text:level=\"9\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1182
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1183
+ " <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" \
1184
+ " </style:list-level-properties>\n" \
1185
+ " </text:list-level-style-number>\n" \
1186
+ " <text:list-level-style-number text:level=\"10\" text:style-name=\"Standard\" style:num-suffix=\".\" style:num-format=\"1\">\n" \
1187
+ " <style:list-level-properties text:list-level-position-and-space-mode=\"label-alignment\">\n" \
1188
+ " <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" \
1189
+ " </style:list-level-properties>\n" \
1190
+ " </text:list-level-style-number>\n" \
1191
+ "</text:list-style>\n" \
1192
+ "</office:automatic-styles>\n" \
1193
+ " <office:master-styles>\n" \
1194
+ " <style:master-page style:name=\"Endnote\" >\n" \
1195
+ " <style:header><text:h text:outline-level=\"2\">Bibliography</text:h></style:header></style:master-page>\n" \
1196
+ " <style:master-page style:name=\"Footnote\" style:page-layout-name=\"pm2\"/>\n" \
1197
+ " </office:master-styles>\n") ;
1198
+ }
1199
+
1200
+ void print_odf_footer(GString *out) {
1201
+ g_string_append_printf(out, "</office:text>\n</office:body>\n</office:document>");
1202
+ }