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/file.c
CHANGED
|
@@ -119,38 +119,48 @@
|
|
|
119
119
|
/// Scan file into a DString
|
|
120
120
|
DString * scan_file(const char * fname) {
|
|
121
121
|
/* Read from stdin and return a DString *
|
|
122
|
-
|
|
122
|
+
`buffer` will need to be freed elsewhere */
|
|
123
123
|
|
|
124
124
|
char chunk[kBUFFERSIZE];
|
|
125
125
|
size_t bytes;
|
|
126
126
|
|
|
127
127
|
FILE * file;
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
#if defined(__WIN32)
|
|
130
130
|
int wchars_num = MultiByteToWideChar(CP_UTF8, 0, fname, -1, NULL, 0);
|
|
131
131
|
wchar_t wstr[wchars_num];
|
|
132
132
|
MultiByteToWideChar(CP_UTF8, 0, fname, -1, wstr, wchars_num);
|
|
133
133
|
|
|
134
134
|
if ((file = _wfopen(wstr, L"rb")) == NULL) {
|
|
135
|
-
|
|
135
|
+
return NULL;
|
|
136
|
+
}
|
|
136
137
|
|
|
137
|
-
|
|
138
|
-
#endif
|
|
138
|
+
#else
|
|
139
139
|
|
|
140
|
+
if ((file = fopen(fname, "r")) == NULL ) {
|
|
140
141
|
return NULL;
|
|
141
142
|
}
|
|
142
143
|
|
|
144
|
+
#endif
|
|
145
|
+
|
|
143
146
|
DString * buffer = d_string_new("");
|
|
144
147
|
|
|
145
148
|
while ((bytes = fread(chunk, 1, kBUFFERSIZE, file)) > 0) {
|
|
146
149
|
d_string_append_c_array(buffer, chunk, bytes);
|
|
150
|
+
}
|
|
147
151
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
152
|
+
// Strip UTF-8 BOM
|
|
153
|
+
if (strncmp(buffer->str, "\xef\xbb\xbf", 3) == 0) {
|
|
154
|
+
d_string_erase(buffer, 0, 3);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Strip UTF-16 BOMs
|
|
158
|
+
if (strncmp(buffer->str, "\xef\xff", 2) == 0) {
|
|
159
|
+
d_string_erase(buffer, 0, 2);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (strncmp(buffer->str, "\xff\xfe", 2) == 0) {
|
|
163
|
+
d_string_erase(buffer, 0, 2);
|
|
154
164
|
}
|
|
155
165
|
|
|
156
166
|
fclose(file);
|
|
@@ -160,7 +170,7 @@ DString * scan_file(const char * fname) {
|
|
|
160
170
|
|
|
161
171
|
|
|
162
172
|
/// Scan from stdin into a DString
|
|
163
|
-
DString * stdin_buffer() {
|
|
173
|
+
DString * stdin_buffer(void) {
|
|
164
174
|
/* Read from stdin and return a GString *
|
|
165
175
|
`buffer` will need to be freed elsewhere */
|
|
166
176
|
|
|
@@ -182,38 +192,38 @@ DString * stdin_buffer() {
|
|
|
182
192
|
/// Windows can use either `\` or `/` as a separator -- thanks to t-beckmann on github
|
|
183
193
|
/// for suggesting a fix for this.
|
|
184
194
|
bool is_separator(char c) {
|
|
185
|
-
|
|
195
|
+
#if defined(__WIN32)
|
|
186
196
|
return c == '\\' || c == '/';
|
|
187
|
-
|
|
197
|
+
#else
|
|
188
198
|
return c == '/';
|
|
189
|
-
|
|
199
|
+
#endif
|
|
190
200
|
}
|
|
191
201
|
|
|
192
202
|
|
|
193
203
|
#ifdef TEST
|
|
194
|
-
void Test_is_separator(CuTest* tc) {
|
|
204
|
+
void Test_is_separator(CuTest * tc) {
|
|
195
205
|
char * test = "a/\\";
|
|
196
206
|
|
|
197
|
-
|
|
207
|
+
#if defined(__WIN32)
|
|
198
208
|
CuAssertIntEquals(tc, false, is_separator(test[0]));
|
|
199
209
|
CuAssertIntEquals(tc, true, is_separator(test[1]));
|
|
200
210
|
CuAssertIntEquals(tc, true, is_separator(test[2]));
|
|
201
|
-
|
|
211
|
+
#else
|
|
202
212
|
CuAssertIntEquals(tc, false, is_separator(test[0]));
|
|
203
213
|
CuAssertIntEquals(tc, true, is_separator(test[1]));
|
|
204
214
|
CuAssertIntEquals(tc, false, is_separator(test[2]));
|
|
205
|
-
|
|
215
|
+
#endif
|
|
206
216
|
}
|
|
207
217
|
#endif
|
|
208
218
|
|
|
209
219
|
|
|
210
220
|
/// Ensure that path ends in separator
|
|
211
221
|
void add_trailing_sep(DString * path) {
|
|
212
|
-
|
|
222
|
+
#if defined(__WIN32)
|
|
213
223
|
char sep = '\\';
|
|
214
|
-
|
|
224
|
+
#else
|
|
215
225
|
char sep = '/';
|
|
216
|
-
|
|
226
|
+
#endif
|
|
217
227
|
|
|
218
228
|
// Ensure that folder ends in separator
|
|
219
229
|
if ((path->currentStringLength == 0) || (!is_separator(path->str[path->currentStringLength - 1]))) {
|
|
@@ -234,7 +244,7 @@ static char * my_strndup(const char * source, size_t n) {
|
|
|
234
244
|
|
|
235
245
|
// strlen is too slow if strlen(source) >> n
|
|
236
246
|
for (len = 0; len < n; ++len) {
|
|
237
|
-
if (test == '\0') {
|
|
247
|
+
if (*test == '\0') {
|
|
238
248
|
break;
|
|
239
249
|
}
|
|
240
250
|
|
|
@@ -301,17 +311,17 @@ char * path_from_dir_base(const char * dir, const char * base) {
|
|
|
301
311
|
|
|
302
312
|
|
|
303
313
|
#ifdef TEST
|
|
304
|
-
void Test_path_from_dir_base(CuTest* tc) {
|
|
314
|
+
void Test_path_from_dir_base(CuTest * tc) {
|
|
305
315
|
char dir[10] = "/foo";
|
|
306
316
|
char base[10] = "bar";
|
|
307
317
|
|
|
308
318
|
char * path = path_from_dir_base(dir, base);
|
|
309
319
|
|
|
310
|
-
|
|
320
|
+
#if defined(__WIN32)
|
|
311
321
|
CuAssertStrEquals(tc, "/foo\\bar", path);
|
|
312
|
-
|
|
322
|
+
#else
|
|
313
323
|
CuAssertStrEquals(tc, "/foo/bar", path);
|
|
314
|
-
|
|
324
|
+
#endif
|
|
315
325
|
|
|
316
326
|
free(path);
|
|
317
327
|
strcpy(base, "/bar");
|
|
@@ -334,11 +344,11 @@ void Test_path_from_dir_base(CuTest* tc) {
|
|
|
334
344
|
void split_path_file(char ** dir, char ** file, const char * path) {
|
|
335
345
|
const char * slash = path, * next;
|
|
336
346
|
|
|
337
|
-
|
|
347
|
+
#if defined(__WIN32)
|
|
338
348
|
const char sep[] = "\\/"; // Windows allows either variant
|
|
339
|
-
|
|
349
|
+
#else
|
|
340
350
|
const char sep[] = "/";
|
|
341
|
-
|
|
351
|
+
#endif
|
|
342
352
|
|
|
343
353
|
while ((next = strpbrk(slash + 1, sep))) {
|
|
344
354
|
slash = next;
|
|
@@ -359,7 +369,7 @@ void split_path_file(char ** dir, char ** file, const char * path) {
|
|
|
359
369
|
|
|
360
370
|
|
|
361
371
|
#ifdef TEST
|
|
362
|
-
void Test_split_path_file(CuTest* tc) {
|
|
372
|
+
void Test_split_path_file(CuTest * tc) {
|
|
363
373
|
char * dir, * file;
|
|
364
374
|
|
|
365
375
|
char * path = "/foo/bar.txt";
|
|
@@ -371,13 +381,13 @@ void Test_split_path_file(CuTest* tc) {
|
|
|
371
381
|
path = "\\foo\\bar.txt";
|
|
372
382
|
split_path_file(&dir, &file, path);
|
|
373
383
|
|
|
374
|
-
|
|
384
|
+
#if defined(__WIN32)
|
|
375
385
|
CuAssertStrEquals(tc, "\\foo\\", dir);
|
|
376
386
|
CuAssertStrEquals(tc, "bar.txt", file);
|
|
377
|
-
|
|
387
|
+
#else
|
|
378
388
|
CuAssertStrEquals(tc, "", dir);
|
|
379
389
|
CuAssertStrEquals(tc, "\\foo\\bar.txt", file);
|
|
380
|
-
|
|
390
|
+
#endif
|
|
381
391
|
}
|
|
382
392
|
#endif
|
|
383
393
|
|
|
@@ -388,15 +398,15 @@ void Test_split_path_file(CuTest* tc) {
|
|
|
388
398
|
// Let compiler know where to find GetFullPathName()
|
|
389
399
|
#include <windows.h>
|
|
390
400
|
|
|
391
|
-
char *realpath(const char *path, char *resolved_path) {
|
|
401
|
+
char * realpath(const char * path, char * resolved_path) {
|
|
392
402
|
DWORD retval = 0;
|
|
393
403
|
DWORD dwBufSize = 0; // Just in case MAX_PATH differs from PATH_MAX
|
|
394
|
-
TCHAR
|
|
404
|
+
TCHAR * buffer = NULL;
|
|
395
405
|
|
|
396
406
|
if (resolved_path == NULL) {
|
|
397
407
|
// realpath allocates appropiate bytes if resolved_path is null. This is to mimic realpath behavior
|
|
398
408
|
dwBufSize = PATH_MAX; // Use windows PATH_MAX constant, because we are in Windows context now.
|
|
399
|
-
buffer = (char*)malloc(dwBufSize);
|
|
409
|
+
buffer = (char *)malloc(dwBufSize);
|
|
400
410
|
|
|
401
411
|
if (buffer == NULL) {
|
|
402
412
|
return NULL; // some really weird is going on...
|
|
@@ -421,15 +431,15 @@ char *realpath(const char *path, char *resolved_path) {
|
|
|
421
431
|
// Convert argument to absolute path
|
|
422
432
|
char * absolute_path_for_argument(const char * arg) {
|
|
423
433
|
char * result = NULL;
|
|
424
|
-
|
|
434
|
+
#ifdef PATH_MAX
|
|
425
435
|
// If PATH_MAX defined, use it
|
|
426
436
|
char absolute[PATH_MAX + 1];
|
|
427
437
|
realpath(arg, absolute);
|
|
428
438
|
result = my_strdup(absolute);
|
|
429
|
-
|
|
439
|
+
#else
|
|
430
440
|
// If undefined, then we *should* be able to use a NULL pointer to allocate
|
|
431
441
|
result = realpath(arg, NULL);
|
|
432
|
-
|
|
442
|
+
#endif
|
|
433
443
|
|
|
434
444
|
return result;
|
|
435
445
|
}
|
data/ext/mmd/file.h
CHANGED
|
@@ -121,7 +121,7 @@ DString * scan_file(const char * fname);
|
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
/// Scan from stdin into a DString
|
|
124
|
-
DString * stdin_buffer();
|
|
124
|
+
DString * stdin_buffer(void);
|
|
125
125
|
|
|
126
126
|
|
|
127
127
|
/// Windows can use either `\` or `/` as a separator -- thanks to t-beckmann on github
|
|
@@ -147,7 +147,7 @@ char * absolute_path_for_argument(const char * arg);
|
|
|
147
147
|
|
|
148
148
|
#if (defined(_WIN32) || defined(__WIN32__))
|
|
149
149
|
// Windows does not know realpath(), so we need a "windows port"
|
|
150
|
-
char *realpath(const char *path, char *resolved_path);
|
|
150
|
+
char * realpath(const char * path, char * resolved_path);
|
|
151
151
|
#endif
|
|
152
152
|
|
|
153
153
|
#endif
|