rmultimarkdown 4.7.1.1 → 6.2.2.1

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.
Files changed (110) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +2 -2
  3. data/README.md +7 -9
  4. data/Rakefile +33 -18
  5. data/ext/Makefile +261 -0
  6. data/ext/extconf.rb +23 -3
  7. data/ext/mmd/aho-corasick.c +596 -0
  8. data/ext/mmd/aho-corasick.h +120 -0
  9. data/ext/mmd/beamer.c +344 -0
  10. data/ext/mmd/beamer.h +72 -0
  11. data/ext/mmd/char.c +156 -0
  12. data/ext/mmd/char.h +111 -0
  13. data/ext/mmd/char_lookup.c +212 -0
  14. data/ext/mmd/critic_markup.c +330 -0
  15. data/ext/mmd/critic_markup.h +94 -0
  16. data/ext/mmd/d_string.c +402 -0
  17. data/ext/mmd/epub.c +563 -0
  18. data/ext/mmd/epub.h +69 -0
  19. data/ext/mmd/fodt.c +2288 -0
  20. data/ext/mmd/fodt.h +81 -0
  21. data/ext/mmd/html.c +2460 -0
  22. data/ext/mmd/html.h +81 -0
  23. data/ext/mmd/i18n.h +170 -0
  24. data/ext/mmd/include/d_string.h +182 -0
  25. data/ext/mmd/include/libMultiMarkdown.h +548 -0
  26. data/ext/mmd/include/token.h +233 -0
  27. data/ext/mmd/latex.c +2435 -0
  28. data/ext/mmd/latex.h +83 -0
  29. data/ext/mmd/lexer.c +3001 -0
  30. data/ext/mmd/lexer.h +75 -0
  31. data/ext/mmd/memoir.c +138 -0
  32. data/ext/mmd/memoir.h +67 -0
  33. data/ext/mmd/miniz.c +7557 -0
  34. data/ext/mmd/miniz.h +1328 -0
  35. data/ext/mmd/mmd.c +2798 -0
  36. data/ext/mmd/mmd.h +120 -0
  37. data/ext/mmd/object_pool.c +141 -0
  38. data/ext/mmd/object_pool.h +101 -0
  39. data/ext/mmd/opendocument-content.c +2071 -0
  40. data/ext/mmd/opendocument-content.h +135 -0
  41. data/ext/mmd/opendocument.c +981 -0
  42. data/ext/mmd/opendocument.h +118 -0
  43. data/ext/mmd/parser.c +1760 -0
  44. data/ext/mmd/parser.h +39 -0
  45. data/{MultiMarkdown-4 → ext/mmd}/rng.c +90 -49
  46. data/ext/mmd/scanners.c +77512 -0
  47. data/ext/mmd/scanners.h +101 -0
  48. data/ext/mmd/stack.c +142 -0
  49. data/ext/mmd/stack.h +113 -0
  50. data/ext/mmd/textbundle.c +455 -0
  51. data/ext/mmd/textbundle.h +115 -0
  52. data/ext/mmd/token.c +773 -0
  53. data/ext/mmd/token_pairs.c +263 -0
  54. data/ext/mmd/token_pairs.h +123 -0
  55. data/ext/mmd/transclude.c +549 -0
  56. data/ext/mmd/transclude.h +87 -0
  57. data/ext/mmd/uthash.h +1074 -0
  58. data/ext/mmd/uuid.c +154 -0
  59. data/ext/mmd/uuid.h +77 -0
  60. data/ext/mmd/version.h +111 -0
  61. data/ext/mmd/writer.c +2652 -0
  62. data/ext/mmd/writer.h +260 -0
  63. data/ext/mmd/zip.c +210 -0
  64. data/ext/mmd/zip.h +120 -0
  65. data/ext/{multi_markdown.c → ruby_multi_markdown.c} +87 -18
  66. data/lib/multi_markdown.bundle +0 -0
  67. data/lib/multi_markdown.rb +5 -8
  68. data/lib/multi_markdown/version.rb +1 -1
  69. data/rmultimarkdown.gemspec +2 -2
  70. data/test/{extensions_test.rb.rb → extensions_test.rb} +10 -54
  71. data/test/multi_markdown_test.rb +13 -0
  72. metadata +67 -47
  73. data/MultiMarkdown-4/GLibFacade.c +0 -310
  74. data/MultiMarkdown-4/GLibFacade.h +0 -100
  75. data/MultiMarkdown-4/beamer.c +0 -182
  76. data/MultiMarkdown-4/beamer.h +0 -11
  77. data/MultiMarkdown-4/critic.c +0 -111
  78. data/MultiMarkdown-4/critic.h +0 -15
  79. data/MultiMarkdown-4/glib.h +0 -11
  80. data/MultiMarkdown-4/html.c +0 -1117
  81. data/MultiMarkdown-4/html.h +0 -14
  82. data/MultiMarkdown-4/latex.c +0 -1217
  83. data/MultiMarkdown-4/latex.h +0 -16
  84. data/MultiMarkdown-4/libMultiMarkdown.h +0 -177
  85. data/MultiMarkdown-4/lyx.c +0 -2265
  86. data/MultiMarkdown-4/lyx.h +0 -37
  87. data/MultiMarkdown-4/lyxbeamer.c +0 -265
  88. data/MultiMarkdown-4/lyxbeamer.h +0 -11
  89. data/MultiMarkdown-4/memoir.c +0 -80
  90. data/MultiMarkdown-4/memoir.h +0 -10
  91. data/MultiMarkdown-4/multimarkdown.c +0 -518
  92. data/MultiMarkdown-4/odf.c +0 -1222
  93. data/MultiMarkdown-4/odf.h +0 -18
  94. data/MultiMarkdown-4/opml.c +0 -189
  95. data/MultiMarkdown-4/opml.h +0 -15
  96. data/MultiMarkdown-4/parse_utilities.c +0 -884
  97. data/MultiMarkdown-4/parser.c +0 -16656
  98. data/MultiMarkdown-4/parser.h +0 -188
  99. data/MultiMarkdown-4/rtf.c +0 -665
  100. data/MultiMarkdown-4/rtf.h +0 -17
  101. data/MultiMarkdown-4/strtok.c +0 -56
  102. data/MultiMarkdown-4/strtok.h +0 -9
  103. data/MultiMarkdown-4/text.c +0 -53
  104. data/MultiMarkdown-4/text.h +0 -11
  105. data/MultiMarkdown-4/toc.c +0 -142
  106. data/MultiMarkdown-4/toc.h +0 -15
  107. data/MultiMarkdown-4/transclude.c +0 -307
  108. data/MultiMarkdown-4/transclude.h +0 -28
  109. data/MultiMarkdown-4/writer.c +0 -731
  110. data/MultiMarkdown-4/writer.h +0 -38
