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
@@ -7,115 +7,111 @@
|
|
7
7
|
#include "cmark_ctype.h"
|
8
8
|
#include "buffer.h"
|
9
9
|
|
10
|
-
#define CMARK_CHUNK_EMPTY
|
10
|
+
#define CMARK_CHUNK_EMPTY \
|
11
|
+
{ NULL, 0, 0 }
|
11
12
|
|
12
13
|
typedef struct {
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
unsigned char *data;
|
15
|
+
bufsize_t len;
|
16
|
+
bufsize_t alloc; // also implies a NULL-terminated string
|
16
17
|
} cmark_chunk;
|
17
18
|
|
18
|
-
static
|
19
|
-
|
20
|
-
|
21
|
-
free(c->data);
|
19
|
+
static CMARK_INLINE void cmark_chunk_free(cmark_chunk *c) {
|
20
|
+
if (c->alloc)
|
21
|
+
free(c->data);
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
c->data = NULL;
|
24
|
+
c->alloc = 0;
|
25
|
+
c->len = 0;
|
26
26
|
}
|
27
27
|
|
28
|
-
static
|
29
|
-
|
30
|
-
assert(!c->alloc);
|
28
|
+
static CMARK_INLINE void cmark_chunk_ltrim(cmark_chunk *c) {
|
29
|
+
assert(!c->alloc);
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
while (c->len && cmark_isspace(c->data[0])) {
|
32
|
+
c->data++;
|
33
|
+
c->len--;
|
34
|
+
}
|
36
35
|
}
|
37
36
|
|
38
|
-
static
|
39
|
-
{
|
40
|
-
|
41
|
-
|
42
|
-
break;
|
37
|
+
static CMARK_INLINE void cmark_chunk_rtrim(cmark_chunk *c) {
|
38
|
+
while (c->len > 0) {
|
39
|
+
if (!cmark_isspace(c->data[c->len - 1]))
|
40
|
+
break;
|
43
41
|
|
44
|
-
|
45
|
-
|
42
|
+
c->len--;
|
43
|
+
}
|
46
44
|
}
|
47
45
|
|
48
|
-
static
|
49
|
-
|
50
|
-
|
51
|
-
cmark_chunk_rtrim(c);
|
46
|
+
static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
|
47
|
+
cmark_chunk_ltrim(c);
|
48
|
+
cmark_chunk_rtrim(c);
|
52
49
|
}
|
53
50
|
|
54
|
-
static
|
55
|
-
{
|
56
|
-
|
57
|
-
|
51
|
+
static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
|
52
|
+
bufsize_t offset) {
|
53
|
+
const unsigned char *p =
|
54
|
+
(unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
|
55
|
+
return p ? (bufsize_t)(p - ch->data) : ch->len;
|
58
56
|
}
|
59
57
|
|
60
|
-
static
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
return (char *)str;
|
58
|
+
static CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_chunk *c) {
|
59
|
+
unsigned char *str;
|
60
|
+
|
61
|
+
if (c->alloc) {
|
62
|
+
return (char *)c->data;
|
63
|
+
}
|
64
|
+
str = (unsigned char *)malloc(c->len + 1);
|
65
|
+
if (str != NULL) {
|
66
|
+
if (c->len > 0) {
|
67
|
+
memcpy(str, c->data, c->len);
|
68
|
+
}
|
69
|
+
str[c->len] = 0;
|
70
|
+
}
|
71
|
+
c->data = str;
|
72
|
+
c->alloc = 1;
|
73
|
+
|
74
|
+
return (char *)str;
|
78
75
|
}
|
79
76
|
|
80
|
-
static
|
81
|
-
{
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
77
|
+
static CMARK_INLINE void
|
78
|
+
cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
|
79
|
+
if (c->alloc) {
|
80
|
+
free(c->data);
|
81
|
+
}
|
82
|
+
if (str == NULL) {
|
83
|
+
c->len = 0;
|
84
|
+
c->data = NULL;
|
85
|
+
c->alloc = 0;
|
86
|
+
} else {
|
87
|
+
c->len = cmark_strbuf_safe_strlen(str);
|
88
|
+
c->data = (unsigned char *)malloc(c->len + 1);
|
89
|
+
c->alloc = 1;
|
90
|
+
memcpy(c->data, str, c->len + 1);
|
91
|
+
}
|
95
92
|
}
|
96
93
|
|
97
|
-
static
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
return c;
|
94
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
|
95
|
+
bufsize_t len = data ? cmark_strbuf_safe_strlen(data) : 0;
|
96
|
+
cmark_chunk c = {(unsigned char *)data, len, 0};
|
97
|
+
return c;
|
102
98
|
}
|
103
99
|
|
104
|
-
static
|
105
|
-
|
106
|
-
|
107
|
-
|
100
|
+
static CMARK_INLINE
|
101
|
+
cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos,
|
102
|
+
bufsize_t len) {
|
103
|
+
cmark_chunk c = {ch->data + pos, len, 0};
|
104
|
+
return c;
|
108
105
|
}
|
109
106
|
|
110
|
-
static
|
111
|
-
|
112
|
-
cmark_chunk c;
|
107
|
+
static CMARK_INLINE cmark_chunk cmark_chunk_buf_detach(cmark_strbuf *buf) {
|
108
|
+
cmark_chunk c;
|
113
109
|
|
114
|
-
|
115
|
-
|
116
|
-
|
110
|
+
c.len = buf->size;
|
111
|
+
c.data = cmark_strbuf_detach(buf);
|
112
|
+
c.alloc = 1;
|
117
113
|
|
118
|
-
|
114
|
+
return c;
|
119
115
|
}
|
120
116
|
|
121
117
|
#endif
|
@@ -6,26 +6,18 @@
|
|
6
6
|
#include "cmark.h"
|
7
7
|
#include "buffer.h"
|
8
8
|
|
9
|
-
int cmark_version()
|
10
|
-
{
|
11
|
-
return CMARK_VERSION;
|
12
|
-
}
|
9
|
+
int cmark_version() { return CMARK_VERSION; }
|
13
10
|
|
14
|
-
const char *cmark_version_string()
|
15
|
-
{
|
16
|
-
return CMARK_VERSION_STRING;
|
17
|
-
}
|
11
|
+
const char *cmark_version_string() { return CMARK_VERSION_STRING; }
|
18
12
|
|
19
|
-
char *cmark_markdown_to_html(const char *text, size_t len, int options)
|
20
|
-
|
21
|
-
|
22
|
-
char *result;
|
13
|
+
char *cmark_markdown_to_html(const char *text, size_t len, int options) {
|
14
|
+
cmark_node *doc;
|
15
|
+
char *result;
|
23
16
|
|
24
|
-
|
17
|
+
doc = cmark_parse_document(text, len, options);
|
25
18
|
|
26
|
-
|
27
|
-
|
19
|
+
result = cmark_render_html(doc, options);
|
20
|
+
cmark_node_free(doc);
|
28
21
|
|
29
|
-
|
22
|
+
return result;
|
30
23
|
}
|
31
|
-
|