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/opml-reader.c
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/*
|
|
16
16
|
|
|
17
|
-
Copyright © 2016 -
|
|
17
|
+
Copyright © 2016 - 2019 Fletcher T. Penney.
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
The `MultiMarkdown 6` project is released under the MIT License..
|
|
@@ -104,18 +104,19 @@
|
|
|
104
104
|
#include <stdio.h>
|
|
105
105
|
#include <stdlib.h>
|
|
106
106
|
|
|
107
|
+
#include "d_string.h"
|
|
107
108
|
#include "mmd.h"
|
|
108
109
|
#include "opml-reader.h"
|
|
109
110
|
#include "opml-lexer.h"
|
|
110
111
|
#include "opml-parser.h"
|
|
111
112
|
#include "token.h"
|
|
112
|
-
|
|
113
|
+
#include "xml.h"
|
|
113
114
|
|
|
114
115
|
// Basic parser function declarations
|
|
115
|
-
void * OPMLAlloc();
|
|
116
|
-
void OPML();
|
|
117
|
-
void OPMLFree();
|
|
118
|
-
void OPMLTrace();
|
|
116
|
+
void * OPMLAlloc(void *);
|
|
117
|
+
void OPML(void *, int, void *, void *);
|
|
118
|
+
void OPMLFree(void *, void *);
|
|
119
|
+
void OPMLTrace(FILE * stream, char * zPrefix);
|
|
119
120
|
|
|
120
121
|
|
|
121
122
|
#define print(x) d_string_append(out, x)
|
|
@@ -188,107 +189,15 @@ token * tokenize_opml_string(mmd_engine * e, size_t start, size_t len) {
|
|
|
188
189
|
}
|
|
189
190
|
|
|
190
191
|
|
|
191
|
-
void print_opml_text(DString * out, const char * source, size_t start, size_t len) {
|
|
192
|
-
const char * s_start = &source[start];
|
|
193
|
-
const char * s_stop = &source[start + len];
|
|
194
|
-
|
|
195
|
-
char * c = (char *) s_start;
|
|
196
|
-
|
|
197
|
-
while (c < s_stop) {
|
|
198
|
-
switch (*c) {
|
|
199
|
-
case '&':
|
|
200
|
-
switch (*++c) {
|
|
201
|
-
case '#':
|
|
202
|
-
if (strncmp(c, "#10;", 4) == 0) {
|
|
203
|
-
print_char('\n');
|
|
204
|
-
c += 4;
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (strncmp(c, "#9;", 3) == 0) {
|
|
209
|
-
print_char('\t');
|
|
210
|
-
c += 3;
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (strncmp(c, "#13;", 4) == 0) {
|
|
215
|
-
print_char('\r');
|
|
216
|
-
c += 4;
|
|
217
|
-
continue;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
break;
|
|
221
|
-
|
|
222
|
-
case 'a':
|
|
223
|
-
if (strncmp(c, "amp;", 4) == 0) {
|
|
224
|
-
print_char('&');
|
|
225
|
-
c += 4;
|
|
226
|
-
continue;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
if (strncmp(c, "apos;", 5) == 0) {
|
|
230
|
-
print_char('\'');
|
|
231
|
-
c += 5;
|
|
232
|
-
continue;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
break;
|
|
236
|
-
|
|
237
|
-
case 'l':
|
|
238
|
-
if (strncmp(c, "lt;", 3) == 0) {
|
|
239
|
-
print_char('<');
|
|
240
|
-
c += 3;
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
break;
|
|
245
|
-
|
|
246
|
-
case 'g':
|
|
247
|
-
if (strncmp(c, "gt;", 3) == 0) {
|
|
248
|
-
print_char('>');
|
|
249
|
-
c += 3;
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
break;
|
|
254
|
-
|
|
255
|
-
case 'q':
|
|
256
|
-
if (strncmp(c, "quot;", 5) == 0) {
|
|
257
|
-
print_char('"');
|
|
258
|
-
c += 5;
|
|
259
|
-
continue;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
break;
|
|
263
|
-
|
|
264
|
-
default:
|
|
265
|
-
break;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
print_char('&');
|
|
269
|
-
continue;
|
|
270
|
-
break;
|
|
271
|
-
|
|
272
|
-
default:
|
|
273
|
-
print_char(*c);
|
|
274
|
-
break;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
c++;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
192
|
void parse_opml_token_chain(mmd_engine * e, token * chain) {
|
|
284
193
|
|
|
285
|
-
void* pParser = OPMLAlloc (malloc); // Create a parser (for lemon)
|
|
194
|
+
void * pParser = OPMLAlloc (malloc); // Create a parser (for lemon)
|
|
286
195
|
token * walker = chain->next; // Walk the existing tree
|
|
287
196
|
token * remainder; // Hold unparsed tail of chain
|
|
288
197
|
|
|
289
|
-
|
|
198
|
+
#ifndef NDEBUG
|
|
290
199
|
OPMLTrace(stderr, "parser >>");
|
|
291
|
-
|
|
200
|
+
#endif
|
|
292
201
|
|
|
293
202
|
// Remove existing token tree
|
|
294
203
|
e->root = NULL;
|
|
@@ -302,9 +211,9 @@ void parse_opml_token_chain(mmd_engine * e, token * chain) {
|
|
|
302
211
|
}
|
|
303
212
|
|
|
304
213
|
// Signal finish to parser
|
|
305
|
-
|
|
214
|
+
#ifndef NDEBUG
|
|
306
215
|
fprintf(stderr, "\nFinish parse\n");
|
|
307
|
-
|
|
216
|
+
#endif
|
|
308
217
|
OPML(pParser, 0, NULL, e);
|
|
309
218
|
|
|
310
219
|
if (e->root) {
|
|
@@ -328,59 +237,80 @@ void parse_opml_token_chain(mmd_engine * e, token * chain) {
|
|
|
328
237
|
// Advance over `<outline`
|
|
329
238
|
start = walker->start + 8;
|
|
330
239
|
|
|
331
|
-
|
|
332
|
-
len = scan_double_quoted(&(e->dstr->str[start]));
|
|
333
|
-
|
|
334
|
-
if (strncmp(&(e->dstr->str[start + 1]), "(Untitled Preamble)", 19) != 0) {
|
|
335
|
-
if (out == metadata) {
|
|
336
|
-
print_opml_text(out, e->dstr->str, start + 1, len - 2);
|
|
337
|
-
print_const(":\t");
|
|
338
|
-
} else {
|
|
339
|
-
// Print header
|
|
340
|
-
if (scan_encoded_newline(&(e->dstr->str[start + 1]), len - 2) == -1) {
|
|
341
|
-
// ATX header
|
|
342
|
-
for (int i = 0; i < header_level; ++i) {
|
|
343
|
-
print_char('#');
|
|
344
|
-
}
|
|
240
|
+
char * text = xml_extract_named_attribute(e->dstr->str, start, "text");
|
|
345
241
|
|
|
346
|
-
|
|
347
|
-
|
|
242
|
+
if (text) {
|
|
243
|
+
len = strlen(text);
|
|
348
244
|
|
|
349
|
-
|
|
245
|
+
if (strcmp(">>Preamble<<", text) != 0) {
|
|
246
|
+
if (out == metadata) {
|
|
247
|
+
print_xml_as_text(out, text, 0, len);
|
|
248
|
+
print_const(":\t");
|
|
249
|
+
} else {
|
|
250
|
+
// Print header
|
|
350
251
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
252
|
+
if (xml_scan_encoded_newline(text, len) == -1) {
|
|
253
|
+
// ATX header
|
|
254
|
+
for (int i = 0; i < header_level; ++i) {
|
|
255
|
+
print_char('#');
|
|
256
|
+
}
|
|
354
257
|
|
|
355
|
-
|
|
356
|
-
print_char('#');
|
|
258
|
+
print_char(' ');
|
|
357
259
|
}
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
260
|
+
|
|
261
|
+
print_xml_as_text(out, text, 0, len);
|
|
262
|
+
|
|
263
|
+
if (xml_scan_encoded_newline(text, len) == -1) {
|
|
264
|
+
// ATX header
|
|
265
|
+
print_char(' ');
|
|
266
|
+
|
|
267
|
+
for (int i = 0; i < header_level; ++i) {
|
|
268
|
+
print_char('#');
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
// Print Setext Header
|
|
272
|
+
switch (header_level) {
|
|
273
|
+
case 1:
|
|
274
|
+
print_const("\n======");
|
|
275
|
+
break;
|
|
276
|
+
|
|
277
|
+
default:
|
|
278
|
+
print_const("\n------");
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
368
281
|
}
|
|
369
|
-
}
|
|
370
282
|
|
|
371
|
-
|
|
283
|
+
print_const("\n");
|
|
284
|
+
}
|
|
372
285
|
}
|
|
286
|
+
|
|
287
|
+
free(text);
|
|
373
288
|
}
|
|
374
289
|
|
|
375
290
|
// Print contents
|
|
376
|
-
start
|
|
377
|
-
|
|
378
|
-
|
|
291
|
+
text = xml_extract_named_attribute(e->dstr->str, start, "_note");
|
|
292
|
+
|
|
293
|
+
if (text) {
|
|
294
|
+
print_xml_as_text(out, text, 0, strlen(text));
|
|
379
295
|
|
|
380
|
-
|
|
296
|
+
free(text);
|
|
297
|
+
}
|
|
381
298
|
|
|
382
299
|
if (out == metadata) {
|
|
383
|
-
|
|
300
|
+
print_const(" \n");
|
|
301
|
+
} else {
|
|
302
|
+
// Ensure that contents end in newline
|
|
303
|
+
if (out->currentStringLength) {
|
|
304
|
+
switch (out->str[out->currentStringLength - 1]) {
|
|
305
|
+
case '\n':
|
|
306
|
+
case '\r':
|
|
307
|
+
break;
|
|
308
|
+
|
|
309
|
+
default:
|
|
310
|
+
d_string_append_c(out, '\n');
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
384
314
|
}
|
|
385
315
|
|
|
386
316
|
if (walker->type == OPML_OUTLINE_SELF_CLOSE) {
|
data/ext/mmd/opml-reader.h
CHANGED
data/ext/mmd/opml.c
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
/*
|
|
16
16
|
|
|
17
|
-
Copyright © 2016 -
|
|
17
|
+
Copyright © 2016 - 2019 Fletcher T. Penney.
|
|
18
18
|
|
|
19
19
|
|
|
20
20
|
The `MultiMarkdown 6` project is released under the MIT License..
|
|
@@ -108,6 +108,8 @@
|
|
|
108
108
|
|
|
109
109
|
#include "opml.h"
|
|
110
110
|
#include "parser.h"
|
|
111
|
+
#include "stack.h"
|
|
112
|
+
|
|
111
113
|
|
|
112
114
|
#define print(x) d_string_append(out, x)
|
|
113
115
|
#define print_const(x) d_string_append_c_array(out, x, sizeof(x) - 1)
|
|
@@ -118,7 +120,7 @@
|
|
|
118
120
|
|
|
119
121
|
|
|
120
122
|
|
|
121
|
-
void
|
|
123
|
+
void mmd_print_source_opml(DString * out, const char * source, size_t start, size_t len) {
|
|
122
124
|
const char * s_start = &source[start];
|
|
123
125
|
const char * s_stop = &source[start + len];
|
|
124
126
|
|
|
@@ -190,7 +192,7 @@ void mmd_check_preamble_opml(DString * out, token * t, scratch_pad * scratch) {
|
|
|
190
192
|
break;
|
|
191
193
|
|
|
192
194
|
default:
|
|
193
|
-
print_const("<outline text=\"
|
|
195
|
+
print_const("<outline text=\">>Preamble<<\" _note=\"");
|
|
194
196
|
scratch->opml_item_closed = 0;
|
|
195
197
|
stack_push(scratch->outline_stack, walker);
|
|
196
198
|
walker = NULL;
|
|
@@ -211,7 +213,7 @@ void mmd_export_title_opml(DString * out, const char * source, scratch_pad * scr
|
|
|
211
213
|
print_const("<head><title>");
|
|
212
214
|
|
|
213
215
|
size_t len = strlen(m->value);
|
|
214
|
-
|
|
216
|
+
mmd_print_source_opml(out, m->value, 0, len);
|
|
215
217
|
|
|
216
218
|
print_const("</title></head>\n");
|
|
217
219
|
}
|
|
@@ -224,16 +226,16 @@ void mmd_export_metadata_opml(DString * out, const char * source, scratch_pad *
|
|
|
224
226
|
size_t len;
|
|
225
227
|
|
|
226
228
|
if (scratch->meta_hash) {
|
|
227
|
-
print_const("<outline text=\"Metadata
|
|
229
|
+
print_const("<outline text=\">>Metadata<<\">\n");
|
|
228
230
|
|
|
229
231
|
for (m = scratch->meta_hash; m != NULL; m = m->hh.next) {
|
|
230
232
|
print_const("<outline text=\"");
|
|
231
233
|
len = strlen(m->key);
|
|
232
|
-
|
|
234
|
+
mmd_print_source_opml(out, m->key, 0, len);
|
|
233
235
|
|
|
234
236
|
print_const("\" _note=\"");
|
|
235
237
|
len = strlen(m->value);
|
|
236
|
-
|
|
238
|
+
mmd_print_source_opml(out, m->value, 0, len);
|
|
237
239
|
|
|
238
240
|
print_const("\"/>\n");
|
|
239
241
|
}
|
|
@@ -321,7 +323,7 @@ void mmd_outline_add_opml(DString * out, const char * source, token * current, s
|
|
|
321
323
|
}
|
|
322
324
|
|
|
323
325
|
// Output as XML string
|
|
324
|
-
|
|
326
|
+
mmd_print_source_opml(out, source, start, len);
|
|
325
327
|
|
|
326
328
|
print_const("\">");
|
|
327
329
|
scratch->opml_item_closed = 1;
|
|
@@ -417,6 +419,8 @@ void mmd_export_header_opml(DString * out, const char * source, token * t, scrat
|
|
|
417
419
|
case MARKER_H4:
|
|
418
420
|
case MARKER_H5:
|
|
419
421
|
case MARKER_H6:
|
|
422
|
+
case MARKER_SETEXT_1:
|
|
423
|
+
case MARKER_SETEXT_2:
|
|
420
424
|
walker = walker->prev;
|
|
421
425
|
break;
|
|
422
426
|
|
|
@@ -427,7 +431,7 @@ void mmd_export_header_opml(DString * out, const char * source, token * t, scrat
|
|
|
427
431
|
}
|
|
428
432
|
}
|
|
429
433
|
|
|
430
|
-
|
|
434
|
+
mmd_print_source_opml(out, source, start, stop - start);
|
|
431
435
|
}
|
|
432
436
|
}
|
|
433
437
|
|
|
@@ -437,10 +441,6 @@ void mmd_export_token_opml(DString * out, const char * source, token * t, scratc
|
|
|
437
441
|
return;
|
|
438
442
|
}
|
|
439
443
|
|
|
440
|
-
short temp_short;
|
|
441
|
-
char * temp_char = NULL;
|
|
442
|
-
token * temp_token = NULL;
|
|
443
|
-
|
|
444
444
|
switch (t->type) {
|
|
445
445
|
case DOC_START_TOKEN:
|
|
446
446
|
print_const("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<opml version=\"1.0\">\n");
|