@@ -0,0 +1,120 @@
1
+ /**
2
+
3
+ C-Template -- Boilerplate c project with cmake support, CuTest unit testing, and more.
4
+
5
+ @file aho-corasick.h
6
+
7
+ @brief
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2015-2017 Fletcher T. Penney.
18
+
19
+
20
+ The `c-template` project is released under the MIT License.
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the text
30
+ of the license.
31
+
32
+
33
+ ## The MIT License ##
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in
43
+ all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ THE SOFTWARE.
52
+
53
+ */
54
+
55
+
56
+ #ifndef AC_TEMPLATE_H
57
+ #define AC_TEMPLATE_H
58
+
59
+ #include <string.h>
60
+
61
+ struct trie_node {
62
+ char c; // Character for this node
63
+ unsigned short match_type; // 0 = no match, otherwise what have we matched?
64
+ unsigned short len; // Length of string matched
65
+ size_t child[256]; // Where should we go next?
66
+ size_t ac_fail; // Where should we go if we fail?
67
+ };
68
+
69
+ typedef struct trie_node trie_node;
70
+
71
+
72
+ struct trie {
73
+ size_t size; // How many nodes are in use?
74
+ size_t capacity; // How many nodes can we hold
75
+
76
+ trie_node * node; // Pointer to stack of nodes
77
+ };
78
+
79
+ typedef struct trie trie;
80
+
81
+
82
+ struct match {
83
+ size_t start; // Starting offset for this match
84
+ size_t len; // Length for this match
85
+ unsigned short match_type; // Match type
86
+ struct match * next; // Pointer to next match in list
87
+ struct match * prev; // Pointer to previous match in list
88
+ };
89
+
90
+ typedef struct match match;
91
+
92
+
93
+ trie * trie_new(size_t startingSize);
94
+
95
+ bool trie_insert(trie * a, const char * key, unsigned short match_type);
96
+
97
+ void ac_trie_prepare(trie * a);
98
+
99
+ match * ac_trie_search(trie * a, const char * source, size_t start, size_t len);
100
+
101
+ match * ac_trie_leftmost_longest_search(trie * a, const char * source, size_t start, size_t len);
102
+
103
+ void trie_free(trie * a);
104
+
105
+ void match_set_describe(match * m, const char * source);
106
+
107
+ void match_set_filter_leftmost_longest(match * header);
108
+
109
+ void match_free(match * m);
110
+
111
+
112
+ void trie_to_graphviz(trie * a);
113
+
114
+
115
+ #ifdef TEST
116
+ #include "CuTest.h"
117
+ #endif
118
+
119
+
120
+ #endif
data/ext/mmd/beamer.c ADDED
@@ -0,0 +1,344 @@
1
+ /**
2
+
3
+ MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
4
+
5
+ @file beamer.c
6
+
7
+ @brief
8
+
9
+
10
+ @author Fletcher T. Penney
11
+ @bug
12
+
13
+ **/
14
+
15
+ /*
16
+
17
+ Copyright © 2016 - 2017 Fletcher T. Penney.
18
+
19
+
20
+ The `MultiMarkdown 6` project is released under the MIT License..
21
+
22
+ GLibFacade.c and GLibFacade.h are from the MultiMarkdown v4 project:
23
+
24
+ https://github.com/fletcher/MultiMarkdown-4/
25
+
26
+ MMD 4 is released under both the MIT License and GPL.
27
+
28
+
29
+ CuTest is released under the zlib/libpng license. See CuTest.c for the text
30
+ of the license.
31
+
32
+
33
+ ## The MIT License ##
34
+
35
+ Permission is hereby granted, free of charge, to any person obtaining a copy
36
+ of this software and associated documentation files (the "Software"), to deal
37
+ in the Software without restriction, including without limitation the rights
38
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
39
+ copies of the Software, and to permit persons to whom the Software is
40
+ furnished to do so, subject to the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be included in
43
+ all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
46
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
47
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
48
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
49
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
50
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
51
+ THE SOFTWARE.
52
+
53
+ */
54
+
55
+
56
+ #include "latex.h"
57
+ #include "beamer.h"
58
+
59
+ #define print(x) d_string_append(out, x)
60
+ #define print_const(x) d_string_append_c_array(out, x, sizeof(x) - 1)
61
+ #define print_char(x) d_string_append_c(out, x)
62
+ #define printf(...) d_string_append_printf(out, __VA_ARGS__)
63
+ #define print_token(t) d_string_append_c_array(out, &(source[t->start]), t->len)
64
+ #define print_localized(x) mmd_print_localized_char_latex(out, x, scratch)
65
+
66
+
67
+ void mmd_outline_add_beamer(DString * out, token * current, scratch_pad * scratch) {
68
+ token * t;
69
+ short level; // Header level we are adding
70
+ short t_level;
71
+ stack * s = scratch->outline_stack;
72
+
73
+ if (current) {
74
+ switch (current->type) {
75
+ case BLOCK_SETEXT_1:
76
+ level = 1;
77
+ break;
78
+
79
+ case BLOCK_SETEXT_2:
80
+ level = 2;
81
+ break;
82
+
83
+ default:
84
+ level = 1 + current->type - BLOCK_H1;
85
+ }
86
+
87
+ level += scratch->base_header_level - 1;
88
+ } else {
89
+ level = 0;
90
+ }
91
+
92
+ if (s->size) {
93
+ t = stack_peek(s);
94
+
95
+ while (t) {
96
+ switch (t->type) {
97
+ case BLOCK_SETEXT_1:
98
+ t_level = 1;
99
+ break;
100
+
101
+ case BLOCK_SETEXT_2:
102
+ t_level = 2;
103
+ break;
104
+
105
+ default:
106
+ t_level = 1 + t->type - BLOCK_H1;
107
+ }
108
+
109
+ t_level += scratch->base_header_level - 1;
110
+
111
+ if (t_level >= level) {
112
+ // Close out level
113
+ switch (t_level) {
114
+ case 3:
115
+ pad(out, 1, scratch);
116
+ print_const("\\end{frame}\n\n");
117
+ scratch->padded = 2;
118
+ break;
119
+
120
+ case 4:
121
+ pad(out, 1, scratch);
122
+ print_const("}\n\n");
123
+ scratch->padded = 2;
124
+ break;
125
+ }
126
+
127
+ stack_pop(s);
128
+ t = stack_peek(s);
129
+ } else {
130
+ // Nothing to close
131
+ t = NULL;
132
+ }
133
+ }
134
+ }
135
+
136
+
137
+ // Add current level to stack and open
138
+ switch (level) {
139
+ case 3:
140
+ pad(out, 2, scratch);
141
+ print_const("\\begin{frame}[fragile]\n");
142
+ scratch->padded = 1;
143
+ stack_push(s, current);
144
+ break;
145
+
146
+ case 4:
147
+ pad(out, 2, scratch);
148
+ print_const("\\mode<article>{");
149
+ scratch->padded = 0;
150
+ stack_push(s, current);
151
+ break;
152
+ }
153
+ }
154
+
155
+
156
+ void mmd_export_token_beamer(DString * out, const char * source, token * t, scratch_pad * scratch) {
157
+ if (t == NULL) {
158
+ return;
159
+ }
160
+
161
+ short temp_short;
162
+ char * temp_char = NULL;
163
+ token * temp_token = NULL;
164
+
165
+ switch (t->type) {
166
+ case DOC_START_TOKEN:
167
+ mmd_export_token_tree_beamer(out, source, t->child, scratch);
168
+ break;
169
+
170
+ case BLOCK_CODE_FENCED:
171
+ pad(out, 2, scratch);
172
+
173
+ temp_char = get_fence_language_specifier(t->child->child, source);
174
+
175
+ if (temp_char) {
176
+ printf("\\begin{lstlisting}[language=%s]\n", temp_char);
177
+ } else {
178
+ print_const("\\begin{verbatim}\n");
179
+ }
180
+
181
+ mmd_export_token_tree_latex_raw(out, source, t->child->next, scratch);
182
+
183
+ if (temp_char) {
184
+ print_const("\\end{lstlisting}");
185
+ free(temp_char);
186
+ } else {
187
+ print_const("\\end{verbatim}");
188
+ }
189
+
190
+ scratch->padded = 0;
191
+ break;
192
+
193
+ case BLOCK_CODE_INDENTED:
194
+ pad(out, 2, scratch);
195
+ print_const("\\begin{verbatim}\n");
196
+ mmd_export_token_tree_latex_raw(out, source, t->child, scratch);
197
+ print_const("\\end{verbatim}");
198
+ scratch->padded = 0;
199
+ break;
200
+
201
+ case BLOCK_H1:
202
+ case BLOCK_H2:
203
+ case BLOCK_H3:
204
+ case BLOCK_H4:
205
+ case BLOCK_H5:
206
+ case BLOCK_H6:
207
+ case BLOCK_SETEXT_1:
208
+ case BLOCK_SETEXT_2:
209
+ pad(out, 2, scratch);
210
+
211
+ mmd_outline_add_beamer(out, t, scratch);
212
+
213
+ switch (t->type) {
214
+ case BLOCK_SETEXT_1:
215
+ temp_short = 1;
216
+ break;
217
+
218
+ case BLOCK_SETEXT_2:
219
+ temp_short = 2;
220
+ break;
221
+
222
+ default:
223
+ temp_short = t->type - BLOCK_H1 + 1;
224
+ }
225
+
226
+ switch (temp_short + scratch->base_header_level - 1) {
227
+ case 1:
228
+ print_const("\\part{");
229
+ break;
230
+
231
+ case 2:
232
+ print_const("\\section{");
233
+ break;
234
+
235
+ case 3:
236
+ print_const("\\frametitle{");
237
+ break;
238
+
239
+ default:
240
+ print_const("\\emph{");
241
+ break;
242
+ }
243
+
244
+ mmd_export_token_tree_beamer(out, source, t->child, scratch);
245
+
246
+ if (scratch->extensions & EXT_NO_LABELS) {
247
+ print_const("}");
248
+ } else {
249
+ temp_token = manual_label_from_header(t, source);
250
+
251
+ if (temp_token) {
252
+ temp_char = label_from_token(source, temp_token);
253
+ } else {
254
+ temp_char = label_from_token(source, t);
255
+ }
256
+
257
+ printf("}\n\\label{%s}", temp_char);
258
+
259
+ if (temp_char) {
260
+ free(temp_char);
261
+ }
262
+ }
263
+
264
+ scratch->padded = 0;
265
+ break;
266
+
267
+ default:
268
+ // Default to LaTeX behavior
269
+ mmd_export_token_latex(out, source, t, scratch);
270
+ }
271
+ }
272
+
273
+
274
+ void mmd_export_token_tree_beamer(DString * out, const char * source, token * t, scratch_pad * scratch) {
275
+
276
+ // Prevent stack overflow with "dangerous" input causing extreme recursion
277
+ if (scratch->recurse_depth == kMaxExportRecursiveDepth) {
278
+ return;
279
+ }
280
+
281
+ scratch->recurse_depth++;
282
+
283
+ while (t != NULL) {
284
+ if (scratch->skip_token) {
285
+ scratch->skip_token--;
286
+ } else {
287
+ mmd_export_token_beamer(out, source, t, scratch);
288
+ }
289
+
290
+ t = t->next;
291
+ }
292
+
293
+ scratch->recurse_depth--;
294
+ }
295
+
296
+
297
+ void mmd_export_citation_list_beamer(DString * out, const char * source, scratch_pad * scratch) {
298
+ if (scratch->used_citations->size > 0) {
299
+ footnote * note;
300
+ token * content;
301
+
302
+ pad(out, 2, scratch);
303
+ print_const("\\part{Bibliography}\n\\begin{frame}[allowframebreaks]\n\\frametitle{Bibliography}\n\\def\\newblock{}\n\\begin{thebibliography}{0}");
304
+ scratch->padded = 0;
305
+
306
+ for (int i = 0; i < scratch->used_citations->size; ++i) {
307
+ // Export footnote
308
+ pad(out, 2, scratch);
309
+
310
+ note = stack_peek_index(scratch->used_citations, i);
311
+
312
+ printf("\\bibitem{%s}\n", note->label_text);
313
+ scratch->padded = 6;
314
+
315
+ scratch->footnote_para_counter = 0;
316
+
317
+ content = note->content;
318
+ scratch->citation_being_printed = i + 1;
319
+
320
+ mmd_export_token_tree_latex(out, source, content, scratch);
321
+ }
322
+
323
+ pad(out, 1, scratch);
324
+ print_const("\\end{thebibliography}\n\\end{frame}");
325
+ scratch->padded = 0;
326
+ scratch->citation_being_printed = 0;
327
+ }
328
+ }
329
+
330
+
331
+ void mmd_end_complete_beamer(DString * out, const char * source, scratch_pad * scratch) {
332
+ pad(out, 2, scratch);
333
+
334
+ print_const("\\mode<all>\n");
335
+ meta * m = extract_meta_from_stack(scratch, "latexfooter");
336
+
337
+ if (m) {
338
+ printf("\\input{%s}\n\n", m->value);
339
+ }
340
+
341
+ print_const("\\end{document}");
342
+ print_const("\\mode*\n");
343
+ scratch->padded = 0;
344
+ }