rmultimarkdown 6.2.2.1 → 6.4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/Makefile +2 -2
- data/ext/mmd/aho-corasick.c +12 -8
- data/ext/mmd/beamer.c +29 -0
- data/ext/mmd/critic_markup.c +100 -4
- data/ext/mmd/critic_markup.h +7 -0
- data/ext/mmd/d_string.c +502 -119
- data/ext/mmd/epub.c +2 -4
- data/ext/mmd/file.c +436 -0
- data/ext/mmd/file.h +153 -0
- data/ext/mmd/html.c +130 -37
- data/ext/mmd/include/d_string.h +20 -19
- data/ext/mmd/include/libMultiMarkdown.h +42 -27
- data/ext/mmd/include/token.h +15 -15
- data/ext/mmd/latex.c +107 -30
- data/ext/mmd/lexer.c +19 -7
- data/ext/mmd/lexer.h +2 -2
- data/ext/mmd/memoir.c +29 -0
- data/ext/mmd/mmd.c +65 -39
- data/ext/mmd/object_pool.h +4 -4
- data/ext/mmd/opendocument-content.c +95 -13
- data/ext/mmd/opendocument.c +315 -313
- data/ext/mmd/opml-lexer.c +2183 -0
- data/ext/mmd/opml-lexer.h +157 -0
- data/ext/mmd/opml-parser.c +1193 -0
- data/ext/mmd/opml-parser.h +15 -0
- data/ext/mmd/opml-reader.c +435 -0
- data/ext/mmd/opml-reader.h +111 -0
- data/ext/mmd/opml.c +511 -0
- data/ext/mmd/opml.h +115 -0
- data/ext/mmd/parser.c +2 -0
- data/ext/mmd/rng.c +1 -1
- data/ext/mmd/scanners.c +51663 -24824
- data/ext/mmd/stack.c +4 -2
- data/ext/mmd/stack.h +8 -8
- data/ext/mmd/textbundle.c +2 -4
- data/ext/mmd/token.c +24 -12
- data/ext/mmd/token_pairs.c +2 -2
- data/ext/mmd/token_pairs.h +10 -10
- data/ext/mmd/transclude.c +1 -226
- data/ext/mmd/transclude.h +0 -8
- data/ext/mmd/uuid.c +3 -3
- data/ext/mmd/version.h +3 -3
- data/ext/mmd/writer.c +99 -30
- data/ext/mmd/writer.h +11 -0
- data/lib/multi_markdown.bundle +0 -0
- data/lib/multi_markdown/version.rb +1 -1
- metadata +13 -5
- data/ext/mmd/fodt.c +0 -2288
- data/ext/mmd/fodt.h +0 -81
data/ext/mmd/include/d_string.h
CHANGED
@@ -10,42 +10,42 @@
|
|
10
10
|
|
11
11
|
@author Daniel Jalkut, modified by Fletcher T. Penney and Dan Lowe
|
12
12
|
|
13
|
-
@bug
|
13
|
+
@bug
|
14
14
|
|
15
15
|
**/
|
16
16
|
|
17
17
|
/*
|
18
18
|
|
19
19
|
Copyright © 2011 Daniel Jalkut.
|
20
|
-
Modifications by Fletcher T. Penney, Copyright © 2011-
|
20
|
+
Modifications by Fletcher T. Penney, Copyright © 2011-2018 Fletcher T. Penney.
|
21
21
|
Modifications by Dan Lowe, Copyright © 2011 Dan Lowe.
|
22
22
|
|
23
23
|
|
24
24
|
The `MultiMarkdown 6` project is released under the MIT License..
|
25
|
-
|
25
|
+
|
26
26
|
GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
|
27
|
-
|
27
|
+
|
28
28
|
https://github.com/fletcher/MultiMarkdown-4/
|
29
|
-
|
29
|
+
|
30
30
|
MMD 4 is released under both the MIT License and GPL.
|
31
|
-
|
32
|
-
|
31
|
+
|
32
|
+
|
33
33
|
CuTest is released under the zlib/libpng license. See CuTest.c for the text
|
34
34
|
of the license.
|
35
|
-
|
36
|
-
|
35
|
+
|
36
|
+
|
37
37
|
## The MIT License ##
|
38
|
-
|
38
|
+
|
39
39
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
40
40
|
of this software and associated documentation files (the "Software"), to deal
|
41
41
|
in the Software without restriction, including without limitation the rights
|
42
42
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
43
43
|
copies of the Software, and to permit persons to whom the Software is
|
44
44
|
furnished to do so, subject to the following conditions:
|
45
|
-
|
45
|
+
|
46
46
|
The above copyright notice and this permission notice shall be included in
|
47
47
|
all copies or substantial portions of the Software.
|
48
|
-
|
48
|
+
|
49
49
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
50
50
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
51
51
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
@@ -63,26 +63,27 @@
|
|
63
63
|
#include <stdbool.h>
|
64
64
|
#include <stdlib.h>
|
65
65
|
|
66
|
-
/* WE implement minimal mirror implementations of GLib's GString
|
66
|
+
/* WE implement minimal mirror implementations of GLib's GString
|
67
67
|
* sufficient to cover the functionality required by MultiMarkdown.
|
68
68
|
*
|
69
|
-
* NOTE: THese are 100% clean, from-scratch implementations using only the
|
69
|
+
* NOTE: THese are 100% clean, from-scratch implementations using only the
|
70
70
|
* GLib function prototype as guide for behavior.
|
71
71
|
*/
|
72
72
|
|
73
73
|
|
74
74
|
/// Structure for dynamic string
|
75
|
-
|
76
|
-
{
|
75
|
+
struct DString {
|
77
76
|
char * str; //!< Pointer to UTF-8 byte stream for string
|
78
77
|
unsigned long currentStringBufferSize; //!< Size of buffer currently allocated
|
79
78
|
unsigned long currentStringLength; //!< Size of current string
|
80
|
-
}
|
79
|
+
};
|
80
|
+
|
81
|
+
typedef struct DString DString;
|
81
82
|
|
82
83
|
|
83
84
|
/// Create a new dynamic string
|
84
85
|
DString * d_string_new(
|
85
|
-
const char * startingString //!< Initial contents for string
|
86
|
+
const char * startingString //!< Initial contents for string
|
86
87
|
);
|
87
88
|
|
88
89
|
|
@@ -159,7 +160,7 @@ void d_string_insert_printf(
|
|
159
160
|
void d_string_erase(
|
160
161
|
DString * baseString, //!< DString to be appended
|
161
162
|
size_t pos, //!< Offset at which to erase portion of string
|
162
|
-
size_t len //!<
|
163
|
+
size_t len //!< How many characters(bytes) to remove
|
163
164
|
);
|
164
165
|
|
165
166
|
/// Copy a portion of dynamic string
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
@author Fletcher T. Penney
|
11
|
-
@bug
|
11
|
+
@bug
|
12
12
|
|
13
13
|
|
14
14
|
******IMPORTANT******
|
@@ -20,7 +20,7 @@
|
|
20
20
|
2. Properly manage the `token_pool_init` and `token_pool_free` functions.
|
21
21
|
|
22
22
|
|
23
|
-
I recommend option #1, unless you absolutely need the best performance for
|
23
|
+
I recommend option #1, unless you absolutely need the best performance for
|
24
24
|
long documents. Doing #2 properly is tricky in any program that can handle
|
25
25
|
multiple MMD text strings at overlapping times.
|
26
26
|
|
@@ -32,30 +32,30 @@
|
|
32
32
|
|
33
33
|
|
34
34
|
The `MultiMarkdown 6` project is released under the MIT License..
|
35
|
-
|
35
|
+
|
36
36
|
GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
|
37
|
-
|
37
|
+
|
38
38
|
https://github.com/fletcher/MultiMarkdown-4/
|
39
|
-
|
39
|
+
|
40
40
|
MMD 4 is released under both the MIT License and GPL.
|
41
|
-
|
42
|
-
|
41
|
+
|
42
|
+
|
43
43
|
CuTest is released under the zlib/libpng license. See CuTest.c for the text
|
44
44
|
of the license.
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
|
47
47
|
## The MIT License ##
|
48
|
-
|
48
|
+
|
49
49
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
50
50
|
of this software and associated documentation files (the "Software"), to deal
|
51
51
|
in the Software without restriction, including without limitation the rights
|
52
52
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
53
53
|
copies of the Software, and to permit persons to whom the Software is
|
54
54
|
furnished to do so, subject to the following conditions:
|
55
|
-
|
55
|
+
|
56
56
|
The above copyright notice and this permission notice shall be included in
|
57
57
|
all copies or substantial portions of the Software.
|
58
|
-
|
58
|
+
|
59
59
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
60
60
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
61
61
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
@@ -74,8 +74,20 @@
|
|
74
74
|
#include <stdlib.h>
|
75
75
|
|
76
76
|
|
77
|
-
|
78
|
-
|
77
|
+
/// typedefs for internal data structures. If you intend to work with these structures
|
78
|
+
/// in your own code, you may need to import additional header files.
|
79
|
+
|
80
|
+
/// From token.h:
|
81
|
+
typedef struct token token;
|
82
|
+
|
83
|
+
/// From d_string.h:
|
84
|
+
typedef struct DString DString;
|
85
|
+
|
86
|
+
/// From mmd.h
|
87
|
+
typedef struct mmd_engine mmd_engine;
|
88
|
+
|
89
|
+
/// From stack.h
|
90
|
+
typedef struct stack stack;
|
79
91
|
|
80
92
|
|
81
93
|
/// There are 3 main versions of the primary functions:
|
@@ -181,10 +193,6 @@ struct stack * mmd_d_string_transclusion_manifest(DString * source, const char *
|
|
181
193
|
MMD Engine variants
|
182
194
|
*/
|
183
195
|
|
184
|
-
/// MMD Engine is used for storing configuration information for MMD parser
|
185
|
-
typedef struct mmd_engine mmd_engine;
|
186
|
-
|
187
|
-
|
188
196
|
/// Create MMD Engine using an existing DString (A new copy is *not* made)
|
189
197
|
mmd_engine * mmd_engine_create_with_dstring(
|
190
198
|
DString * d,
|
@@ -206,8 +214,8 @@ void mmd_engine_reset(mmd_engine * e);
|
|
206
214
|
|
207
215
|
/// Free an existing MMD Engine
|
208
216
|
void mmd_engine_free(
|
209
|
-
mmd_engine *
|
210
|
-
bool
|
217
|
+
mmd_engine * e,
|
218
|
+
bool freeDString
|
211
219
|
);
|
212
220
|
|
213
221
|
|
@@ -281,10 +289,6 @@ char * mmd_version(void);
|
|
281
289
|
DString * scan_file(const char * fname);
|
282
290
|
|
283
291
|
|
284
|
-
/// MMD Engine is used for storing configuration information for MMD parser
|
285
|
-
typedef struct stack stack;
|
286
|
-
|
287
|
-
|
288
292
|
/// Recursively transclude source text, given a search directory.
|
289
293
|
/// Track files to prevent infinite recursive loops
|
290
294
|
void mmd_transclude_source(DString * source, const char * search_path, const char * source_path, short format, struct stack * parsed, struct stack * manifest);
|
@@ -302,10 +306,18 @@ void mmd_append_mmd_footer(DString * source);
|
|
302
306
|
void mmd_critic_markup_accept(DString * d);
|
303
307
|
|
304
308
|
|
309
|
+
/// Accept all CriticMarkup changes in the specified range
|
310
|
+
void mmd_critic_markup_accept_range(DString * d, size_t start, size_t len);
|
311
|
+
|
312
|
+
|
305
313
|
/// Reject all CriticMarkup changes in the source string
|
306
314
|
void mmd_critic_markup_reject(DString * d);
|
307
315
|
|
308
316
|
|
317
|
+
/// Reject all CriticMarkup changes in the specified range
|
318
|
+
void mmd_critic_markup_reject_range(DString * d, size_t start, size_t len);
|
319
|
+
|
320
|
+
|
309
321
|
/// Token types for parse tree
|
310
322
|
enum token_types {
|
311
323
|
DOC_START_TOKEN = 0, //!< DOC_START_TOKEN must be type 0
|
@@ -440,7 +452,7 @@ enum token_types {
|
|
440
452
|
HTML_COMMENT_START,
|
441
453
|
HTML_COMMENT_STOP,
|
442
454
|
PAIR_HTML_COMMENT,
|
443
|
-
|
455
|
+
|
444
456
|
MATH_PAREN_OPEN,
|
445
457
|
MATH_PAREN_CLOSE,
|
446
458
|
MATH_BRACKET_OPEN,
|
@@ -452,7 +464,7 @@ enum token_types {
|
|
452
464
|
PIPE,
|
453
465
|
PLUS,
|
454
466
|
SLASH,
|
455
|
-
|
467
|
+
|
456
468
|
SUPERSCRIPT,
|
457
469
|
SUBSCRIPT,
|
458
470
|
|
@@ -481,7 +493,7 @@ enum token_types {
|
|
481
493
|
TABLE_DIVIDER,
|
482
494
|
|
483
495
|
TOC,
|
484
|
-
|
496
|
+
|
485
497
|
TEXT_BACKSLASH,
|
486
498
|
RAW_FILTER_LEFT,
|
487
499
|
TEXT_BRACE_LEFT,
|
@@ -508,6 +520,7 @@ enum smart_quotes_language {
|
|
508
520
|
FRENCH,
|
509
521
|
GERMAN,
|
510
522
|
GERMANGUILL,
|
523
|
+
SPANISH,
|
511
524
|
SWEDISH,
|
512
525
|
};
|
513
526
|
|
@@ -522,6 +535,7 @@ enum output_format {
|
|
522
535
|
FORMAT_ODT,
|
523
536
|
FORMAT_TEXTBUNDLE,
|
524
537
|
FORMAT_TEXTBUNDLE_COMPRESSED,
|
538
|
+
FORMAT_OPML,
|
525
539
|
FORMAT_MMD,
|
526
540
|
};
|
527
541
|
|
@@ -541,6 +555,7 @@ enum parser_extensions {
|
|
541
555
|
EXT_CRITIC_REJECT = 1 << 11, //!< Reject all proposed changes
|
542
556
|
EXT_RANDOM_FOOT = 1 << 12, //!< Use random numbers for footnote links
|
543
557
|
EXT_TRANSCLUDE = 1 << 13, //!< Perform transclusion(s)
|
558
|
+
EXT_PARSE_OPML = 1 << 14, //!< Convert from OPML before processing source text
|
544
559
|
EXT_FAKE = 1 << 31, //!< 31 is highest number allowed
|
545
560
|
};
|
546
561
|
|
data/ext/mmd/include/token.h
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
@author Fletcher T. Penney
|
12
12
|
|
13
|
-
@bug
|
13
|
+
@bug
|
14
14
|
|
15
15
|
**/
|
16
16
|
|
@@ -20,27 +20,27 @@
|
|
20
20
|
|
21
21
|
|
22
22
|
The `MultiMarkdown 6` project is released under the MIT License..
|
23
|
-
|
23
|
+
|
24
24
|
GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
|
25
|
-
|
25
|
+
|
26
26
|
https://github.com/fletcher/MultiMarkdown-4/
|
27
|
-
|
27
|
+
|
28
28
|
MMD 4 is released under both the MIT License and GPL.
|
29
|
-
|
30
|
-
|
29
|
+
|
30
|
+
|
31
31
|
CuTest is released under the zlib/libpng license. See CuTest.c for the text
|
32
32
|
of the license.
|
33
|
-
|
34
|
-
|
33
|
+
|
34
|
+
|
35
35
|
## The MIT License ##
|
36
|
-
|
36
|
+
|
37
37
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
38
38
|
of this software and associated documentation files (the "Software"), to deal
|
39
39
|
in the Software without restriction, including without limitation the rights
|
40
40
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
41
41
|
copies of the Software, and to permit persons to whom the Software is
|
42
42
|
furnished to do so, subject to the following conditions:
|
43
|
-
|
43
|
+
|
44
44
|
The above copyright notice and this permission notice shall be included in
|
45
45
|
all copies or substantial portions of the Software.
|
46
46
|
|
@@ -59,17 +59,17 @@
|
|
59
59
|
|
60
60
|
|
61
61
|
#define kUseObjectPoolDisabled 1 //!< Use an object pool to allocate tokens to improve
|
62
|
-
|
63
|
-
|
62
|
+
//!< performance in memory allocation. Frees all
|
63
|
+
//!< tokens at once, however, at end of parsing.
|
64
64
|
|
65
65
|
/// Should call init() once per thread/use, and drain() once per thread/use.
|
66
66
|
/// This allows us to know when the pool is no longer being used and it is safe
|
67
67
|
/// to free.
|
68
68
|
|
69
69
|
#ifdef kUseObjectPool
|
70
|
-
void token_pool_init(void);
|
71
|
-
void token_pool_drain(void);
|
72
|
-
void token_pool_free(void);
|
70
|
+
void token_pool_init(void); //!< Initialize object pool for allocating tokens
|
71
|
+
void token_pool_drain(void); //!< Drain pool to free memory when parse complete
|
72
|
+
void token_pool_free(void); //!< Free the token object pool
|
73
73
|
#endif
|
74
74
|
|
75
75
|
|
data/ext/mmd/latex.c
CHANGED
@@ -116,6 +116,10 @@ void mmd_print_char_latex(DString * out, char c) {
|
|
116
116
|
print_const("\\textbar{}");
|
117
117
|
break;
|
118
118
|
|
119
|
+
case '\n':
|
120
|
+
case '\r':
|
121
|
+
print_char('\\');
|
122
|
+
|
119
123
|
case '#':
|
120
124
|
case '{':
|
121
125
|
case '}':
|
@@ -214,6 +218,7 @@ void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_
|
|
214
218
|
break;
|
215
219
|
|
216
220
|
case FRENCH:
|
221
|
+
case SPANISH:
|
217
222
|
print_const("«");
|
218
223
|
break;
|
219
224
|
|
@@ -238,6 +243,7 @@ void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_
|
|
238
243
|
break;
|
239
244
|
|
240
245
|
case FRENCH:
|
246
|
+
case SPANISH:
|
241
247
|
print_const("»");
|
242
248
|
break;
|
243
249
|
|
@@ -261,14 +267,13 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin
|
|
261
267
|
if (text && text->child) {
|
262
268
|
temp_char = label_from_token(source, text);
|
263
269
|
|
264
|
-
if (
|
265
|
-
// [bar][bar] or [bar](#bar) or [bar]
|
266
|
-
printf("\\autoref{%s}", &(link->url)[1]);
|
267
|
-
} else {
|
270
|
+
if (temp_char && temp_char[0] != '\0') {
|
268
271
|
mmd_export_token_tree_latex(out, source, text->child, scratch);
|
269
272
|
print_const(" (");
|
270
273
|
printf("\\autoref{%s}", &(link->url)[1]);
|
271
274
|
print_const(")");
|
275
|
+
} else {
|
276
|
+
printf("\\autoref{%s}", &(link->url)[1]);
|
272
277
|
}
|
273
278
|
|
274
279
|
free(temp_char);
|
@@ -292,7 +297,9 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin
|
|
292
297
|
text->child->next->len++;
|
293
298
|
}
|
294
299
|
|
295
|
-
|
300
|
+
if (text && text->child) {
|
301
|
+
mmd_export_token_tree_latex(out, source, text->child, scratch);
|
302
|
+
}
|
296
303
|
|
297
304
|
print_const("}");
|
298
305
|
|
@@ -441,7 +448,7 @@ void mmd_export_toc_entry_latex(DString * out, const char * source, scratch_pad
|
|
441
448
|
if (entry_level >= level) {
|
442
449
|
// This entry is a direct descendant of the parent
|
443
450
|
temp_char = label_from_header(source, entry);
|
444
|
-
print_const("\\item
|
451
|
+
print_const("\\item ");
|
445
452
|
mmd_export_token_tree_latex(out, source, entry->child, scratch);
|
446
453
|
printf("(\\autoref{%s})\n\n", temp_char);
|
447
454
|
|
@@ -684,6 +691,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
684
691
|
}
|
685
692
|
|
686
693
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
694
|
+
trim_trailing_whitespace_d_string(out);
|
687
695
|
|
688
696
|
if (scratch->extensions & EXT_NO_LABELS) {
|
689
697
|
print_const("}");
|
@@ -763,7 +771,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
763
771
|
|
764
772
|
case BLOCK_LIST_ITEM:
|
765
773
|
pad(out, 2, scratch);
|
766
|
-
print_const("\\item
|
774
|
+
print_const("\\item ");
|
767
775
|
scratch->padded = 2;
|
768
776
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
769
777
|
scratch->padded = 0;
|
@@ -771,7 +779,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
771
779
|
|
772
780
|
case BLOCK_LIST_ITEM_TIGHT:
|
773
781
|
pad(out, 2, scratch);
|
774
|
-
print_const("\\item
|
782
|
+
print_const("\\item ");
|
775
783
|
scratch->padded = 2;
|
776
784
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
777
785
|
scratch->padded = 0;
|
@@ -798,7 +806,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
798
806
|
temp_token = t->next->child;
|
799
807
|
|
800
808
|
if (temp_token->next &&
|
801
|
-
|
809
|
+
temp_token->next->type == PAIR_BRACKET) {
|
802
810
|
temp_token = temp_token->next;
|
803
811
|
}
|
804
812
|
|
@@ -1026,7 +1034,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
1026
1034
|
|
1027
1035
|
case ESCAPED_CHARACTER:
|
1028
1036
|
if (!(scratch->extensions & EXT_COMPATIBILITY) &&
|
1029
|
-
|
1037
|
+
(source[t->start + 1] == ' ')) {
|
1030
1038
|
print_const("~");
|
1031
1039
|
} else {
|
1032
1040
|
mmd_print_char_latex(out, source[t->start + 1]);
|
@@ -1238,7 +1246,7 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
1238
1246
|
|
1239
1247
|
case PAIR_BRACKET:
|
1240
1248
|
if ((scratch->extensions & EXT_NOTES) &&
|
1241
|
-
|
1249
|
+
(t->next && t->next->type == PAIR_BRACKET_CITATION)) {
|
1242
1250
|
goto parse_citation;
|
1243
1251
|
}
|
1244
1252
|
|
@@ -1254,8 +1262,8 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
1254
1262
|
temp_token = t->next;
|
1255
1263
|
|
1256
1264
|
if (temp_token &&
|
1257
|
-
|
1258
|
-
|
1265
|
+
((temp_token->type == PAIR_BRACKET) ||
|
1266
|
+
(temp_token->type == PAIR_PAREN))) {
|
1259
1267
|
temp_token = temp_token->next;
|
1260
1268
|
}
|
1261
1269
|
|
@@ -1284,7 +1292,9 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
1284
1292
|
}
|
1285
1293
|
|
1286
1294
|
// No links exist, so treat as normal
|
1295
|
+
print_const("{");
|
1287
1296
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
1297
|
+
print_const("}");
|
1288
1298
|
break;
|
1289
1299
|
|
1290
1300
|
case PAIR_BRACKET_ABBREVIATION:
|
@@ -1299,9 +1309,9 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
1299
1309
|
|
1300
1310
|
if (temp_short == -1) {
|
1301
1311
|
// This instance is not properly formed
|
1302
|
-
print_const("[>");
|
1312
|
+
print_const("{[>");
|
1303
1313
|
mmd_export_token_tree_latex(out, source, t->child->next, scratch);
|
1304
|
-
print_const("]");
|
1314
|
+
print_const("]}");
|
1305
1315
|
break;
|
1306
1316
|
}
|
1307
1317
|
|
@@ -1325,7 +1335,9 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
|
|
1325
1335
|
}
|
1326
1336
|
} else {
|
1327
1337
|
// Note-based syntax disabled
|
1338
|
+
print_const("{");
|
1328
1339
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
1340
|
+
print_const("}");
|
1329
1341
|
}
|
1330
1342
|
|
1331
1343
|
break;
|
@@ -1366,9 +1378,9 @@ parse_citation:
|
|
1366
1378
|
// Ensure we aren't using BibTeX
|
1367
1379
|
if (!scratch->bibtex_file) {
|
1368
1380
|
// This instance is not properly formed
|
1369
|
-
print_const("[#");
|
1381
|
+
print_const("{[#");
|
1370
1382
|
mmd_export_token_tree_latex(out, source, t->child->next, scratch);
|
1371
|
-
print_const("]");
|
1383
|
+
print_const("]}");
|
1372
1384
|
|
1373
1385
|
free(temp_char);
|
1374
1386
|
break;
|
@@ -1448,7 +1460,9 @@ parse_citation:
|
|
1448
1460
|
free(temp_char);
|
1449
1461
|
} else {
|
1450
1462
|
// Note-based syntax disabled
|
1463
|
+
print_const("{");
|
1451
1464
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
1465
|
+
print_const("}");
|
1452
1466
|
}
|
1453
1467
|
|
1454
1468
|
break;
|
@@ -1463,9 +1477,9 @@ parse_citation:
|
|
1463
1477
|
|
1464
1478
|
if (temp_short == -1) {
|
1465
1479
|
// This instance is not properly formed
|
1466
|
-
print_const("[?");
|
1480
|
+
print_const("{[?");
|
1467
1481
|
mmd_export_token_tree_latex(out, source, t->child->next, scratch);
|
1468
|
-
print_const("]");
|
1482
|
+
print_const("]}");
|
1469
1483
|
break;
|
1470
1484
|
}
|
1471
1485
|
|
@@ -1488,16 +1502,18 @@ parse_citation:
|
|
1488
1502
|
print_const("}");
|
1489
1503
|
} else {
|
1490
1504
|
// This is the first time this note was used
|
1491
|
-
|
1492
1505
|
print_const("\\footnote{");
|
1493
1506
|
temp_note = stack_peek_index(scratch->used_footnotes, temp_short - 1);
|
1494
|
-
|
1507
|
+
// Reset padding counter in case of multiple footnotes in single paragraph
|
1508
|
+
scratch->padded = 2;
|
1495
1509
|
mmd_export_token_tree_latex(out, source, temp_note->content, scratch);
|
1496
1510
|
print_const("}");
|
1497
1511
|
}
|
1498
1512
|
} else {
|
1499
1513
|
// Note-based syntax disabled
|
1514
|
+
print_const("{");
|
1500
1515
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
1516
|
+
print_const("}");
|
1501
1517
|
}
|
1502
1518
|
|
1503
1519
|
break;
|
@@ -1515,7 +1531,7 @@ parse_citation:
|
|
1515
1531
|
|
1516
1532
|
if (temp_short == -1) {
|
1517
1533
|
// This instance is not properly formed
|
1518
|
-
print_const("[?");
|
1534
|
+
print_const("{[?");
|
1519
1535
|
|
1520
1536
|
if (t->child) {
|
1521
1537
|
mmd_export_token_tree_latex(out, source, t->child->next, scratch);
|
@@ -1523,7 +1539,7 @@ parse_citation:
|
|
1523
1539
|
print_token(t);
|
1524
1540
|
}
|
1525
1541
|
|
1526
|
-
print_const("]");
|
1542
|
+
print_const("]}");
|
1527
1543
|
break;
|
1528
1544
|
}
|
1529
1545
|
|
@@ -1563,7 +1579,9 @@ parse_citation:
|
|
1563
1579
|
}
|
1564
1580
|
} else {
|
1565
1581
|
// Note-based syntax disabled
|
1582
|
+
print_const("{");
|
1566
1583
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
1584
|
+
print_const("}");
|
1567
1585
|
}
|
1568
1586
|
|
1569
1587
|
break;
|
@@ -1575,7 +1593,9 @@ parse_citation:
|
|
1575
1593
|
if (temp_char2) {
|
1576
1594
|
mmd_print_string_latex(out, temp_char2);
|
1577
1595
|
} else {
|
1596
|
+
print_const("{");
|
1578
1597
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
1598
|
+
print_const("}");
|
1579
1599
|
}
|
1580
1600
|
|
1581
1601
|
// Don't free temp_char2 (it belongs to meta *)
|
@@ -1634,7 +1654,7 @@ parse_citation:
|
|
1634
1654
|
|
1635
1655
|
// Ignore if we're rejecting or accepting
|
1636
1656
|
if ((scratch->extensions & EXT_CRITIC_REJECT) ||
|
1637
|
-
|
1657
|
+
(scratch->extensions & EXT_CRITIC_ACCEPT)) {
|
1638
1658
|
break;
|
1639
1659
|
}
|
1640
1660
|
|
@@ -1654,7 +1674,7 @@ parse_citation:
|
|
1654
1674
|
|
1655
1675
|
// Ignore if we're rejecting or accepting
|
1656
1676
|
if ((scratch->extensions & EXT_CRITIC_REJECT) ||
|
1657
|
-
|
1677
|
+
(scratch->extensions & EXT_CRITIC_ACCEPT)) {
|
1658
1678
|
t->child->type = TEXT_EMPTY;
|
1659
1679
|
t->child->mate->type = TEXT_EMPTY;
|
1660
1680
|
mmd_export_token_tree_latex(out, source, t->child, scratch);
|
@@ -1684,8 +1704,8 @@ parse_citation:
|
|
1684
1704
|
|
1685
1705
|
case PAIR_CRITIC_SUB_DEL:
|
1686
1706
|
if ((scratch->extensions & EXT_CRITIC) &&
|
1687
|
-
|
1688
|
-
|
1707
|
+
(t->next) &&
|
1708
|
+
(t->next->type == PAIR_CRITIC_SUB_ADD)) {
|
1689
1709
|
t->child->type = TEXT_EMPTY;
|
1690
1710
|
t->child->mate->type = TEXT_EMPTY;
|
1691
1711
|
|
@@ -1706,8 +1726,8 @@ parse_citation:
|
|
1706
1726
|
|
1707
1727
|
case PAIR_CRITIC_SUB_ADD:
|
1708
1728
|
if ((scratch->extensions & EXT_CRITIC) &&
|
1709
|
-
|
1710
|
-
|
1729
|
+
(t->prev) &&
|
1730
|
+
(t->prev->type == PAIR_CRITIC_SUB_DEL)) {
|
1711
1731
|
t->child->type = TEXT_EMPTY;
|
1712
1732
|
t->child->mate->type = TEXT_EMPTY;
|
1713
1733
|
|
@@ -1930,6 +1950,7 @@ parse_citation:
|
|
1930
1950
|
case TEXT_BRACE_RIGHT:
|
1931
1951
|
print_const("\\");
|
1932
1952
|
|
1953
|
+
case PAIR_RAW_FILTER:
|
1933
1954
|
case RAW_FILTER_LEFT:
|
1934
1955
|
case TEXT_NUMBER_POSS_LIST:
|
1935
1956
|
case TEXT_PERIOD:
|
@@ -1981,6 +2002,8 @@ void mmd_export_token_latex_raw(DString * out, const char * source, token * t, s
|
|
1981
2002
|
return;
|
1982
2003
|
}
|
1983
2004
|
|
2005
|
+
char * temp;
|
2006
|
+
|
1984
2007
|
switch (t->type) {
|
1985
2008
|
case ESCAPED_CHARACTER:
|
1986
2009
|
print_const("\\");
|
@@ -1992,6 +2015,27 @@ void mmd_export_token_latex_raw(DString * out, const char * source, token * t, s
|
|
1992
2015
|
print_token(t);
|
1993
2016
|
break;
|
1994
2017
|
|
2018
|
+
case MARKER_LIST_BULLET:
|
2019
|
+
case MARKER_LIST_ENUMERATOR:
|
2020
|
+
print_token(t);
|
2021
|
+
|
2022
|
+
temp = NULL;
|
2023
|
+
|
2024
|
+
if (t->next) {
|
2025
|
+
temp = (char *) &source[t->next->start];
|
2026
|
+
}
|
2027
|
+
|
2028
|
+
source = (char *) &source[t->start + t->len];
|
2029
|
+
|
2030
|
+
while (char_is_whitespace(*source) &&
|
2031
|
+
((temp == NULL) ||
|
2032
|
+
(source < temp))) {
|
2033
|
+
print_char(*source);
|
2034
|
+
source++;
|
2035
|
+
}
|
2036
|
+
|
2037
|
+
break;
|
2038
|
+
|
1995
2039
|
case SUBSCRIPT:
|
1996
2040
|
if (t->child) {
|
1997
2041
|
print_const("\\ensuremath{\\sim}");
|
@@ -2020,6 +2064,10 @@ void mmd_export_token_latex_raw(DString * out, const char * source, token * t, s
|
|
2020
2064
|
case TEXT_EMPTY:
|
2021
2065
|
break;
|
2022
2066
|
|
2067
|
+
case TEXT_PERCENT:
|
2068
|
+
print_const("\\%");
|
2069
|
+
break;
|
2070
|
+
|
2023
2071
|
default:
|
2024
2072
|
if (t->child) {
|
2025
2073
|
mmd_export_token_tree_latex_raw(out, source, t->child, scratch);
|
@@ -2133,7 +2181,23 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
|
|
2133
2181
|
|
2134
2182
|
case ESCAPED_CHARACTER:
|
2135
2183
|
print_const("\\textbackslash{}");
|
2136
|
-
|
2184
|
+
|
2185
|
+
if (t->next && t->next->type == TEXT_EMPTY && source[t->start + 1] == ' ') {
|
2186
|
+
} else {
|
2187
|
+
mmd_print_char_latex(out, source[t->start + 1]);
|
2188
|
+
}
|
2189
|
+
|
2190
|
+
break;
|
2191
|
+
|
2192
|
+
case HASH1:
|
2193
|
+
case HASH2:
|
2194
|
+
case HASH3:
|
2195
|
+
case HASH4:
|
2196
|
+
case HASH5:
|
2197
|
+
case HASH6:
|
2198
|
+
case TEXT_HASH:
|
2199
|
+
print_const("\\");
|
2200
|
+
print_token(t);
|
2137
2201
|
break;
|
2138
2202
|
|
2139
2203
|
case HTML_ENTITY:
|
@@ -2152,6 +2216,14 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
|
|
2152
2216
|
t->next->type = TEXT_EMPTY;
|
2153
2217
|
}
|
2154
2218
|
|
2219
|
+
case MATH_DOLLAR_SINGLE:
|
2220
|
+
print_const("\\$");
|
2221
|
+
break;
|
2222
|
+
|
2223
|
+
case MATH_DOLLAR_DOUBLE:
|
2224
|
+
print_const("\\$\\$");
|
2225
|
+
break;
|
2226
|
+
|
2155
2227
|
case MATH_BRACKET_OPEN:
|
2156
2228
|
case MATH_BRACKET_CLOSE:
|
2157
2229
|
case MATH_PAREN_OPEN:
|
@@ -2207,6 +2279,10 @@ void mmd_export_token_latex_tt(DString * out, const char * source, token * t, sc
|
|
2207
2279
|
print_const("\\}");
|
2208
2280
|
break;
|
2209
2281
|
|
2282
|
+
case TEXT_PERCENT:
|
2283
|
+
print_const("\\%");
|
2284
|
+
break;
|
2285
|
+
|
2210
2286
|
case TOC:
|
2211
2287
|
print_const("\\{\\{TOC\\}\\}");
|
2212
2288
|
break;
|
@@ -2321,6 +2397,7 @@ void mmd_start_complete_latex(DString * out, const char * source, scratch_pad *
|
|
2321
2397
|
} else if (strcmp(m->key, "latexmode") == 0) {
|
2322
2398
|
} else if (strcmp(m->key, "mmdfooter") == 0) {
|
2323
2399
|
} else if (strcmp(m->key, "mmdheader") == 0) {
|
2400
|
+
} else if (strcmp(m->key, "odfheader") == 0) {
|
2324
2401
|
} else if (strcmp(m->key, "quoteslanguage") == 0) {
|
2325
2402
|
} else if (strcmp(m->key, "title") == 0) {
|
2326
2403
|
print_const("\\def\\mytitle{");
|