rmultimarkdown 6.4.0.4 → 6.7.0.0
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.
- checksums.yaml +5 -5
- data/Rakefile +7 -13
- data/ext/Makefile +67 -55
- data/ext/extconf.rb +7 -5
- data/ext/mmd/aho-corasick.c +8 -8
- data/ext/mmd/aho-corasick.h +3 -3
- data/ext/mmd/argtable3.c +6537 -0
- data/ext/mmd/argtable3.h +273 -0
- data/ext/mmd/beamer.c +12 -1
- data/ext/mmd/char.c +120 -27
- data/ext/mmd/char.h +23 -23
- data/ext/mmd/critic_markup.c +7 -6
- data/ext/mmd/d_string.c +88 -32
- data/ext/mmd/{include/d_string.h → d_string.h} +50 -38
- data/ext/mmd/epub.c +36 -12
- data/ext/mmd/epub.h +2 -2
- data/ext/mmd/file.c +50 -40
- data/ext/mmd/file.h +2 -2
- data/ext/mmd/html.c +164 -99
- data/ext/mmd/html.h +3 -2
- data/ext/mmd/i18n.h +15 -11
- data/ext/mmd/itmz-lexer.c +16978 -0
- data/ext/mmd/itmz-lexer.h +132 -0
- data/ext/mmd/itmz-parser.c +1189 -0
- data/ext/mmd/itmz-parser.h +11 -0
- data/ext/mmd/itmz-reader.c +388 -0
- data/ext/mmd/itmz-reader.h +111 -0
- data/ext/mmd/itmz.c +567 -0
- data/ext/mmd/itmz.h +117 -0
- data/ext/mmd/latex.c +93 -41
- data/ext/mmd/lexer.c +3506 -2774
- data/ext/mmd/{include/libMultiMarkdown.h → libMultiMarkdown.h} +49 -2
- data/ext/mmd/main.c +612 -0
- data/ext/mmd/memoir.c +4 -1
- data/ext/mmd/miniz.c +6905 -6680
- data/ext/mmd/miniz.h +456 -476
- data/ext/mmd/mmd.c +399 -94
- data/ext/mmd/mmd.h +25 -25
- data/ext/mmd/object_pool.h +3 -3
- data/ext/mmd/opendocument-content.c +137 -69
- data/ext/mmd/opendocument-content.h +2 -2
- data/ext/mmd/opendocument.c +35 -14
- data/ext/mmd/opendocument.h +2 -2
- data/ext/mmd/opml-lexer.c +259 -637
- data/ext/mmd/opml-lexer.h +1 -17
- data/ext/mmd/opml-parser.c +194 -188
- data/ext/mmd/opml-reader.c +72 -142
- data/ext/mmd/opml-reader.h +1 -1
- data/ext/mmd/opml.c +13 -13
- data/ext/mmd/opml.h +1 -1
- data/ext/mmd/parser.c +1623 -1244
- data/ext/mmd/rng.c +8 -3
- data/ext/mmd/scanners.c +66625 -103198
- data/ext/mmd/scanners.h +1 -0
- data/ext/mmd/stack.c +62 -20
- data/ext/mmd/stack.h +10 -21
- data/ext/mmd/textbundle.c +23 -7
- data/ext/mmd/textbundle.h +2 -2
- data/ext/mmd/token.c +42 -16
- data/ext/mmd/{include/token.h → token.h} +22 -8
- data/ext/mmd/token_pairs.c +0 -16
- data/ext/mmd/transclude.c +6 -2
- data/ext/mmd/uthash.h +745 -745
- data/ext/mmd/version.h +8 -8
- data/ext/mmd/writer.c +225 -63
- data/ext/mmd/writer.h +50 -36
- data/ext/mmd/xml.c +855 -0
- data/ext/mmd/xml.h +134 -0
- data/ext/mmd/zip.c +71 -4
- data/ext/mmd/zip.h +7 -1
- data/ext/ruby_multi_markdown.c +9 -18
- data/lib/multi_markdown/version.rb +1 -1
- data/lib/multi_markdown.bundle +0 -0
- data/rmultimarkdown.gemspec +0 -2
- metadata +22 -28
- data/ext/mmd/char_lookup.c +0 -212
data/ext/mmd/mmd.h
CHANGED
|
@@ -56,44 +56,44 @@
|
|
|
56
56
|
#ifndef MMD_MULTIMARKDOWN_H
|
|
57
57
|
#define MMD_MULTIMARKDOWN_H
|
|
58
58
|
|
|
59
|
-
#include "d_string.h"
|
|
60
59
|
#include "libMultiMarkdown.h"
|
|
61
|
-
#include "stack.h"
|
|
62
|
-
#include "token.h"
|
|
63
|
-
#include "token_pairs.h"
|
|
64
60
|
#include "uthash.h"
|
|
65
61
|
|
|
62
|
+
typedef struct token_pair_engine toke_pair_engine;
|
|
66
63
|
|
|
67
64
|
#define kMaxParseRecursiveDepth 1000 //!< Maximum recursion depth when parsing -- to prevent stack overflow with "pathologic" input
|
|
68
65
|
|
|
69
66
|
|
|
70
67
|
struct mmd_engine {
|
|
71
|
-
DString
|
|
72
|
-
token
|
|
68
|
+
DString * dstr;
|
|
69
|
+
token * root;
|
|
73
70
|
unsigned long extensions;
|
|
74
71
|
unsigned short recurse_depth;
|
|
75
72
|
|
|
76
73
|
bool allow_meta;
|
|
77
74
|
|
|
78
|
-
token_pair_engine
|
|
79
|
-
token_pair_engine
|
|
80
|
-
token_pair_engine
|
|
81
|
-
token_pair_engine
|
|
82
|
-
|
|
83
|
-
stack
|
|
84
|
-
stack
|
|
85
|
-
stack
|
|
86
|
-
stack
|
|
87
|
-
stack
|
|
88
|
-
stack
|
|
89
|
-
stack
|
|
90
|
-
stack
|
|
91
|
-
stack
|
|
75
|
+
struct token_pair_engine * pairings1;
|
|
76
|
+
struct token_pair_engine * pairings2;
|
|
77
|
+
struct token_pair_engine * pairings3;
|
|
78
|
+
struct token_pair_engine * pairings4;
|
|
79
|
+
|
|
80
|
+
stack * abbreviation_stack;
|
|
81
|
+
stack * citation_stack;
|
|
82
|
+
stack * critic_stack;
|
|
83
|
+
stack * definition_stack;
|
|
84
|
+
stack * footnote_stack;
|
|
85
|
+
stack * glossary_stack;
|
|
86
|
+
stack * header_stack;
|
|
87
|
+
stack * link_stack;
|
|
88
|
+
stack * metadata_stack;
|
|
89
|
+
stack * table_stack;
|
|
92
90
|
|
|
93
91
|
short language;
|
|
94
92
|
short quotes_lang;
|
|
95
93
|
|
|
96
|
-
struct asset
|
|
94
|
+
struct asset * asset_hash;
|
|
95
|
+
|
|
96
|
+
int random_seed_base_labels;
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
|
|
@@ -103,15 +103,15 @@ void recursive_parse_list_item(mmd_engine * e, token * block);
|
|
|
103
103
|
void recursive_parse_blockquote(mmd_engine * e, token * block);
|
|
104
104
|
void strip_line_tokens_from_block(mmd_engine * e, token * block);
|
|
105
105
|
void is_para_html(mmd_engine * e, token * block);
|
|
106
|
-
|
|
106
|
+
void add_header(mmd_engine * e, token * header);
|
|
107
107
|
|
|
108
108
|
void is_list_loose(token * list);
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
struct asset {
|
|
112
|
-
char
|
|
113
|
-
char
|
|
114
|
-
UT_hash_handle hh;
|
|
112
|
+
char * url;
|
|
113
|
+
char * asset_path;
|
|
114
|
+
struct UT_hash_handle hh;
|
|
115
115
|
};
|
|
116
116
|
|
|
117
117
|
typedef struct asset asset;
|
data/ext/mmd/object_pool.h
CHANGED
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
|
|
64
64
|
/// Structure for an object allocator pool
|
|
65
65
|
struct pool {
|
|
66
|
-
stack
|
|
67
|
-
void
|
|
68
|
-
void
|
|
66
|
+
stack * allocated; //!< Stack of pointers to slabs that have been allocated
|
|
67
|
+
void * next; //!< Pointer to next available memory for allocation
|
|
68
|
+
void * last; //!< Pointer to end of available memory
|
|
69
69
|
short object_size; //!< Size of individual objects to be allocated
|
|
70
70
|
|
|
71
71
|
char _PADDING[6]; //!< pad struct for alignment
|
|
@@ -107,9 +107,13 @@
|
|
|
107
107
|
#include <string.h>
|
|
108
108
|
|
|
109
109
|
#include "char.h"
|
|
110
|
+
#include "d_string.h"
|
|
110
111
|
#include "opendocument-content.h"
|
|
112
|
+
#include "mmd.h"
|
|
111
113
|
#include "parser.h"
|
|
112
114
|
#include "scanners.h"
|
|
115
|
+
#include "stack.h"
|
|
116
|
+
#include "token.h"
|
|
113
117
|
|
|
114
118
|
|
|
115
119
|
#define print(x) d_string_append(out, x)
|
|
@@ -136,7 +140,7 @@ static char * my_strdup(const char * source) {
|
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
|
|
139
|
-
void mmd_print_char_opendocument(DString * out, char c) {
|
|
143
|
+
void mmd_print_char_opendocument(DString * out, char c, bool line_breaks) {
|
|
140
144
|
switch (c) {
|
|
141
145
|
case '"':
|
|
142
146
|
print_const(""");
|
|
@@ -156,7 +160,12 @@ void mmd_print_char_opendocument(DString * out, char c) {
|
|
|
156
160
|
|
|
157
161
|
case '\n':
|
|
158
162
|
case '\r':
|
|
159
|
-
|
|
163
|
+
if (line_breaks) {
|
|
164
|
+
print_const("<text:line-break/>\n");
|
|
165
|
+
} else {
|
|
166
|
+
print_char(c);
|
|
167
|
+
}
|
|
168
|
+
|
|
160
169
|
break;
|
|
161
170
|
|
|
162
171
|
case '\t':
|
|
@@ -169,13 +178,14 @@ void mmd_print_char_opendocument(DString * out, char c) {
|
|
|
169
178
|
}
|
|
170
179
|
|
|
171
180
|
|
|
172
|
-
void mmd_print_string_opendocument(DString * out, const char * str) {
|
|
181
|
+
void mmd_print_string_opendocument(DString * out, const char * str, bool line_breaks) {
|
|
173
182
|
if (str == NULL) {
|
|
174
183
|
return;
|
|
175
184
|
}
|
|
176
185
|
|
|
177
186
|
while (*str != '\0') {
|
|
178
|
-
mmd_print_char_opendocument(out, *str);
|
|
187
|
+
mmd_print_char_opendocument(out, *str, line_breaks);
|
|
188
|
+
|
|
179
189
|
str++;
|
|
180
190
|
}
|
|
181
191
|
}
|
|
@@ -297,6 +307,7 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
|
|
|
297
307
|
}
|
|
298
308
|
|
|
299
309
|
char * temp;
|
|
310
|
+
char * stop;
|
|
300
311
|
|
|
301
312
|
switch (t->type) {
|
|
302
313
|
case AMPERSAND:
|
|
@@ -320,7 +331,7 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
|
|
|
320
331
|
|
|
321
332
|
if (t->next && t->next->type == TEXT_EMPTY && source[t->start + 1] == ' ') {
|
|
322
333
|
} else {
|
|
323
|
-
mmd_print_char_opendocument(out, source[t->start + 1]);
|
|
334
|
+
mmd_print_char_opendocument(out, source[t->start + 1], false);
|
|
324
335
|
}
|
|
325
336
|
|
|
326
337
|
break;
|
|
@@ -353,8 +364,9 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
|
|
|
353
364
|
case MARKER_H5:
|
|
354
365
|
case MARKER_H6:
|
|
355
366
|
temp = (char *) &source[t->start];
|
|
367
|
+
stop = (char *) &source[t->start + t->len];
|
|
356
368
|
|
|
357
|
-
while (temp) {
|
|
369
|
+
while (temp < stop) {
|
|
358
370
|
switch (*temp) {
|
|
359
371
|
case '#':
|
|
360
372
|
print_const("#");
|
|
@@ -372,7 +384,7 @@ void mmd_export_token_opendocument_raw(DString * out, const char * source, token
|
|
|
372
384
|
break;
|
|
373
385
|
|
|
374
386
|
default:
|
|
375
|
-
temp =
|
|
387
|
+
temp = stop;
|
|
376
388
|
break;
|
|
377
389
|
}
|
|
378
390
|
}
|
|
@@ -511,7 +523,7 @@ void mmd_export_token_opendocument_math(DString * out, const char * source, toke
|
|
|
511
523
|
void mmd_export_link_opendocument(DString * out, const char * source, token * text, link * link, scratch_pad * scratch) {
|
|
512
524
|
if (link->url) {
|
|
513
525
|
print_const("<text:a xlink:type=\"simple\" xlink:href=\"");
|
|
514
|
-
mmd_print_string_opendocument(out, link->url);
|
|
526
|
+
mmd_print_string_opendocument(out, link->url, false);
|
|
515
527
|
print_const("\"");
|
|
516
528
|
} else {
|
|
517
529
|
print_const("<a xlink:type=\"simple\" xlink:href=\"\"");
|
|
@@ -519,7 +531,7 @@ void mmd_export_link_opendocument(DString * out, const char * source, token * te
|
|
|
519
531
|
|
|
520
532
|
if (link->title && link->title[0] != '\0') {
|
|
521
533
|
print_const(" office:name=\"");
|
|
522
|
-
mmd_print_string_opendocument(out, link->title);
|
|
534
|
+
mmd_print_string_opendocument(out, link->title, false);
|
|
523
535
|
print_const("\"");
|
|
524
536
|
}
|
|
525
537
|
|
|
@@ -539,8 +551,8 @@ void mmd_export_link_opendocument(DString * out, const char * source, token * te
|
|
|
539
551
|
}
|
|
540
552
|
|
|
541
553
|
|
|
542
|
-
static char * correct_dimension_units(char *original) {
|
|
543
|
-
char *result;
|
|
554
|
+
static char * correct_dimension_units(char * original) {
|
|
555
|
+
char * result;
|
|
544
556
|
int i;
|
|
545
557
|
|
|
546
558
|
result = my_strdup(original);
|
|
@@ -611,7 +623,7 @@ void mmd_export_image_opendocument(DString * out, const char * source, token * t
|
|
|
611
623
|
print_const(" xlink:type=\"simple\" xlink:show=\"embed\" xlink:actuate=\"onLoad\" draw:filter-name=\"<All formats>\"/>\n</draw:frame></text:p>");
|
|
612
624
|
|
|
613
625
|
if (is_figure) {
|
|
614
|
-
if (text) {
|
|
626
|
+
if (text && text->len > 3) {
|
|
615
627
|
print_const("\n<text:p>Figure <text:sequence text:name=\"Figure\" text:formula=\"ooow:Figure+1\" style:num-format=\"1\"> Update Fields to calculate numbers</text:sequence>: ");
|
|
616
628
|
mmd_export_token_tree_opendocument(out, source, text->child, scratch);
|
|
617
629
|
print_const("</text:p>");
|
|
@@ -624,7 +636,7 @@ void mmd_export_image_opendocument(DString * out, const char * source, token * t
|
|
|
624
636
|
}
|
|
625
637
|
|
|
626
638
|
|
|
627
|
-
void mmd_export_toc_entry_opendocument(DString * out, const char * source, scratch_pad * scratch, size_t * counter, short level) {
|
|
639
|
+
void mmd_export_toc_entry_opendocument(DString * out, const char * source, scratch_pad * scratch, size_t * counter, short level, short min, short max) {
|
|
628
640
|
token * entry, * next;
|
|
629
641
|
short entry_level, next_level;
|
|
630
642
|
char * temp_char;
|
|
@@ -635,30 +647,37 @@ void mmd_export_toc_entry_opendocument(DString * out, const char * source, scrat
|
|
|
635
647
|
entry = stack_peek_index(scratch->header_stack, *counter);
|
|
636
648
|
entry_level = raw_level_for_header(entry);
|
|
637
649
|
|
|
638
|
-
if (entry_level
|
|
639
|
-
//
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
(*counter)
|
|
652
|
-
|
|
650
|
+
if (entry_level < min || entry_level > max) {
|
|
651
|
+
// Ignore this one
|
|
652
|
+
} else {
|
|
653
|
+
if (entry_level >= level) {
|
|
654
|
+
// This entry is a direct descendant of the parent
|
|
655
|
+
scratch->label_counter = (int) * counter;
|
|
656
|
+
temp_char = label_from_header(source, entry, scratch);
|
|
657
|
+
printf("<text:p text:style-name=\"TOC_Item\"><text:a xlink:type=\"simple\" xlink:href=\"#%s\" text:style-name=\"Index_20_Link\" text:visited-style-name=\"Index_20_Link\">", temp_char);
|
|
658
|
+
mmd_export_token_tree_opendocument(out, source, entry->child, scratch);
|
|
659
|
+
trim_trailing_whitespace_d_string(out);
|
|
660
|
+
print_const(" <text:tab/>1</text:a></text:p>\n");
|
|
661
|
+
|
|
662
|
+
if (*counter < scratch->header_stack->size - 1) {
|
|
663
|
+
next = stack_peek_index(scratch->header_stack, *counter + 1);
|
|
664
|
+
next_level = next->type - BLOCK_H1 + 1;
|
|
665
|
+
|
|
666
|
+
if (next_level > entry_level) {
|
|
667
|
+
// This entry has children
|
|
668
|
+
(*counter)++;
|
|
669
|
+
mmd_export_toc_entry_opendocument(out, source, scratch, counter, entry_level + 1, min, max);
|
|
670
|
+
trim_trailing_whitespace_d_string(out);
|
|
671
|
+
}
|
|
653
672
|
}
|
|
654
|
-
}
|
|
655
673
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
674
|
+
free(temp_char);
|
|
675
|
+
} else if (entry_level < level ) {
|
|
676
|
+
// If entry < level, exit this level
|
|
677
|
+
// Decrement counter first, so that we can test it again later
|
|
678
|
+
(*counter)--;
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
662
681
|
}
|
|
663
682
|
|
|
664
683
|
// Increment counter
|
|
@@ -667,9 +686,11 @@ void mmd_export_toc_entry_opendocument(DString * out, const char * source, scrat
|
|
|
667
686
|
}
|
|
668
687
|
|
|
669
688
|
|
|
670
|
-
void mmd_export_toc_opendocument(DString * out, const char * source, scratch_pad * scratch) {
|
|
689
|
+
void mmd_export_toc_opendocument(DString * out, const char * source, scratch_pad * scratch, short min, short max) {
|
|
671
690
|
size_t counter = 0;
|
|
672
691
|
|
|
692
|
+
int old_label_counter = scratch->label_counter;
|
|
693
|
+
|
|
673
694
|
// TODO: Could use LC to internationalize this
|
|
674
695
|
print_const("<text:table-of-content text:style-name=\"Sect1\" text:protected=\"true\" text:name=\"Table of Contents1\">\n");
|
|
675
696
|
print_const("<text:table-of-content-source text:outline-level=\"10\">\n");
|
|
@@ -679,9 +700,11 @@ void mmd_export_toc_opendocument(DString * out, const char * source, scratch_pad
|
|
|
679
700
|
print_const("<text:p text:style-name=\"Contents_20_Heading\">Table of Contents</text:p>\n");
|
|
680
701
|
print_const("</text:index-title>\n");
|
|
681
702
|
|
|
682
|
-
mmd_export_toc_entry_opendocument(out, source, scratch, &counter, 0);
|
|
703
|
+
mmd_export_toc_entry_opendocument(out, source, scratch, &counter, 0, min, max);
|
|
683
704
|
|
|
684
705
|
print_const("</text:index-body>\n</text:table-of-content>\n\n");
|
|
706
|
+
|
|
707
|
+
scratch->label_counter = old_label_counter;
|
|
685
708
|
}
|
|
686
709
|
|
|
687
710
|
|
|
@@ -700,6 +723,7 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
700
723
|
bool temp_bool = 0;
|
|
701
724
|
token * temp_token = NULL;
|
|
702
725
|
footnote * temp_note = NULL;
|
|
726
|
+
size_t temp_size;
|
|
703
727
|
|
|
704
728
|
switch (t->type) {
|
|
705
729
|
case DOC_START_TOKEN:
|
|
@@ -766,6 +790,7 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
766
790
|
// Raw source
|
|
767
791
|
if (raw_filter_text_matches(temp_char, FORMAT_ODT)) {
|
|
768
792
|
switch (t->child->tail->type) {
|
|
793
|
+
case CODE_FENCE_LINE:
|
|
769
794
|
case LINE_FENCE_BACKTICK_3:
|
|
770
795
|
case LINE_FENCE_BACKTICK_4:
|
|
771
796
|
case LINE_FENCE_BACKTICK_5:
|
|
@@ -780,7 +805,10 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
780
805
|
d_string_append_c_array(out, &source[t->child->next->start], temp_token->start - t->child->next->start);
|
|
781
806
|
scratch->padded = 1;
|
|
782
807
|
} else {
|
|
783
|
-
|
|
808
|
+
if (t->child->next) {
|
|
809
|
+
d_string_append_c_array(out, &source[t->child->start + t->child->len], t->start + t->len - t->child->next->start);
|
|
810
|
+
}
|
|
811
|
+
|
|
784
812
|
scratch->padded = 0;
|
|
785
813
|
}
|
|
786
814
|
}
|
|
@@ -851,6 +879,9 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
851
879
|
scratch->padded = 1;
|
|
852
880
|
break;
|
|
853
881
|
|
|
882
|
+
case MARKER_DEFLIST_COLON:
|
|
883
|
+
break;
|
|
884
|
+
|
|
854
885
|
case BLOCK_EMPTY:
|
|
855
886
|
break;
|
|
856
887
|
|
|
@@ -879,17 +910,29 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
879
910
|
|
|
880
911
|
printf("<text:h text:outline-level=\"%d\">", temp_short + scratch->base_header_level - 1);
|
|
881
912
|
|
|
913
|
+
header_clean_trailing_whitespace(t->child, source);
|
|
914
|
+
|
|
882
915
|
if (scratch->extensions & EXT_NO_LABELS) {
|
|
883
916
|
mmd_export_token_tree_opendocument(out, source, t->child, scratch);
|
|
884
917
|
} else {
|
|
885
|
-
temp_char = label_from_header(source, t);
|
|
918
|
+
temp_char = label_from_header(source, t, scratch);
|
|
886
919
|
printf("<text:bookmark text:name=\"%s\"/>", temp_char);
|
|
887
920
|
mmd_export_token_tree_opendocument(out, source, t->child, scratch);
|
|
888
921
|
//printf("<text:bookmark-end text:name=\"%s\"/>", temp_char);
|
|
889
922
|
free(temp_char);
|
|
890
923
|
}
|
|
891
924
|
|
|
892
|
-
|
|
925
|
+
temp_size = 0;
|
|
926
|
+
|
|
927
|
+
while (temp_size != out->currentStringLength) {
|
|
928
|
+
temp_size = out->currentStringLength;
|
|
929
|
+
|
|
930
|
+
trim_trailing_whitespace_d_string(out);
|
|
931
|
+
|
|
932
|
+
if (strcmp(&(out->str[out->currentStringLength - 11]), "<text:tab/>") == 0) {
|
|
933
|
+
d_string_erase(out, out->currentStringLength - 11, 11);
|
|
934
|
+
}
|
|
935
|
+
}
|
|
893
936
|
|
|
894
937
|
print_const("</text:h>");
|
|
895
938
|
scratch->padded = 0;
|
|
@@ -1099,7 +1142,21 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
1099
1142
|
case BLOCK_TOC:
|
|
1100
1143
|
pad(out, 2, scratch);
|
|
1101
1144
|
|
|
1102
|
-
|
|
1145
|
+
// Define range
|
|
1146
|
+
if (t->child->child->type == TOC) {
|
|
1147
|
+
temp_short = 1;
|
|
1148
|
+
temp_short2 = 6;
|
|
1149
|
+
} else {
|
|
1150
|
+
temp_short = source[t->start + 6] - '0';
|
|
1151
|
+
|
|
1152
|
+
if (t->child->child->type == TOC_RANGE) {
|
|
1153
|
+
temp_short2 = source[t->start + 8] - '0';
|
|
1154
|
+
} else {
|
|
1155
|
+
temp_short2 = temp_short;
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
mmd_export_toc_opendocument(out, source, scratch, temp_short, temp_short2);
|
|
1103
1160
|
|
|
1104
1161
|
scratch->padded = 1;
|
|
1105
1162
|
break;
|
|
@@ -1232,7 +1289,7 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
1232
1289
|
(source[t->start + 1] == ' ')) {
|
|
1233
1290
|
print_const(" "); // This is a non-breaking space character
|
|
1234
1291
|
} else {
|
|
1235
|
-
mmd_print_char_opendocument(out, source[t->start + 1]);
|
|
1292
|
+
mmd_print_char_opendocument(out, source[t->start + 1], false);
|
|
1236
1293
|
}
|
|
1237
1294
|
|
|
1238
1295
|
break;
|
|
@@ -1293,6 +1350,8 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
1293
1350
|
case MARKER_H4:
|
|
1294
1351
|
case MARKER_H5:
|
|
1295
1352
|
case MARKER_H6:
|
|
1353
|
+
case MARKER_SETEXT_1:
|
|
1354
|
+
case MARKER_SETEXT_2:
|
|
1296
1355
|
case MARKER_LIST_BULLET:
|
|
1297
1356
|
case MARKER_LIST_ENUMERATOR:
|
|
1298
1357
|
break;
|
|
@@ -1371,9 +1430,9 @@ void mmd_export_token_opendocument(DString * out, const char * source, token * t
|
|
|
1371
1430
|
temp_bool = false;
|
|
1372
1431
|
}
|
|
1373
1432
|
|
|
1374
|
-
mmd_print_string_opendocument(out, temp_char);
|
|
1433
|
+
mmd_print_string_opendocument(out, temp_char, false);
|
|
1375
1434
|
print_const("\">");
|
|
1376
|
-
mmd_print_string_opendocument(out, temp_char);
|
|
1435
|
+
mmd_print_string_opendocument(out, temp_char, false);
|
|
1377
1436
|
print_const("</text:a>");
|
|
1378
1437
|
} else if (scan_html(&source[t->start])) {
|
|
1379
1438
|
// We ignore HTML blocks
|
|
@@ -1688,11 +1747,11 @@ parse_citation:
|
|
|
1688
1747
|
|
|
1689
1748
|
if (temp_short3 == scratch->inline_abbreviations_to_free->size) {
|
|
1690
1749
|
// This is a reference definition
|
|
1691
|
-
mmd_print_string_opendocument(out, temp_note->label_text);
|
|
1750
|
+
mmd_print_string_opendocument(out, temp_note->label_text, true);
|
|
1692
1751
|
// mmd_export_token_tree_opendocument(out, source, t->child, scratch);
|
|
1693
1752
|
} else {
|
|
1694
1753
|
// This is an inline definition
|
|
1695
|
-
mmd_print_string_opendocument(out, temp_note->label_text);
|
|
1754
|
+
mmd_print_string_opendocument(out, temp_note->label_text, true);
|
|
1696
1755
|
// mmd_export_token_tree_opendocument(out, source, t->child, scratch);
|
|
1697
1756
|
}
|
|
1698
1757
|
} else {
|
|
@@ -1702,15 +1761,15 @@ parse_citation:
|
|
|
1702
1761
|
|
|
1703
1762
|
if (temp_short3 == scratch->inline_abbreviations_to_free->size) {
|
|
1704
1763
|
// This is a reference definition
|
|
1705
|
-
mmd_print_string_opendocument(out, temp_note->clean_text);
|
|
1764
|
+
mmd_print_string_opendocument(out, temp_note->clean_text, true);
|
|
1706
1765
|
print_const(" (");
|
|
1707
|
-
mmd_print_string_opendocument(out, temp_note->label_text);
|
|
1766
|
+
mmd_print_string_opendocument(out, temp_note->label_text, true);
|
|
1708
1767
|
print_const(")");
|
|
1709
1768
|
} else {
|
|
1710
1769
|
// This is an inline definition
|
|
1711
|
-
mmd_print_string_opendocument(out, temp_note->clean_text);
|
|
1770
|
+
mmd_print_string_opendocument(out, temp_note->clean_text, true);
|
|
1712
1771
|
print_const(" (");
|
|
1713
|
-
mmd_print_string_opendocument(out, temp_note->label_text);
|
|
1772
|
+
mmd_print_string_opendocument(out, temp_note->label_text, true);
|
|
1714
1773
|
print_const(")");
|
|
1715
1774
|
}
|
|
1716
1775
|
|
|
@@ -1750,11 +1809,11 @@ parse_citation:
|
|
|
1750
1809
|
if (temp_short2 == scratch->used_glossaries->size) {
|
|
1751
1810
|
// This is a re-use of a previously used note
|
|
1752
1811
|
|
|
1753
|
-
mmd_print_string_opendocument(out, temp_note->clean_text);
|
|
1812
|
+
mmd_print_string_opendocument(out, temp_note->clean_text, true);
|
|
1754
1813
|
} else {
|
|
1755
1814
|
// This is the first time this note was used
|
|
1756
1815
|
|
|
1757
|
-
mmd_print_string_opendocument(out, temp_note->clean_text);
|
|
1816
|
+
mmd_print_string_opendocument(out, temp_note->clean_text, true);
|
|
1758
1817
|
|
|
1759
1818
|
printf("<text:note text:id=\"gn%d\" text:note-class=\"glossary\"><text:note-body>", temp_short);
|
|
1760
1819
|
mmd_export_token_tree_opendocument(out, source, temp_note->content, scratch);
|
|
@@ -1774,7 +1833,7 @@ parse_citation:
|
|
|
1774
1833
|
temp_char2 = extract_metadata(scratch, temp_char);
|
|
1775
1834
|
|
|
1776
1835
|
if (temp_char2) {
|
|
1777
|
-
mmd_print_string_opendocument(out, temp_char2);
|
|
1836
|
+
mmd_print_string_opendocument(out, temp_char2, true);
|
|
1778
1837
|
} else {
|
|
1779
1838
|
mmd_export_token_tree_opendocument(out, source, t->child, scratch);
|
|
1780
1839
|
}
|
|
@@ -2046,22 +2105,26 @@ parse_citation:
|
|
|
2046
2105
|
} else {
|
|
2047
2106
|
print_const(">\n<text:p");
|
|
2048
2107
|
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2108
|
+
if (scratch->table_cell_count < kMaxTableColumns) {
|
|
2109
|
+
switch (scratch->table_alignment[scratch->table_cell_count]) {
|
|
2110
|
+
case 'l':
|
|
2111
|
+
case 'L':
|
|
2112
|
+
default:
|
|
2113
|
+
print_const(" text:style-name=\"MMD-Table\"");
|
|
2114
|
+
break;
|
|
2115
|
+
|
|
2116
|
+
case 'r':
|
|
2117
|
+
case 'R':
|
|
2118
|
+
print_const(" text:style-name=\"MMD-Table-Right\"");
|
|
2119
|
+
break;
|
|
2120
|
+
|
|
2121
|
+
case 'c':
|
|
2122
|
+
case 'C':
|
|
2123
|
+
print_const(" text:style-name=\"MMD-Table-Center\"");
|
|
2124
|
+
break;
|
|
2125
|
+
}
|
|
2126
|
+
} else {
|
|
2127
|
+
print_const(" text:style-name=\"MMD-Table\"");
|
|
2065
2128
|
}
|
|
2066
2129
|
}
|
|
2067
2130
|
|
|
@@ -2117,10 +2180,15 @@ parse_citation:
|
|
|
2117
2180
|
case TEXT_PERIOD:
|
|
2118
2181
|
case TEXT_PLAIN:
|
|
2119
2182
|
case TOC:
|
|
2183
|
+
case TOC_SINGLE:
|
|
2184
|
+
case TOC_RANGE:
|
|
2120
2185
|
case UL:
|
|
2121
2186
|
print_token(t);
|
|
2122
2187
|
break;
|
|
2123
2188
|
|
|
2189
|
+
case OBJECT_REPLACEMENT_CHARACTER:
|
|
2190
|
+
break;
|
|
2191
|
+
|
|
2124
2192
|
default:
|
|
2125
2193
|
fprintf(stderr, "Unknown token type: %d\n", t->type);
|
|
2126
2194
|
token_describe(t, source);
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
|
|
108
108
|
#include "writer.h"
|
|
109
109
|
|
|
110
|
-
void mmd_print_char_opendocument(DString * out, char c);
|
|
111
|
-
void mmd_print_string_opendocument(DString * out, const char * str);
|
|
110
|
+
void mmd_print_char_opendocument(DString * out, char c, bool line_breaks);
|
|
111
|
+
void mmd_print_string_opendocument(DString * out, const char * str, bool line_breaks);
|
|
112
112
|
void mmd_print_localized_char_opendocument(DString * out, unsigned short type, scratch_pad * scratch);
|
|
113
113
|
|
|
114
114
|
void mmd_export_token_opendocument_raw(DString * out, const char * source, token * t, scratch_pad * scratch);
|