qiita_marker 0.23.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +50 -0
- data/Rakefile +113 -0
- data/bin/qiita_marker +123 -0
- data/ext/qiita_marker/arena.c +103 -0
- data/ext/qiita_marker/autolink.c +425 -0
- data/ext/qiita_marker/autolink.h +8 -0
- data/ext/qiita_marker/blocks.c +1596 -0
- data/ext/qiita_marker/buffer.c +278 -0
- data/ext/qiita_marker/buffer.h +116 -0
- data/ext/qiita_marker/case_fold_switch.inc +4327 -0
- data/ext/qiita_marker/chunk.h +135 -0
- data/ext/qiita_marker/cmark-gfm-core-extensions.h +54 -0
- data/ext/qiita_marker/cmark-gfm-extension_api.h +736 -0
- data/ext/qiita_marker/cmark-gfm-extensions_export.h +42 -0
- data/ext/qiita_marker/cmark-gfm.h +817 -0
- data/ext/qiita_marker/cmark-gfm_export.h +42 -0
- data/ext/qiita_marker/cmark-gfm_version.h +7 -0
- data/ext/qiita_marker/cmark.c +55 -0
- data/ext/qiita_marker/cmark_ctype.c +44 -0
- data/ext/qiita_marker/cmark_ctype.h +33 -0
- data/ext/qiita_marker/commonmark.c +529 -0
- data/ext/qiita_marker/config.h +76 -0
- data/ext/qiita_marker/core-extensions.c +27 -0
- data/ext/qiita_marker/entities.inc +2138 -0
- data/ext/qiita_marker/ext_scanners.c +879 -0
- data/ext/qiita_marker/ext_scanners.h +24 -0
- data/ext/qiita_marker/extconf.rb +7 -0
- data/ext/qiita_marker/footnotes.c +63 -0
- data/ext/qiita_marker/footnotes.h +27 -0
- data/ext/qiita_marker/houdini.h +57 -0
- data/ext/qiita_marker/houdini_href_e.c +100 -0
- data/ext/qiita_marker/houdini_html_e.c +66 -0
- data/ext/qiita_marker/houdini_html_u.c +149 -0
- data/ext/qiita_marker/html.c +486 -0
- data/ext/qiita_marker/html.h +27 -0
- data/ext/qiita_marker/inlines.c +1691 -0
- data/ext/qiita_marker/inlines.h +29 -0
- data/ext/qiita_marker/iterator.c +159 -0
- data/ext/qiita_marker/iterator.h +26 -0
- data/ext/qiita_marker/latex.c +466 -0
- data/ext/qiita_marker/linked_list.c +37 -0
- data/ext/qiita_marker/man.c +278 -0
- data/ext/qiita_marker/map.c +122 -0
- data/ext/qiita_marker/map.h +41 -0
- data/ext/qiita_marker/node.c +979 -0
- data/ext/qiita_marker/node.h +125 -0
- data/ext/qiita_marker/parser.h +58 -0
- data/ext/qiita_marker/plaintext.c +235 -0
- data/ext/qiita_marker/plugin.c +36 -0
- data/ext/qiita_marker/plugin.h +34 -0
- data/ext/qiita_marker/qiita_marker.c +1321 -0
- data/ext/qiita_marker/qiita_marker.h +16 -0
- data/ext/qiita_marker/references.c +42 -0
- data/ext/qiita_marker/references.h +26 -0
- data/ext/qiita_marker/registry.c +63 -0
- data/ext/qiita_marker/registry.h +24 -0
- data/ext/qiita_marker/render.c +205 -0
- data/ext/qiita_marker/render.h +62 -0
- data/ext/qiita_marker/scanners.c +10520 -0
- data/ext/qiita_marker/scanners.h +62 -0
- data/ext/qiita_marker/scanners.re +341 -0
- data/ext/qiita_marker/strikethrough.c +167 -0
- data/ext/qiita_marker/strikethrough.h +9 -0
- data/ext/qiita_marker/syntax_extension.c +149 -0
- data/ext/qiita_marker/syntax_extension.h +34 -0
- data/ext/qiita_marker/table.c +822 -0
- data/ext/qiita_marker/table.h +12 -0
- data/ext/qiita_marker/tagfilter.c +60 -0
- data/ext/qiita_marker/tagfilter.h +8 -0
- data/ext/qiita_marker/tasklist.c +156 -0
- data/ext/qiita_marker/tasklist.h +8 -0
- data/ext/qiita_marker/utf8.c +317 -0
- data/ext/qiita_marker/utf8.h +35 -0
- data/ext/qiita_marker/xml.c +181 -0
- data/lib/qiita_marker/config.rb +52 -0
- data/lib/qiita_marker/node/inspect.rb +57 -0
- data/lib/qiita_marker/node.rb +83 -0
- data/lib/qiita_marker/renderer/html_renderer.rb +252 -0
- data/lib/qiita_marker/renderer.rb +135 -0
- data/lib/qiita_marker/version.rb +5 -0
- data/lib/qiita_marker.rb +45 -0
- data/qiita_marker.gemspec +40 -0
- data/test/benchmark.rb +32 -0
- data/test/fixtures/curly.md +1 -0
- data/test/fixtures/dingus.md +10 -0
- data/test/fixtures/strong.md +1 -0
- data/test/fixtures/table.md +10 -0
- data/test/test_attributes.rb +24 -0
- data/test/test_basics.rb +35 -0
- data/test/test_commands.rb +72 -0
- data/test/test_commonmark.rb +36 -0
- data/test/test_doc.rb +130 -0
- data/test/test_encoding.rb +23 -0
- data/test/test_extensions.rb +116 -0
- data/test/test_footnotes.rb +60 -0
- data/test/test_gc.rb +47 -0
- data/test/test_helper.rb +71 -0
- data/test/test_linebreaks.rb +15 -0
- data/test/test_maliciousness.rb +262 -0
- data/test/test_node.rb +89 -0
- data/test/test_options.rb +37 -0
- data/test/test_pathological_inputs.rb +94 -0
- data/test/test_plaintext.rb +46 -0
- data/test/test_renderer.rb +47 -0
- data/test/test_smartpunct.rb +27 -0
- data/test/test_spec.rb +30 -0
- data/test/test_tasklists.rb +43 -0
- data/test/test_xml.rb +107 -0
- metadata +313 -0
@@ -0,0 +1,149 @@
|
|
1
|
+
#include <stdlib.h>
|
2
|
+
#include <assert.h>
|
3
|
+
|
4
|
+
#include "cmark-gfm.h"
|
5
|
+
#include "syntax_extension.h"
|
6
|
+
#include "buffer.h"
|
7
|
+
|
8
|
+
extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;
|
9
|
+
|
10
|
+
static cmark_mem *_mem = &CMARK_DEFAULT_MEM_ALLOCATOR;
|
11
|
+
|
12
|
+
void cmark_syntax_extension_free(cmark_mem *mem, cmark_syntax_extension *extension) {
|
13
|
+
if (extension->free_function && extension->priv) {
|
14
|
+
extension->free_function(mem, extension->priv);
|
15
|
+
}
|
16
|
+
|
17
|
+
cmark_llist_free(mem, extension->special_inline_chars);
|
18
|
+
mem->free(extension->name);
|
19
|
+
mem->free(extension);
|
20
|
+
}
|
21
|
+
|
22
|
+
cmark_syntax_extension *cmark_syntax_extension_new(const char *name) {
|
23
|
+
cmark_syntax_extension *res = (cmark_syntax_extension *) _mem->calloc(1, sizeof(cmark_syntax_extension));
|
24
|
+
res->name = (char *) _mem->calloc(1, sizeof(char) * (strlen(name)) + 1);
|
25
|
+
strcpy(res->name, name);
|
26
|
+
return res;
|
27
|
+
}
|
28
|
+
|
29
|
+
cmark_node_type cmark_syntax_extension_add_node(int is_inline) {
|
30
|
+
cmark_node_type *ref = !is_inline ? &CMARK_NODE_LAST_BLOCK : &CMARK_NODE_LAST_INLINE;
|
31
|
+
|
32
|
+
if ((*ref & CMARK_NODE_VALUE_MASK) == CMARK_NODE_VALUE_MASK) {
|
33
|
+
assert(false);
|
34
|
+
return (cmark_node_type) 0;
|
35
|
+
}
|
36
|
+
|
37
|
+
return *ref = (cmark_node_type) ((int) *ref + 1);
|
38
|
+
}
|
39
|
+
|
40
|
+
void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension,
|
41
|
+
int emphasis) {
|
42
|
+
extension->emphasis = emphasis == 1;
|
43
|
+
}
|
44
|
+
|
45
|
+
void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
|
46
|
+
cmark_open_block_func func) {
|
47
|
+
extension->try_opening_block = func;
|
48
|
+
}
|
49
|
+
|
50
|
+
void cmark_syntax_extension_set_match_block_func(cmark_syntax_extension *extension,
|
51
|
+
cmark_match_block_func func) {
|
52
|
+
extension->last_block_matches = func;
|
53
|
+
}
|
54
|
+
|
55
|
+
void cmark_syntax_extension_set_match_inline_func(cmark_syntax_extension *extension,
|
56
|
+
cmark_match_inline_func func) {
|
57
|
+
extension->match_inline = func;
|
58
|
+
}
|
59
|
+
|
60
|
+
void cmark_syntax_extension_set_inline_from_delim_func(cmark_syntax_extension *extension,
|
61
|
+
cmark_inline_from_delim_func func) {
|
62
|
+
extension->insert_inline_from_delim = func;
|
63
|
+
}
|
64
|
+
|
65
|
+
void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *extension,
|
66
|
+
cmark_llist *special_chars) {
|
67
|
+
extension->special_inline_chars = special_chars;
|
68
|
+
}
|
69
|
+
|
70
|
+
void cmark_syntax_extension_set_get_type_string_func(cmark_syntax_extension *extension,
|
71
|
+
cmark_get_type_string_func func) {
|
72
|
+
extension->get_type_string_func = func;
|
73
|
+
}
|
74
|
+
|
75
|
+
void cmark_syntax_extension_set_can_contain_func(cmark_syntax_extension *extension,
|
76
|
+
cmark_can_contain_func func) {
|
77
|
+
extension->can_contain_func = func;
|
78
|
+
}
|
79
|
+
|
80
|
+
void cmark_syntax_extension_set_contains_inlines_func(cmark_syntax_extension *extension,
|
81
|
+
cmark_contains_inlines_func func) {
|
82
|
+
extension->contains_inlines_func = func;
|
83
|
+
}
|
84
|
+
|
85
|
+
void cmark_syntax_extension_set_commonmark_render_func(cmark_syntax_extension *extension,
|
86
|
+
cmark_common_render_func func) {
|
87
|
+
extension->commonmark_render_func = func;
|
88
|
+
}
|
89
|
+
|
90
|
+
void cmark_syntax_extension_set_plaintext_render_func(cmark_syntax_extension *extension,
|
91
|
+
cmark_common_render_func func) {
|
92
|
+
extension->plaintext_render_func = func;
|
93
|
+
}
|
94
|
+
|
95
|
+
void cmark_syntax_extension_set_latex_render_func(cmark_syntax_extension *extension,
|
96
|
+
cmark_common_render_func func) {
|
97
|
+
extension->latex_render_func = func;
|
98
|
+
}
|
99
|
+
|
100
|
+
void cmark_syntax_extension_set_xml_attr_func(cmark_syntax_extension *extension,
|
101
|
+
cmark_xml_attr_func func) {
|
102
|
+
extension->xml_attr_func = func;
|
103
|
+
}
|
104
|
+
|
105
|
+
void cmark_syntax_extension_set_man_render_func(cmark_syntax_extension *extension,
|
106
|
+
cmark_common_render_func func) {
|
107
|
+
extension->man_render_func = func;
|
108
|
+
}
|
109
|
+
|
110
|
+
void cmark_syntax_extension_set_html_render_func(cmark_syntax_extension *extension,
|
111
|
+
cmark_html_render_func func) {
|
112
|
+
extension->html_render_func = func;
|
113
|
+
}
|
114
|
+
|
115
|
+
void cmark_syntax_extension_set_html_filter_func(cmark_syntax_extension *extension,
|
116
|
+
cmark_html_filter_func func) {
|
117
|
+
extension->html_filter_func = func;
|
118
|
+
}
|
119
|
+
|
120
|
+
void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extension,
|
121
|
+
cmark_postprocess_func func) {
|
122
|
+
extension->postprocess_func = func;
|
123
|
+
}
|
124
|
+
|
125
|
+
void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
|
126
|
+
void *priv,
|
127
|
+
cmark_free_func free_func) {
|
128
|
+
extension->priv = priv;
|
129
|
+
extension->free_function = free_func;
|
130
|
+
}
|
131
|
+
|
132
|
+
void *cmark_syntax_extension_get_private(cmark_syntax_extension *extension) {
|
133
|
+
return extension->priv;
|
134
|
+
}
|
135
|
+
|
136
|
+
void cmark_syntax_extension_set_opaque_alloc_func(cmark_syntax_extension *extension,
|
137
|
+
cmark_opaque_alloc_func func) {
|
138
|
+
extension->opaque_alloc_func = func;
|
139
|
+
}
|
140
|
+
|
141
|
+
void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
|
142
|
+
cmark_opaque_free_func func) {
|
143
|
+
extension->opaque_free_func = func;
|
144
|
+
}
|
145
|
+
|
146
|
+
void cmark_syntax_extension_set_commonmark_escape_func(cmark_syntax_extension *extension,
|
147
|
+
cmark_commonmark_escape_func func) {
|
148
|
+
extension->commonmark_escape_func = func;
|
149
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#ifndef CMARK_SYNTAX_EXTENSION_H
|
2
|
+
#define CMARK_SYNTAX_EXTENSION_H
|
3
|
+
|
4
|
+
#include "cmark-gfm.h"
|
5
|
+
#include "cmark-gfm-extension_api.h"
|
6
|
+
#include "config.h"
|
7
|
+
|
8
|
+
struct cmark_syntax_extension {
|
9
|
+
cmark_match_block_func last_block_matches;
|
10
|
+
cmark_open_block_func try_opening_block;
|
11
|
+
cmark_match_inline_func match_inline;
|
12
|
+
cmark_inline_from_delim_func insert_inline_from_delim;
|
13
|
+
cmark_llist * special_inline_chars;
|
14
|
+
char * name;
|
15
|
+
void * priv;
|
16
|
+
bool emphasis;
|
17
|
+
cmark_free_func free_function;
|
18
|
+
cmark_get_type_string_func get_type_string_func;
|
19
|
+
cmark_can_contain_func can_contain_func;
|
20
|
+
cmark_contains_inlines_func contains_inlines_func;
|
21
|
+
cmark_common_render_func commonmark_render_func;
|
22
|
+
cmark_common_render_func plaintext_render_func;
|
23
|
+
cmark_common_render_func latex_render_func;
|
24
|
+
cmark_xml_attr_func xml_attr_func;
|
25
|
+
cmark_common_render_func man_render_func;
|
26
|
+
cmark_html_render_func html_render_func;
|
27
|
+
cmark_html_filter_func html_filter_func;
|
28
|
+
cmark_postprocess_func postprocess_func;
|
29
|
+
cmark_opaque_alloc_func opaque_alloc_func;
|
30
|
+
cmark_opaque_free_func opaque_free_func;
|
31
|
+
cmark_commonmark_escape_func commonmark_escape_func;
|
32
|
+
};
|
33
|
+
|
34
|
+
#endif
|