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,135 @@
|
|
1
|
+
#ifndef CMARK_CHUNK_H
|
2
|
+
#define CMARK_CHUNK_H
|
3
|
+
|
4
|
+
#include <string.h>
|
5
|
+
#include <stdlib.h>
|
6
|
+
#include <assert.h>
|
7
|
+
#include "cmark-gfm.h"
|
8
|
+
#include "buffer.h"
|
9
|
+
#include "cmark_ctype.h"
|
10
|
+
|
11
|
+
#define CMARK_CHUNK_EMPTY \
|
12
|
+
{ NULL, 0, 0 }
|
13
|
+
|
14
|
+
typedef struct cmark_chunk {
|
15
|
+
unsigned char *data;
|
16
|
+
bufsize_t len;
|
17
|
+
bufsize_t alloc; // also implies a NULL-terminated string
|
18
|
+
} cmark_chunk;
|
19
|
+
|
20
|
+
static CMARK_INLINE void cmark_chunk_free(cmark_mem *mem, cmark_chunk *c) {
|
21
|
+
if (c->alloc)
|
22
|
+
mem->free(c->data);
|
23
|
+
|
24
|
+
c->data = NULL;
|
25
|
+
c->alloc = 0;
|
26
|
+
c->len = 0;
|
27
|
+
}
|
28
|
+
|
29
|
+
static CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
|
30
|
+
assert(!c->alloc);
|
31
|
+
|
32
|
+
while (c->len && cmark_isspace(c->data[0])) {
|
33
|
+
c->data++;
|
34
|
+
c->len--;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
static CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
|
39
|
+
assert(!c->alloc);
|
40
|
+
|
41
|
+
while (c->len > 0) {
|
42
|
+
if (!cmark_isspace(c->data[c->len - 1]))
|
43
|
+
break;
|
44
|
+
|
45
|
+
c->len--;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
|
50
|
+
cmark_chunk_ltrim(c);
|
51
|
+
cmark_chunk_rtrim(c);
|
52
|
+
}
|
53
|
+
|
54
|
+
static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
|
55
|
+
bufsize_t offset) {
|
56
|
+
const unsigned char *p =
|
57
|
+
(unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
|
58
|
+
return p ? (bufsize_t)(p - ch->data) : ch->len;
|
59
|
+
}
|
60
|
+
|
61
|
+
static CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_mem *mem,
|
62
|
+
cmark_chunk *c) {
|
63
|
+
unsigned char *str;
|
64
|
+
|
65
|
+
if (c->alloc) {
|
66
|
+
return (char *)c->data;
|
67
|
+
}
|
68
|
+
str = (unsigned char *)mem->calloc(c->len + 1, 1);
|
69
|
+
if (c->len > 0) {
|
70
|
+
memcpy(str, c->data, c->len);
|
71
|
+
}
|
72
|
+
str[c->len] = 0;
|
73
|
+
c->data = str;
|
74
|
+
c->alloc = 1;
|
75
|
+
|
76
|
+
return (char *)str;
|
77
|
+
}
|
78
|
+
|
79
|
+
static CMARK_INLINE void cmark_chunk_set_cstr(cmark_mem *mem, cmark_chunk *c,
|
80
|
+
const char *str) {
|
81
|
+
unsigned char *old = c->alloc ? c->data : NULL;
|
82
|
+
if (str == NULL) {
|
83
|
+
c->len = 0;
|
84
|
+
c->data = NULL;
|
85
|
+
c->alloc = 0;
|
86
|
+
} else {
|
87
|
+
c->len = (bufsize_t)strlen(str);
|
88
|
+
c->data = (unsigned char *)mem->calloc(c->len + 1, 1);
|
89
|
+
c->alloc = 1;
|
90
|
+
memcpy(c->data, str, c->len + 1);
|
91
|
+
}
|
92
|
+
if (old != NULL) {
|
93
|
+
mem->free(old);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
|
98
|
+
bufsize_t len = data ? (bufsize_t)strlen(data) : 0;
|
99
|
+
cmark_chunk c = {(unsigned char *)data, len, 0};
|
100
|
+
return c;
|
101
|
+
}
|
102
|
+
|
103
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_dup(const cmark_chunk *ch,
|
104
|
+
bufsize_t pos, bufsize_t len) {
|
105
|
+
cmark_chunk c = {ch->data + pos, len, 0};
|
106
|
+
return c;
|
107
|
+
}
|
108
|
+
|
109
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
|
110
|
+
cmark_chunk c;
|
111
|
+
|
112
|
+
c.len = buf->size;
|
113
|
+
c.data = cmark_strbuf_detach(buf);
|
114
|
+
c.alloc = 1;
|
115
|
+
|
116
|
+
return c;
|
117
|
+
}
|
118
|
+
|
119
|
+
/* trim_new variants are to be used when the source chunk may or may not be
|
120
|
+
* allocated; forces a newly allocated chunk. */
|
121
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_ltrim_new(cmark_mem *mem, cmark_chunk *c) {
|
122
|
+
cmark_chunk r = cmark_chunk_dup(c, 0, c->len);
|
123
|
+
cmark_chunk_ltrim(&r);
|
124
|
+
cmark_chunk_to_cstr(mem, &r);
|
125
|
+
return r;
|
126
|
+
}
|
127
|
+
|
128
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_rtrim_new(cmark_mem *mem, cmark_chunk *c) {
|
129
|
+
cmark_chunk r = cmark_chunk_dup(c, 0, c->len);
|
130
|
+
cmark_chunk_rtrim(&r);
|
131
|
+
cmark_chunk_to_cstr(mem, &r);
|
132
|
+
return r;
|
133
|
+
}
|
134
|
+
|
135
|
+
#endif
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#ifndef CMARK_GFM_CORE_EXTENSIONS_H
|
2
|
+
#define CMARK_GFM_CORE_EXTENSIONS_H
|
3
|
+
|
4
|
+
#ifdef __cplusplus
|
5
|
+
extern "C" {
|
6
|
+
#endif
|
7
|
+
|
8
|
+
#include "cmark-gfm-extension_api.h"
|
9
|
+
#include "cmark-gfm-extensions_export.h"
|
10
|
+
#include "config.h" // for bool
|
11
|
+
#include <stdint.h>
|
12
|
+
|
13
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
14
|
+
void cmark_gfm_core_extensions_ensure_registered(void);
|
15
|
+
|
16
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
17
|
+
uint16_t cmark_gfm_extensions_get_table_columns(cmark_node *node);
|
18
|
+
|
19
|
+
/** Sets the number of columns for the table, returning 1 on success and 0 on error.
|
20
|
+
*/
|
21
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
22
|
+
int cmark_gfm_extensions_set_table_columns(cmark_node *node, uint16_t n_columns);
|
23
|
+
|
24
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
25
|
+
uint8_t *cmark_gfm_extensions_get_table_alignments(cmark_node *node);
|
26
|
+
|
27
|
+
/** Sets the alignments for the table, returning 1 on success and 0 on error.
|
28
|
+
*/
|
29
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
30
|
+
int cmark_gfm_extensions_set_table_alignments(cmark_node *node, uint16_t ncols, uint8_t *alignments);
|
31
|
+
|
32
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
33
|
+
int cmark_gfm_extensions_get_table_row_is_header(cmark_node *node);
|
34
|
+
|
35
|
+
/** Sets whether the node is a table header row, returning 1 on success and 0 on error.
|
36
|
+
*/
|
37
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
38
|
+
int cmark_gfm_extensions_set_table_row_is_header(cmark_node *node, int is_header);
|
39
|
+
|
40
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
41
|
+
bool cmark_gfm_extensions_get_tasklist_item_checked(cmark_node *node);
|
42
|
+
/* For backwards compatibility */
|
43
|
+
#define cmark_gfm_extensions_tasklist_is_checked cmark_gfm_extensions_get_tasklist_item_checked
|
44
|
+
|
45
|
+
/** Sets whether a tasklist item is "checked" (completed), returning 1 on success and 0 on error.
|
46
|
+
*/
|
47
|
+
CMARK_GFM_EXTENSIONS_EXPORT
|
48
|
+
int cmark_gfm_extensions_set_tasklist_item_checked(cmark_node *node, bool is_checked);
|
49
|
+
|
50
|
+
#ifdef __cplusplus
|
51
|
+
}
|
52
|
+
#endif
|
53
|
+
|
54
|
+
#endif
|