commonmarker 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of commonmarker might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/ext/commonmarker/cmark/CMakeLists.txt +10 -4
- data/ext/commonmarker/cmark/Makefile +5 -5
- data/ext/commonmarker/cmark/api_test/CMakeLists.txt +1 -1
- data/ext/commonmarker/cmark/api_test/main.c +16 -0
- data/ext/commonmarker/cmark/build/CMakeCache.txt +3 -4
- data/ext/commonmarker/cmark/build/CMakeFiles/2.8.10.1/CMakeSystem.cmake +4 -4
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +12 -12
- data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +97 -142
- data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -1
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +1 -1
- data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +23 -23
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +2 -2
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -1
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
- data/ext/commonmarker/cmark/build/src/cmake_install.cmake +3 -3
- data/ext/commonmarker/cmark/build/src/cmark_version.h +2 -2
- data/ext/commonmarker/cmark/build/src/config.h +6 -6
- data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
- data/ext/commonmarker/cmark/build/src/libcmark.pc +1 -1
- data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +4 -4
- data/ext/commonmarker/cmark/changelog.txt +46 -0
- data/ext/commonmarker/cmark/man/man3/cmark.3 +21 -20
- data/ext/commonmarker/cmark/src/CMakeLists.txt +4 -6
- data/ext/commonmarker/cmark/src/bench.h +8 -8
- data/ext/commonmarker/cmark/src/blocks.c +917 -947
- data/ext/commonmarker/cmark/src/buffer.c +213 -288
- data/ext/commonmarker/cmark/src/buffer.h +19 -21
- data/ext/commonmarker/cmark/src/chunk.h +78 -82
- data/ext/commonmarker/cmark/src/cmark.c +9 -17
- data/ext/commonmarker/cmark/src/cmark.h +113 -157
- data/ext/commonmarker/cmark/src/cmark_ctype.c +24 -35
- data/ext/commonmarker/cmark/src/commonmark.c +390 -425
- data/ext/commonmarker/cmark/src/config.h.in +6 -6
- data/ext/commonmarker/cmark/src/houdini.h +21 -15
- data/ext/commonmarker/cmark/src/houdini_href_e.c +50 -57
- data/ext/commonmarker/cmark/src/houdini_html_e.c +36 -51
- data/ext/commonmarker/cmark/src/houdini_html_u.c +119 -124
- data/ext/commonmarker/cmark/src/html.c +289 -307
- data/ext/commonmarker/cmark/src/inlines.c +976 -1030
- data/ext/commonmarker/cmark/src/inlines.h +4 -2
- data/ext/commonmarker/cmark/src/iterator.c +96 -126
- data/ext/commonmarker/cmark/src/iterator.h +5 -5
- data/ext/commonmarker/cmark/src/latex.c +379 -401
- data/ext/commonmarker/cmark/src/main.c +168 -175
- data/ext/commonmarker/cmark/src/man.c +212 -226
- data/ext/commonmarker/cmark/src/node.c +746 -839
- data/ext/commonmarker/cmark/src/node.h +47 -48
- data/ext/commonmarker/cmark/src/parser.h +14 -14
- data/ext/commonmarker/cmark/src/references.c +101 -111
- data/ext/commonmarker/cmark/src/references.h +10 -8
- data/ext/commonmarker/cmark/src/render.c +144 -167
- data/ext/commonmarker/cmark/src/render.h +22 -41
- data/ext/commonmarker/cmark/src/scanners.c +27695 -20903
- data/ext/commonmarker/cmark/src/scanners.h +2 -1
- data/ext/commonmarker/cmark/src/scanners.re +1 -1
- data/ext/commonmarker/cmark/src/utf8.c +276 -419
- data/ext/commonmarker/cmark/src/utf8.h +6 -6
- data/ext/commonmarker/cmark/src/xml.c +129 -144
- data/ext/commonmarker/cmark/test/CMakeLists.txt +4 -4
- data/ext/commonmarker/cmark/test/smart_punct.txt +8 -0
- data/ext/commonmarker/cmark/test/spec.txt +109 -47
- data/lib/commonmarker/version.rb +1 -1
- metadata +2 -2
@@ -13,68 +13,67 @@ extern "C" {
|
|
13
13
|
#include "chunk.h"
|
14
14
|
|
15
15
|
typedef struct {
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
cmark_list_type list_type;
|
17
|
+
int marker_offset;
|
18
|
+
int padding;
|
19
|
+
int start;
|
20
|
+
cmark_delim_type delimiter;
|
21
|
+
unsigned char bullet_char;
|
22
|
+
bool tight;
|
23
23
|
} cmark_list;
|
24
24
|
|
25
25
|
typedef struct {
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
26
|
+
cmark_chunk info;
|
27
|
+
cmark_chunk literal;
|
28
|
+
int fence_length;
|
29
|
+
/* fence_offset must be 0-3, so we can use int8_t */
|
30
|
+
int8_t fence_offset;
|
31
|
+
unsigned char fence_char;
|
32
|
+
bool fenced;
|
33
33
|
} cmark_code;
|
34
34
|
|
35
35
|
typedef struct {
|
36
|
-
|
37
|
-
|
36
|
+
int level;
|
37
|
+
bool setext;
|
38
38
|
} cmark_header;
|
39
39
|
|
40
40
|
typedef struct {
|
41
|
-
|
42
|
-
|
41
|
+
cmark_chunk url;
|
42
|
+
cmark_chunk title;
|
43
43
|
} cmark_link;
|
44
44
|
|
45
45
|
struct cmark_node {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
46
|
+
struct cmark_node *next;
|
47
|
+
struct cmark_node *prev;
|
48
|
+
struct cmark_node *parent;
|
49
|
+
struct cmark_node *first_child;
|
50
|
+
struct cmark_node *last_child;
|
51
|
+
|
52
|
+
void *user_data;
|
53
|
+
|
54
|
+
int start_line;
|
55
|
+
int start_column;
|
56
|
+
int end_line;
|
57
|
+
int end_column;
|
58
|
+
|
59
|
+
cmark_node_type type;
|
60
|
+
|
61
|
+
bool open;
|
62
|
+
bool last_line_blank;
|
63
|
+
|
64
|
+
cmark_strbuf string_content;
|
65
|
+
|
66
|
+
union {
|
67
|
+
cmark_chunk literal;
|
68
|
+
cmark_list list;
|
69
|
+
cmark_code code;
|
70
|
+
cmark_header header;
|
71
|
+
cmark_link link;
|
72
|
+
int html_block_type;
|
73
|
+
} as;
|
74
74
|
};
|
75
75
|
|
76
|
-
CMARK_EXPORT int
|
77
|
-
cmark_node_check(cmark_node *node, FILE *out);
|
76
|
+
CMARK_EXPORT int cmark_node_check(cmark_node *node, FILE *out);
|
78
77
|
|
79
78
|
#ifdef __cplusplus
|
80
79
|
}
|
@@ -12,20 +12,20 @@ extern "C" {
|
|
12
12
|
#define MAX_LINK_LABEL_LENGTH 1000
|
13
13
|
|
14
14
|
struct cmark_parser {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
struct cmark_reference_map *refmap;
|
16
|
+
struct cmark_node *root;
|
17
|
+
struct cmark_node *current;
|
18
|
+
int line_number;
|
19
|
+
bufsize_t offset;
|
20
|
+
bufsize_t column;
|
21
|
+
bufsize_t first_nonspace;
|
22
|
+
bufsize_t first_nonspace_column;
|
23
|
+
int indent;
|
24
|
+
bool blank;
|
25
|
+
cmark_strbuf *curline;
|
26
|
+
bufsize_t last_line_length;
|
27
|
+
cmark_strbuf *linebuf;
|
28
|
+
int options;
|
29
29
|
};
|
30
30
|
|
31
31
|
#ifdef __cplusplus
|
@@ -5,150 +5,140 @@
|
|
5
5
|
#include "inlines.h"
|
6
6
|
#include "chunk.h"
|
7
7
|
|
8
|
-
static unsigned int
|
9
|
-
|
10
|
-
{
|
11
|
-
unsigned int hash = 0;
|
8
|
+
static unsigned int refhash(const unsigned char *link_ref) {
|
9
|
+
unsigned int hash = 0;
|
12
10
|
|
13
|
-
|
14
|
-
|
11
|
+
while (*link_ref)
|
12
|
+
hash = (*link_ref++) + (hash << 6) + (hash << 16) - hash;
|
15
13
|
|
16
|
-
|
14
|
+
return hash;
|
17
15
|
}
|
18
16
|
|
19
|
-
static void reference_free(cmark_reference *ref)
|
20
|
-
{
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
}
|
17
|
+
static void reference_free(cmark_reference *ref) {
|
18
|
+
if (ref != NULL) {
|
19
|
+
free(ref->label);
|
20
|
+
cmark_chunk_free(&ref->url);
|
21
|
+
cmark_chunk_free(&ref->title);
|
22
|
+
free(ref);
|
23
|
+
}
|
27
24
|
}
|
28
25
|
|
29
26
|
// normalize reference: collapse internal whitespace to single space,
|
30
27
|
// remove leading/trailing whitespace, case fold
|
31
28
|
// Return NULL if the reference name is actually empty (i.e. composed
|
32
29
|
// solely from whitespace)
|
33
|
-
static unsigned char *normalize_reference(cmark_chunk *ref)
|
34
|
-
|
35
|
-
|
36
|
-
unsigned char *result;
|
30
|
+
static unsigned char *normalize_reference(cmark_chunk *ref) {
|
31
|
+
cmark_strbuf normalized = GH_BUF_INIT;
|
32
|
+
unsigned char *result;
|
37
33
|
|
38
|
-
|
39
|
-
|
34
|
+
if (ref == NULL)
|
35
|
+
return NULL;
|
40
36
|
|
41
|
-
|
42
|
-
|
37
|
+
if (ref->len == 0)
|
38
|
+
return NULL;
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
cmark_utf8proc_case_fold(&normalized, ref->data, ref->len);
|
41
|
+
cmark_strbuf_trim(&normalized);
|
42
|
+
cmark_strbuf_normalize_whitespace(&normalized);
|
47
43
|
|
48
|
-
|
49
|
-
|
44
|
+
result = cmark_strbuf_detach(&normalized);
|
45
|
+
assert(result);
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
if (result[0] == '\0') {
|
48
|
+
free(result);
|
49
|
+
return NULL;
|
50
|
+
}
|
55
51
|
|
56
|
-
|
52
|
+
return result;
|
57
53
|
}
|
58
54
|
|
59
|
-
static void add_reference(cmark_reference_map *map, cmark_reference*
|
60
|
-
|
61
|
-
cmark_reference *t = ref->next = map->table[ref->hash % REFMAP_SIZE];
|
55
|
+
static void add_reference(cmark_reference_map *map, cmark_reference *ref) {
|
56
|
+
cmark_reference *t = ref->next = map->table[ref->hash % REFMAP_SIZE];
|
62
57
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
}
|
58
|
+
while (t) {
|
59
|
+
if (t->hash == ref->hash && !strcmp((char *)t->label, (char *)ref->label)) {
|
60
|
+
reference_free(ref);
|
61
|
+
return;
|
62
|
+
}
|
69
63
|
|
70
|
-
|
71
|
-
|
64
|
+
t = t->next;
|
65
|
+
}
|
72
66
|
|
73
|
-
|
67
|
+
map->table[ref->hash % REFMAP_SIZE] = ref;
|
74
68
|
}
|
75
69
|
|
76
|
-
void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
|
77
|
-
cmark_chunk *title)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
}
|
70
|
+
void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
|
71
|
+
cmark_chunk *url, cmark_chunk *title) {
|
72
|
+
cmark_reference *ref;
|
73
|
+
unsigned char *reflabel = normalize_reference(label);
|
74
|
+
|
75
|
+
/* empty reference name, or composed from only whitespace */
|
76
|
+
if (reflabel == NULL)
|
77
|
+
return;
|
78
|
+
|
79
|
+
ref = (cmark_reference *)calloc(1, sizeof(*ref));
|
80
|
+
if (ref != NULL) {
|
81
|
+
ref->label = reflabel;
|
82
|
+
ref->hash = refhash(ref->label);
|
83
|
+
ref->url = cmark_clean_url(url);
|
84
|
+
ref->title = cmark_clean_title(title);
|
85
|
+
ref->next = NULL;
|
86
|
+
|
87
|
+
add_reference(map, ref);
|
88
|
+
}
|
96
89
|
}
|
97
90
|
|
98
91
|
// Returns reference if refmap contains a reference with matching
|
99
92
|
// label, otherwise NULL.
|
100
|
-
cmark_reference*
|
101
|
-
{
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
return ref;
|
93
|
+
cmark_reference *cmark_reference_lookup(cmark_reference_map *map,
|
94
|
+
cmark_chunk *label) {
|
95
|
+
cmark_reference *ref = NULL;
|
96
|
+
unsigned char *norm;
|
97
|
+
unsigned int hash;
|
98
|
+
|
99
|
+
if (label->len > MAX_LINK_LABEL_LENGTH)
|
100
|
+
return NULL;
|
101
|
+
|
102
|
+
if (map == NULL)
|
103
|
+
return NULL;
|
104
|
+
|
105
|
+
norm = normalize_reference(label);
|
106
|
+
if (norm == NULL)
|
107
|
+
return NULL;
|
108
|
+
|
109
|
+
hash = refhash(norm);
|
110
|
+
ref = map->table[hash % REFMAP_SIZE];
|
111
|
+
|
112
|
+
while (ref) {
|
113
|
+
if (ref->hash == hash && !strcmp((char *)ref->label, (char *)norm))
|
114
|
+
break;
|
115
|
+
ref = ref->next;
|
116
|
+
}
|
117
|
+
|
118
|
+
free(norm);
|
119
|
+
return ref;
|
128
120
|
}
|
129
121
|
|
130
|
-
void cmark_reference_map_free(cmark_reference_map *map)
|
131
|
-
|
132
|
-
unsigned int i;
|
122
|
+
void cmark_reference_map_free(cmark_reference_map *map) {
|
123
|
+
unsigned int i;
|
133
124
|
|
134
|
-
|
135
|
-
|
125
|
+
if (map == NULL)
|
126
|
+
return;
|
136
127
|
|
137
|
-
|
138
|
-
|
139
|
-
|
128
|
+
for (i = 0; i < REFMAP_SIZE; ++i) {
|
129
|
+
cmark_reference *ref = map->table[i];
|
130
|
+
cmark_reference *next;
|
140
131
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
132
|
+
while (ref) {
|
133
|
+
next = ref->next;
|
134
|
+
reference_free(ref);
|
135
|
+
ref = next;
|
136
|
+
}
|
137
|
+
}
|
147
138
|
|
148
|
-
|
139
|
+
free(map);
|
149
140
|
}
|
150
141
|
|
151
|
-
cmark_reference_map *cmark_reference_map_new(void)
|
152
|
-
|
153
|
-
return (cmark_reference_map *)calloc(1, sizeof(cmark_reference_map));
|
142
|
+
cmark_reference_map *cmark_reference_map_new(void) {
|
143
|
+
return (cmark_reference_map *)calloc(1, sizeof(cmark_reference_map));
|
154
144
|
}
|
@@ -10,25 +10,27 @@ extern "C" {
|
|
10
10
|
#define REFMAP_SIZE 16
|
11
11
|
|
12
12
|
struct cmark_reference {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
struct cmark_reference *next;
|
14
|
+
unsigned char *label;
|
15
|
+
cmark_chunk url;
|
16
|
+
cmark_chunk title;
|
17
|
+
unsigned int hash;
|
18
18
|
};
|
19
19
|
|
20
20
|
typedef struct cmark_reference cmark_reference;
|
21
21
|
|
22
22
|
struct cmark_reference_map {
|
23
|
-
|
23
|
+
cmark_reference *table[REFMAP_SIZE];
|
24
24
|
};
|
25
25
|
|
26
26
|
typedef struct cmark_reference_map cmark_reference_map;
|
27
27
|
|
28
28
|
cmark_reference_map *cmark_reference_map_new(void);
|
29
29
|
void cmark_reference_map_free(cmark_reference_map *map);
|
30
|
-
cmark_reference*
|
31
|
-
|
30
|
+
cmark_reference *cmark_reference_lookup(cmark_reference_map *map,
|
31
|
+
cmark_chunk *label);
|
32
|
+
extern void cmark_reference_create(cmark_reference_map *map, cmark_chunk *label,
|
33
|
+
cmark_chunk *url, cmark_chunk *title);
|
32
34
|
|
33
35
|
#ifdef __cplusplus
|
34
36
|
}
|