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
@@ -16,234 +16,220 @@
|
|
16
16
|
#define BLANKLINE() renderer->blankline(renderer)
|
17
17
|
|
18
18
|
// Functions to convert cmark_nodes to groff man strings.
|
19
|
-
static
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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
|
-
break;
|
71
|
-
default:
|
72
|
-
cmark_render_code_point(renderer, c);
|
73
|
-
}
|
19
|
+
static void S_outc(cmark_renderer *renderer, cmark_escaping escape, int32_t c,
|
20
|
+
unsigned char nextc) {
|
21
|
+
(void)(nextc);
|
22
|
+
|
23
|
+
if (escape == LITERAL) {
|
24
|
+
cmark_render_code_point(renderer, c);
|
25
|
+
return;
|
26
|
+
}
|
27
|
+
|
28
|
+
switch (c) {
|
29
|
+
case 46:
|
30
|
+
if (renderer->begin_line) {
|
31
|
+
cmark_render_ascii(renderer, "\\&.");
|
32
|
+
} else {
|
33
|
+
cmark_render_code_point(renderer, c);
|
34
|
+
}
|
35
|
+
break;
|
36
|
+
case 39:
|
37
|
+
if (renderer->begin_line) {
|
38
|
+
cmark_render_ascii(renderer, "\\&'");
|
39
|
+
} else {
|
40
|
+
cmark_render_code_point(renderer, c);
|
41
|
+
}
|
42
|
+
break;
|
43
|
+
case 45:
|
44
|
+
cmark_render_ascii(renderer, "\\-");
|
45
|
+
break;
|
46
|
+
case 92:
|
47
|
+
cmark_render_ascii(renderer, "\\e");
|
48
|
+
break;
|
49
|
+
case 8216: // left single quote
|
50
|
+
cmark_render_ascii(renderer, "\\[oq]");
|
51
|
+
break;
|
52
|
+
case 8217: // right single quote
|
53
|
+
cmark_render_ascii(renderer, "\\[cq]");
|
54
|
+
break;
|
55
|
+
case 8220: // left double quote
|
56
|
+
cmark_render_ascii(renderer, "\\[lq]");
|
57
|
+
break;
|
58
|
+
case 8221: // right double quote
|
59
|
+
cmark_render_ascii(renderer, "\\[rq]");
|
60
|
+
break;
|
61
|
+
case 8212: // em dash
|
62
|
+
cmark_render_ascii(renderer, "\\[em]");
|
63
|
+
break;
|
64
|
+
case 8211: // en dash
|
65
|
+
cmark_render_ascii(renderer, "\\[en]");
|
66
|
+
break;
|
67
|
+
default:
|
68
|
+
cmark_render_code_point(renderer, c);
|
69
|
+
}
|
74
70
|
}
|
75
71
|
|
76
|
-
static int
|
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
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
}
|
236
|
-
break;
|
237
|
-
|
238
|
-
default:
|
239
|
-
assert(false);
|
240
|
-
break;
|
241
|
-
}
|
242
|
-
|
243
|
-
return 1;
|
72
|
+
static int S_render_node(cmark_renderer *renderer, cmark_node *node,
|
73
|
+
cmark_event_type ev_type, int options) {
|
74
|
+
cmark_node *tmp;
|
75
|
+
int list_number;
|
76
|
+
bool entering = (ev_type == CMARK_EVENT_ENTER);
|
77
|
+
|
78
|
+
// avoid unused parameter error:
|
79
|
+
(void)(options);
|
80
|
+
|
81
|
+
switch (node->type) {
|
82
|
+
case CMARK_NODE_DOCUMENT:
|
83
|
+
break;
|
84
|
+
|
85
|
+
case CMARK_NODE_BLOCK_QUOTE:
|
86
|
+
if (entering) {
|
87
|
+
CR();
|
88
|
+
LIT(".RS");
|
89
|
+
CR();
|
90
|
+
} else {
|
91
|
+
CR();
|
92
|
+
LIT(".RE");
|
93
|
+
CR();
|
94
|
+
}
|
95
|
+
break;
|
96
|
+
|
97
|
+
case CMARK_NODE_LIST:
|
98
|
+
break;
|
99
|
+
|
100
|
+
case CMARK_NODE_ITEM:
|
101
|
+
if (entering) {
|
102
|
+
CR();
|
103
|
+
LIT(".IP ");
|
104
|
+
if (cmark_node_get_list_type(node->parent) == CMARK_BULLET_LIST) {
|
105
|
+
LIT("\\[bu] 2");
|
106
|
+
} else {
|
107
|
+
list_number = cmark_node_get_list_start(node->parent);
|
108
|
+
tmp = node;
|
109
|
+
while (tmp->prev) {
|
110
|
+
tmp = tmp->prev;
|
111
|
+
list_number += 1;
|
112
|
+
}
|
113
|
+
char list_number_s[20];
|
114
|
+
sprintf(list_number_s, "\"%d.\" 4", list_number);
|
115
|
+
LIT(list_number_s);
|
116
|
+
}
|
117
|
+
CR();
|
118
|
+
} else {
|
119
|
+
CR();
|
120
|
+
}
|
121
|
+
break;
|
122
|
+
|
123
|
+
case CMARK_NODE_HEADER:
|
124
|
+
if (entering) {
|
125
|
+
CR();
|
126
|
+
LIT(cmark_node_get_header_level(node) == 1 ? ".SH" : ".SS");
|
127
|
+
CR();
|
128
|
+
} else {
|
129
|
+
CR();
|
130
|
+
}
|
131
|
+
break;
|
132
|
+
|
133
|
+
case CMARK_NODE_CODE_BLOCK:
|
134
|
+
CR();
|
135
|
+
LIT(".IP\n.nf\n\\f[C]\n");
|
136
|
+
OUT(cmark_node_get_literal(node), false, NORMAL);
|
137
|
+
CR();
|
138
|
+
LIT("\\f[]\n.fi");
|
139
|
+
CR();
|
140
|
+
break;
|
141
|
+
|
142
|
+
case CMARK_NODE_HTML:
|
143
|
+
break;
|
144
|
+
|
145
|
+
case CMARK_NODE_HRULE:
|
146
|
+
CR();
|
147
|
+
LIT(".PP\n * * * * *");
|
148
|
+
CR();
|
149
|
+
break;
|
150
|
+
|
151
|
+
case CMARK_NODE_PARAGRAPH:
|
152
|
+
if (entering) {
|
153
|
+
// no blank line if first paragraph in list:
|
154
|
+
if (node->parent && node->parent->type == CMARK_NODE_ITEM &&
|
155
|
+
node->prev == NULL) {
|
156
|
+
// no blank line or .PP
|
157
|
+
} else {
|
158
|
+
CR();
|
159
|
+
LIT(".PP");
|
160
|
+
CR();
|
161
|
+
}
|
162
|
+
} else {
|
163
|
+
CR();
|
164
|
+
}
|
165
|
+
break;
|
166
|
+
|
167
|
+
case CMARK_NODE_TEXT:
|
168
|
+
OUT(cmark_node_get_literal(node), true, NORMAL);
|
169
|
+
break;
|
170
|
+
|
171
|
+
case CMARK_NODE_LINEBREAK:
|
172
|
+
LIT(".PD 0\n.P\n.PD");
|
173
|
+
CR();
|
174
|
+
break;
|
175
|
+
|
176
|
+
case CMARK_NODE_SOFTBREAK:
|
177
|
+
if (renderer->width == 0) {
|
178
|
+
CR();
|
179
|
+
} else {
|
180
|
+
OUT(" ", true, LITERAL);
|
181
|
+
}
|
182
|
+
break;
|
183
|
+
|
184
|
+
case CMARK_NODE_CODE:
|
185
|
+
LIT("\\f[C]");
|
186
|
+
OUT(cmark_node_get_literal(node), true, NORMAL);
|
187
|
+
LIT("\\f[]");
|
188
|
+
break;
|
189
|
+
|
190
|
+
case CMARK_NODE_INLINE_HTML:
|
191
|
+
break;
|
192
|
+
|
193
|
+
case CMARK_NODE_STRONG:
|
194
|
+
if (entering) {
|
195
|
+
LIT("\\f[B]");
|
196
|
+
} else {
|
197
|
+
LIT("\\f[]");
|
198
|
+
}
|
199
|
+
break;
|
200
|
+
|
201
|
+
case CMARK_NODE_EMPH:
|
202
|
+
if (entering) {
|
203
|
+
LIT("\\f[I]");
|
204
|
+
} else {
|
205
|
+
LIT("\\f[]");
|
206
|
+
}
|
207
|
+
break;
|
208
|
+
|
209
|
+
case CMARK_NODE_LINK:
|
210
|
+
if (!entering) {
|
211
|
+
LIT(" (");
|
212
|
+
OUT(cmark_node_get_url(node), true, URL);
|
213
|
+
LIT(")");
|
214
|
+
}
|
215
|
+
break;
|
216
|
+
|
217
|
+
case CMARK_NODE_IMAGE:
|
218
|
+
if (entering) {
|
219
|
+
LIT("[IMAGE: ");
|
220
|
+
} else {
|
221
|
+
LIT("]");
|
222
|
+
}
|
223
|
+
break;
|
224
|
+
|
225
|
+
default:
|
226
|
+
assert(false);
|
227
|
+
break;
|
228
|
+
}
|
229
|
+
|
230
|
+
return 1;
|
244
231
|
}
|
245
232
|
|
246
|
-
char *cmark_render_man(cmark_node *root, int options, int width)
|
247
|
-
|
248
|
-
return cmark_render(root, options, width, S_outc, S_render_node);
|
233
|
+
char *cmark_render_man(cmark_node *root, int options, int width) {
|
234
|
+
return cmark_render(root, options, width, S_outc, S_render_node);
|
249
235
|
}
|