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
@@ -8,12 +8,12 @@
|
|
8
8
|
extern "C" {
|
9
9
|
#endif
|
10
10
|
|
11
|
-
void
|
12
|
-
void
|
13
|
-
int
|
14
|
-
void
|
15
|
-
int
|
16
|
-
int
|
11
|
+
void cmark_utf8proc_case_fold(cmark_strbuf *dest, const uint8_t *str, bufsize_t len);
|
12
|
+
void cmark_utf8proc_encode_char(int32_t uc, cmark_strbuf *buf);
|
13
|
+
int cmark_utf8proc_iterate(const uint8_t *str, bufsize_t str_len, int32_t *dst);
|
14
|
+
void cmark_utf8proc_check(cmark_strbuf *dest, const uint8_t *line, bufsize_t size);
|
15
|
+
int cmark_utf8proc_is_space(int32_t uc);
|
16
|
+
int cmark_utf8proc_is_punctuation(int32_t uc);
|
17
17
|
|
18
18
|
#ifdef __cplusplus
|
19
19
|
}
|
@@ -11,157 +11,142 @@
|
|
11
11
|
|
12
12
|
// Functions to convert cmark_nodes to XML strings.
|
13
13
|
|
14
|
-
static void escape_xml(cmark_strbuf *dest, const unsigned char *source,
|
15
|
-
{
|
16
|
-
|
14
|
+
static void escape_xml(cmark_strbuf *dest, const unsigned char *source,
|
15
|
+
bufsize_t length) {
|
16
|
+
houdini_escape_html0(dest, source, length, 0);
|
17
17
|
}
|
18
18
|
|
19
19
|
struct render_state {
|
20
|
-
|
21
|
-
|
20
|
+
cmark_strbuf *xml;
|
21
|
+
int indent;
|
22
22
|
};
|
23
23
|
|
24
|
-
static inline void indent(struct render_state *state)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
24
|
+
static inline void indent(struct render_state *state) {
|
25
|
+
int i;
|
26
|
+
for (i = 0; i < state->indent; i++) {
|
27
|
+
cmark_strbuf_putc(state->xml, ' ');
|
28
|
+
}
|
30
29
|
}
|
31
30
|
|
32
|
-
static int
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
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
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
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
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
}
|
132
|
-
cmark_strbuf_puts(xml, ">\n");
|
133
|
-
|
134
|
-
|
135
|
-
} else if (node->first_child) {
|
136
|
-
state->indent -= 2;
|
137
|
-
indent(state);
|
138
|
-
cmark_strbuf_printf(xml, "</%s>\n",
|
139
|
-
cmark_node_get_type_string(node));
|
140
|
-
}
|
141
|
-
|
142
|
-
return 1;
|
31
|
+
static int S_render_node(cmark_node *node, cmark_event_type ev_type,
|
32
|
+
struct render_state *state, int options) {
|
33
|
+
cmark_strbuf *xml = state->xml;
|
34
|
+
bool literal = false;
|
35
|
+
cmark_delim_type delim;
|
36
|
+
bool entering = (ev_type == CMARK_EVENT_ENTER);
|
37
|
+
char buffer[100];
|
38
|
+
|
39
|
+
if (entering) {
|
40
|
+
indent(state);
|
41
|
+
cmark_strbuf_putc(xml, '<');
|
42
|
+
cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
|
43
|
+
|
44
|
+
if (options & CMARK_OPT_SOURCEPOS && node->start_line != 0) {
|
45
|
+
sprintf(buffer, " sourcepos=\"%d:%d-%d:%d\"", node->start_line,
|
46
|
+
node->start_column, node->end_line, node->end_column);
|
47
|
+
cmark_strbuf_puts(xml, buffer);
|
48
|
+
}
|
49
|
+
|
50
|
+
literal = false;
|
51
|
+
|
52
|
+
switch (node->type) {
|
53
|
+
case CMARK_NODE_TEXT:
|
54
|
+
case CMARK_NODE_CODE:
|
55
|
+
case CMARK_NODE_HTML:
|
56
|
+
case CMARK_NODE_INLINE_HTML:
|
57
|
+
cmark_strbuf_puts(xml, ">");
|
58
|
+
escape_xml(xml, node->as.literal.data, node->as.literal.len);
|
59
|
+
cmark_strbuf_puts(xml, "</");
|
60
|
+
cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
|
61
|
+
literal = true;
|
62
|
+
break;
|
63
|
+
case CMARK_NODE_LIST:
|
64
|
+
switch (cmark_node_get_list_type(node)) {
|
65
|
+
case CMARK_ORDERED_LIST:
|
66
|
+
cmark_strbuf_puts(xml, " type=\"ordered\"");
|
67
|
+
sprintf(buffer, " start=\"%d\"", cmark_node_get_list_start(node));
|
68
|
+
cmark_strbuf_puts(xml, buffer);
|
69
|
+
delim = cmark_node_get_list_delim(node);
|
70
|
+
if (delim == CMARK_PAREN_DELIM) {
|
71
|
+
cmark_strbuf_puts(xml, " delim=\"paren\"");
|
72
|
+
} else if (delim == CMARK_PERIOD_DELIM) {
|
73
|
+
cmark_strbuf_puts(xml, " delim=\"period\"");
|
74
|
+
}
|
75
|
+
break;
|
76
|
+
case CMARK_BULLET_LIST:
|
77
|
+
cmark_strbuf_puts(xml, " type=\"bullet\"");
|
78
|
+
break;
|
79
|
+
default:
|
80
|
+
break;
|
81
|
+
}
|
82
|
+
sprintf(buffer, " tight=\"%s\"",
|
83
|
+
(cmark_node_get_list_tight(node) ? "true" : "false"));
|
84
|
+
cmark_strbuf_puts(xml, buffer);
|
85
|
+
break;
|
86
|
+
case CMARK_NODE_HEADER:
|
87
|
+
sprintf(buffer, " level=\"%d\"", node->as.header.level);
|
88
|
+
cmark_strbuf_puts(xml, buffer);
|
89
|
+
break;
|
90
|
+
case CMARK_NODE_CODE_BLOCK:
|
91
|
+
if (node->as.code.info.len > 0) {
|
92
|
+
cmark_strbuf_puts(xml, " info=\"");
|
93
|
+
escape_xml(xml, node->as.code.info.data, node->as.code.info.len);
|
94
|
+
cmark_strbuf_putc(xml, '"');
|
95
|
+
}
|
96
|
+
cmark_strbuf_puts(xml, ">");
|
97
|
+
escape_xml(xml, node->as.code.literal.data, node->as.code.literal.len);
|
98
|
+
cmark_strbuf_puts(xml, "</");
|
99
|
+
cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
|
100
|
+
literal = true;
|
101
|
+
break;
|
102
|
+
case CMARK_NODE_LINK:
|
103
|
+
case CMARK_NODE_IMAGE:
|
104
|
+
cmark_strbuf_puts(xml, " destination=\"");
|
105
|
+
escape_xml(xml, node->as.link.url.data, node->as.link.url.len);
|
106
|
+
cmark_strbuf_putc(xml, '"');
|
107
|
+
cmark_strbuf_puts(xml, " title=\"");
|
108
|
+
escape_xml(xml, node->as.link.title.data, node->as.link.title.len);
|
109
|
+
cmark_strbuf_putc(xml, '"');
|
110
|
+
break;
|
111
|
+
default:
|
112
|
+
break;
|
113
|
+
}
|
114
|
+
if (node->first_child) {
|
115
|
+
state->indent += 2;
|
116
|
+
} else if (!literal) {
|
117
|
+
cmark_strbuf_puts(xml, " /");
|
118
|
+
}
|
119
|
+
cmark_strbuf_puts(xml, ">\n");
|
120
|
+
|
121
|
+
} else if (node->first_child) {
|
122
|
+
state->indent -= 2;
|
123
|
+
indent(state);
|
124
|
+
cmark_strbuf_puts(xml, "</");
|
125
|
+
cmark_strbuf_puts(xml, cmark_node_get_type_string(node));
|
126
|
+
cmark_strbuf_puts(xml, ">\n");
|
127
|
+
}
|
128
|
+
|
129
|
+
return 1;
|
143
130
|
}
|
144
131
|
|
145
|
-
char *cmark_render_xml(cmark_node *root, int options)
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
cmark_iter_free(iter);
|
166
|
-
return result;
|
132
|
+
char *cmark_render_xml(cmark_node *root, int options) {
|
133
|
+
char *result;
|
134
|
+
cmark_strbuf xml = GH_BUF_INIT;
|
135
|
+
cmark_event_type ev_type;
|
136
|
+
cmark_node *cur;
|
137
|
+
struct render_state state = {&xml, 0};
|
138
|
+
|
139
|
+
cmark_iter *iter = cmark_iter_new(root);
|
140
|
+
|
141
|
+
cmark_strbuf_puts(state.xml, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
142
|
+
cmark_strbuf_puts(state.xml,
|
143
|
+
"<!DOCTYPE CommonMark SYSTEM \"CommonMark.dtd\">\n");
|
144
|
+
while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
|
145
|
+
cur = cmark_iter_get_node(iter);
|
146
|
+
S_render_node(cur, ev_type, &state, options);
|
147
|
+
}
|
148
|
+
result = (char *)cmark_strbuf_detach(&xml);
|
149
|
+
|
150
|
+
cmark_iter_free(iter);
|
151
|
+
return result;
|
167
152
|
}
|
@@ -27,20 +27,20 @@ IF (PYTHONINTERP_FOUND)
|
|
27
27
|
|
28
28
|
add_test(spectest_library
|
29
29
|
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec"
|
30
|
-
"${
|
30
|
+
"${CMAKE_CURRENT_SOURCE_DIR}/spec.txt" "--library-dir" "${CMAKE_CURRENT_BINARY_DIR}/../src"
|
31
31
|
)
|
32
32
|
|
33
33
|
add_test(pathological_tests_library
|
34
34
|
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/pathological_tests.py"
|
35
|
-
"--library-dir" "${
|
35
|
+
"--library-dir" "${CMAKE_CURRENT_BINARY_DIR}/../src"
|
36
36
|
)
|
37
37
|
|
38
38
|
add_test(spectest_executable
|
39
|
-
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${
|
39
|
+
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/spec.txt" "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark"
|
40
40
|
)
|
41
41
|
|
42
42
|
add_test(smartpuncttest_executable
|
43
|
-
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${
|
43
|
+
${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/spec_tests.py" "--no-normalize" "--spec" "${CMAKE_CURRENT_SOURCE_DIR}/smart_punct.txt" "--program" "${CMAKE_CURRENT_BINARY_DIR}/../src/cmark --smart"
|
44
44
|
)
|
45
45
|
|
46
46
|
ELSE(PYTHONINTERP_FOUND)
|
@@ -58,6 +58,14 @@ by the single quote before `jolly`:
|
|
58
58
|
<p>’tis the season to be ‘jolly’</p>
|
59
59
|
.
|
60
60
|
|
61
|
+
Multiple apostrophes should not be marked as open/closing quotes.
|
62
|
+
|
63
|
+
.
|
64
|
+
'We'll use Jane's boat and John's truck,' Jenna said.
|
65
|
+
.
|
66
|
+
<p>‘We’ll use Jane’s boat and John’s truck,’ Jenna said.</p>
|
67
|
+
.
|
68
|
+
|
61
69
|
An unmatched double quote will be interpreted as a
|
62
70
|
left double quote, to facilitate this style:
|
63
71
|
|