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
@@ -30,49 +30,48 @@ char *cmark_markdown_to_html(const char *text, size_t len, int options);
|
|
30
30
|
*/
|
31
31
|
|
32
32
|
typedef enum {
|
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
|
-
|
33
|
+
/* Error status */
|
34
|
+
CMARK_NODE_NONE,
|
35
|
+
|
36
|
+
/* Block */
|
37
|
+
CMARK_NODE_DOCUMENT,
|
38
|
+
CMARK_NODE_BLOCK_QUOTE,
|
39
|
+
CMARK_NODE_LIST,
|
40
|
+
CMARK_NODE_ITEM,
|
41
|
+
CMARK_NODE_CODE_BLOCK,
|
42
|
+
CMARK_NODE_HTML,
|
43
|
+
CMARK_NODE_PARAGRAPH,
|
44
|
+
CMARK_NODE_HEADER,
|
45
|
+
CMARK_NODE_HRULE,
|
46
|
+
|
47
|
+
CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
|
48
|
+
CMARK_NODE_LAST_BLOCK = CMARK_NODE_HRULE,
|
49
|
+
|
50
|
+
/* Inline */
|
51
|
+
CMARK_NODE_TEXT,
|
52
|
+
CMARK_NODE_SOFTBREAK,
|
53
|
+
CMARK_NODE_LINEBREAK,
|
54
|
+
CMARK_NODE_CODE,
|
55
|
+
CMARK_NODE_INLINE_HTML,
|
56
|
+
CMARK_NODE_EMPH,
|
57
|
+
CMARK_NODE_STRONG,
|
58
|
+
CMARK_NODE_LINK,
|
59
|
+
CMARK_NODE_IMAGE,
|
60
|
+
|
61
|
+
CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
|
62
|
+
CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
|
63
63
|
} cmark_node_type;
|
64
64
|
|
65
|
-
|
66
65
|
typedef enum {
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
}
|
66
|
+
CMARK_NO_LIST,
|
67
|
+
CMARK_BULLET_LIST,
|
68
|
+
CMARK_ORDERED_LIST
|
69
|
+
} cmark_list_type;
|
71
70
|
|
72
71
|
typedef enum {
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
CMARK_NO_DELIM,
|
73
|
+
CMARK_PERIOD_DELIM,
|
74
|
+
CMARK_PAREN_DELIM
|
76
75
|
} cmark_delim_type;
|
77
76
|
|
78
77
|
typedef struct cmark_node cmark_node;
|
@@ -80,10 +79,10 @@ typedef struct cmark_parser cmark_parser;
|
|
80
79
|
typedef struct cmark_iter cmark_iter;
|
81
80
|
|
82
81
|
typedef enum {
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
CMARK_EVENT_NONE,
|
83
|
+
CMARK_EVENT_DONE,
|
84
|
+
CMARK_EVENT_ENTER,
|
85
|
+
CMARK_EVENT_EXIT
|
87
86
|
} cmark_event_type;
|
88
87
|
|
89
88
|
/**
|
@@ -94,13 +93,11 @@ typedef enum {
|
|
94
93
|
* other required properties, which it is the caller's responsibility
|
95
94
|
* to assign.
|
96
95
|
*/
|
97
|
-
CMARK_EXPORT cmark_node*
|
98
|
-
cmark_node_new(cmark_node_type type);
|
96
|
+
CMARK_EXPORT cmark_node *cmark_node_new(cmark_node_type type);
|
99
97
|
|
100
98
|
/** Frees the memory allocated for a node.
|
101
99
|
*/
|
102
|
-
CMARK_EXPORT void
|
103
|
-
cmark_node_free(cmark_node *node);
|
100
|
+
CMARK_EXPORT void cmark_node_free(cmark_node *node);
|
104
101
|
|
105
102
|
/**
|
106
103
|
* ## Tree Traversal
|
@@ -109,29 +106,24 @@ cmark_node_free(cmark_node *node);
|
|
109
106
|
/** Returns the next node in the sequence after 'node', or NULL if
|
110
107
|
* there is none.
|
111
108
|
*/
|
112
|
-
CMARK_EXPORT cmark_node*
|
113
|
-
cmark_node_next(cmark_node *node);
|
109
|
+
CMARK_EXPORT cmark_node *cmark_node_next(cmark_node *node);
|
114
110
|
|
115
111
|
/** Returns the previous node in the sequence after 'node', or NULL if
|
116
112
|
* there is none.
|
117
113
|
*/
|
118
|
-
CMARK_EXPORT cmark_node*
|
119
|
-
cmark_node_previous(cmark_node *node);
|
114
|
+
CMARK_EXPORT cmark_node *cmark_node_previous(cmark_node *node);
|
120
115
|
|
121
116
|
/** Returns the parent of 'node', or NULL if there is none.
|
122
117
|
*/
|
123
|
-
CMARK_EXPORT cmark_node*
|
124
|
-
cmark_node_parent(cmark_node *node);
|
118
|
+
CMARK_EXPORT cmark_node *cmark_node_parent(cmark_node *node);
|
125
119
|
|
126
120
|
/** Returns the first child of 'node', or NULL if 'node' has no children.
|
127
121
|
*/
|
128
|
-
CMARK_EXPORT cmark_node*
|
129
|
-
cmark_node_first_child(cmark_node *node);
|
122
|
+
CMARK_EXPORT cmark_node *cmark_node_first_child(cmark_node *node);
|
130
123
|
|
131
124
|
/** Returns the last child of 'node', or NULL if 'node' has no children.
|
132
125
|
*/
|
133
|
-
CMARK_EXPORT cmark_node*
|
134
|
-
cmark_node_last_child(cmark_node *node);
|
126
|
+
CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
|
135
127
|
|
136
128
|
/**
|
137
129
|
* ## Iterator
|
@@ -182,48 +174,41 @@ cmark_node_last_child(cmark_node *node);
|
|
182
174
|
* type are undefined until `cmark_iter_next` is called for the first time.
|
183
175
|
*/
|
184
176
|
CMARK_EXPORT
|
185
|
-
cmark_iter*
|
186
|
-
cmark_iter_new(cmark_node *root);
|
177
|
+
cmark_iter *cmark_iter_new(cmark_node *root);
|
187
178
|
|
188
179
|
/** Frees the memory allocated for an iterator.
|
189
180
|
*/
|
190
181
|
CMARK_EXPORT
|
191
|
-
void
|
192
|
-
cmark_iter_free(cmark_iter *iter);
|
182
|
+
void cmark_iter_free(cmark_iter *iter);
|
193
183
|
|
194
184
|
/** Advances to the next node and returns the event type (`CMARK_EVENT_ENTER`,
|
195
185
|
* `CMARK_EVENT_EXIT` or `CMARK_EVENT_DONE`).
|
196
186
|
*/
|
197
187
|
CMARK_EXPORT
|
198
|
-
cmark_event_type
|
199
|
-
cmark_iter_next(cmark_iter *iter);
|
188
|
+
cmark_event_type cmark_iter_next(cmark_iter *iter);
|
200
189
|
|
201
190
|
/** Returns the current node.
|
202
191
|
*/
|
203
192
|
CMARK_EXPORT
|
204
|
-
cmark_node*
|
205
|
-
cmark_iter_get_node(cmark_iter *iter);
|
193
|
+
cmark_node *cmark_iter_get_node(cmark_iter *iter);
|
206
194
|
|
207
195
|
/** Returns the current event type.
|
208
196
|
*/
|
209
197
|
CMARK_EXPORT
|
210
|
-
cmark_event_type
|
211
|
-
cmark_iter_get_event_type(cmark_iter *iter);
|
198
|
+
cmark_event_type cmark_iter_get_event_type(cmark_iter *iter);
|
212
199
|
|
213
200
|
/** Returns the root node.
|
214
201
|
*/
|
215
202
|
CMARK_EXPORT
|
216
|
-
cmark_node*
|
217
|
-
cmark_iter_get_root(cmark_iter *iter);
|
203
|
+
cmark_node *cmark_iter_get_root(cmark_iter *iter);
|
218
204
|
|
219
205
|
/** Resets the iterator so that the current node is 'current' and
|
220
206
|
* the event type is 'event_type'. The new current node must be a
|
221
207
|
* descendant of the root node or the root node itself.
|
222
208
|
*/
|
223
209
|
CMARK_EXPORT
|
224
|
-
void
|
225
|
-
|
226
|
-
cmark_event_type event_type);
|
210
|
+
void cmark_iter_reset(cmark_iter *iter, cmark_node *current,
|
211
|
+
cmark_event_type event_type);
|
227
212
|
|
228
213
|
/**
|
229
214
|
* ## Accessors
|
@@ -231,144 +216,120 @@ cmark_iter_reset(cmark_iter *iter, cmark_node *current,
|
|
231
216
|
|
232
217
|
/** Returns the user data of 'node'.
|
233
218
|
*/
|
234
|
-
CMARK_EXPORT void*
|
235
|
-
cmark_node_get_user_data(cmark_node *node);
|
219
|
+
CMARK_EXPORT void *cmark_node_get_user_data(cmark_node *node);
|
236
220
|
|
237
221
|
/** Sets arbitrary user data for 'node'. Returns 1 on success,
|
238
222
|
* 0 on failure.
|
239
223
|
*/
|
240
|
-
CMARK_EXPORT int
|
241
|
-
cmark_node_set_user_data(cmark_node *node, void *user_data);
|
224
|
+
CMARK_EXPORT int cmark_node_set_user_data(cmark_node *node, void *user_data);
|
242
225
|
|
243
226
|
/** Returns the type of 'node', or `CMARK_NODE_NONE` on error.
|
244
227
|
*/
|
245
|
-
CMARK_EXPORT cmark_node_type
|
246
|
-
cmark_node_get_type(cmark_node *node);
|
228
|
+
CMARK_EXPORT cmark_node_type cmark_node_get_type(cmark_node *node);
|
247
229
|
|
248
230
|
/** Like 'cmark_node_get_type', but returns a string representation
|
249
231
|
of the type, or `"<unknown>"`.
|
250
232
|
*/
|
251
233
|
CMARK_EXPORT
|
252
|
-
const char*
|
253
|
-
cmark_node_get_type_string(cmark_node *node);
|
234
|
+
const char *cmark_node_get_type_string(cmark_node *node);
|
254
235
|
|
255
236
|
/** Returns the string contents of 'node', or NULL if none.
|
256
237
|
*/
|
257
|
-
CMARK_EXPORT const char*
|
258
|
-
cmark_node_get_literal(cmark_node *node);
|
238
|
+
CMARK_EXPORT const char *cmark_node_get_literal(cmark_node *node);
|
259
239
|
|
260
240
|
/** Sets the string contents of 'node'. Returns 1 on success,
|
261
241
|
* 0 on failure.
|
262
242
|
*/
|
263
|
-
CMARK_EXPORT int
|
264
|
-
cmark_node_set_literal(cmark_node *node, const char *content);
|
243
|
+
CMARK_EXPORT int cmark_node_set_literal(cmark_node *node, const char *content);
|
265
244
|
|
266
245
|
/** Returns the header level of 'node', or 0 if 'node' is not a header.
|
267
246
|
*/
|
268
|
-
CMARK_EXPORT int
|
269
|
-
cmark_node_get_header_level(cmark_node *node);
|
247
|
+
CMARK_EXPORT int cmark_node_get_header_level(cmark_node *node);
|
270
248
|
|
271
249
|
/** Sets the header level of 'node', returning 1 on success and 0 on error.
|
272
250
|
*/
|
273
|
-
CMARK_EXPORT int
|
274
|
-
cmark_node_set_header_level(cmark_node *node, int level);
|
251
|
+
CMARK_EXPORT int cmark_node_set_header_level(cmark_node *node, int level);
|
275
252
|
|
276
253
|
/** Returns the list type of 'node', or `CMARK_NO_LIST` if 'node'
|
277
254
|
* is not a list.
|
278
255
|
*/
|
279
|
-
CMARK_EXPORT cmark_list_type
|
280
|
-
cmark_node_get_list_type(cmark_node *node);
|
256
|
+
CMARK_EXPORT cmark_list_type cmark_node_get_list_type(cmark_node *node);
|
281
257
|
|
282
258
|
/** Sets the list type of 'node', returning 1 on success and 0 on error.
|
283
259
|
*/
|
284
|
-
CMARK_EXPORT int
|
285
|
-
|
260
|
+
CMARK_EXPORT int cmark_node_set_list_type(cmark_node *node,
|
261
|
+
cmark_list_type type);
|
286
262
|
|
287
263
|
/** Returns the list delimiter type of 'node', or `CMARK_NO_DELIM` if 'node'
|
288
264
|
* is not a list.
|
289
265
|
*/
|
290
|
-
CMARK_EXPORT cmark_delim_type
|
291
|
-
cmark_node_get_list_delim(cmark_node *node);
|
266
|
+
CMARK_EXPORT cmark_delim_type cmark_node_get_list_delim(cmark_node *node);
|
292
267
|
|
293
268
|
/** Sets the list delimiter type of 'node', returning 1 on success and 0
|
294
269
|
* on error.
|
295
270
|
*/
|
296
|
-
CMARK_EXPORT int
|
297
|
-
|
271
|
+
CMARK_EXPORT int cmark_node_set_list_delim(cmark_node *node,
|
272
|
+
cmark_delim_type delim);
|
298
273
|
|
299
274
|
/** Returns starting number of 'node', if it is an ordered list, otherwise 0.
|
300
275
|
*/
|
301
|
-
CMARK_EXPORT int
|
302
|
-
cmark_node_get_list_start(cmark_node *node);
|
276
|
+
CMARK_EXPORT int cmark_node_get_list_start(cmark_node *node);
|
303
277
|
|
304
278
|
/** Sets starting number of 'node', if it is an ordered list. Returns 1
|
305
279
|
* on success, 0 on failure.
|
306
280
|
*/
|
307
|
-
CMARK_EXPORT int
|
308
|
-
cmark_node_set_list_start(cmark_node *node, int start);
|
281
|
+
CMARK_EXPORT int cmark_node_set_list_start(cmark_node *node, int start);
|
309
282
|
|
310
283
|
/** Returns 1 if 'node' is a tight list, 0 otherwise.
|
311
284
|
*/
|
312
|
-
CMARK_EXPORT int
|
313
|
-
cmark_node_get_list_tight(cmark_node *node);
|
285
|
+
CMARK_EXPORT int cmark_node_get_list_tight(cmark_node *node);
|
314
286
|
|
315
287
|
/** Sets the "tightness" of a list. Returns 1 on success, 0 on failure.
|
316
288
|
*/
|
317
|
-
CMARK_EXPORT int
|
318
|
-
cmark_node_set_list_tight(cmark_node *node, int tight);
|
289
|
+
CMARK_EXPORT int cmark_node_set_list_tight(cmark_node *node, int tight);
|
319
290
|
|
320
291
|
/** Returns the info string from a fenced code block, or NULL if none.
|
321
292
|
*/
|
322
|
-
CMARK_EXPORT const char*
|
323
|
-
cmark_node_get_fence_info(cmark_node *node);
|
293
|
+
CMARK_EXPORT const char *cmark_node_get_fence_info(cmark_node *node);
|
324
294
|
|
325
295
|
/** Sets the info string in a fenced code block, returning 1 on
|
326
296
|
* success and 0 on failure.
|
327
297
|
*/
|
328
|
-
CMARK_EXPORT int
|
329
|
-
cmark_node_set_fence_info(cmark_node *node, const char *info);
|
298
|
+
CMARK_EXPORT int cmark_node_set_fence_info(cmark_node *node, const char *info);
|
330
299
|
|
331
300
|
/** Gets the URL of a link or image 'node', or NULL if none.
|
332
301
|
*/
|
333
|
-
CMARK_EXPORT const char*
|
334
|
-
cmark_node_get_url(cmark_node *node);
|
302
|
+
CMARK_EXPORT const char *cmark_node_get_url(cmark_node *node);
|
335
303
|
|
336
304
|
/** Sets the URL of a link or image 'node'. Returns 1 on success,
|
337
305
|
* 0 on failure.
|
338
306
|
*/
|
339
|
-
CMARK_EXPORT int
|
340
|
-
cmark_node_set_url(cmark_node *node, const char *url);
|
307
|
+
CMARK_EXPORT int cmark_node_set_url(cmark_node *node, const char *url);
|
341
308
|
|
342
309
|
/** Gets the title of a link or image 'node', or NULL if none.
|
343
310
|
*/
|
344
|
-
CMARK_EXPORT const char*
|
345
|
-
cmark_node_get_title(cmark_node *node);
|
311
|
+
CMARK_EXPORT const char *cmark_node_get_title(cmark_node *node);
|
346
312
|
|
347
313
|
/** Sets the title of a link or image 'node'. Returns 1 on success,
|
348
314
|
* 0 on failure.
|
349
315
|
*/
|
350
|
-
CMARK_EXPORT int
|
351
|
-
cmark_node_set_title(cmark_node *node, const char *title);
|
316
|
+
CMARK_EXPORT int cmark_node_set_title(cmark_node *node, const char *title);
|
352
317
|
|
353
318
|
/** Returns the line on which 'node' begins.
|
354
319
|
*/
|
355
|
-
CMARK_EXPORT int
|
356
|
-
cmark_node_get_start_line(cmark_node *node);
|
320
|
+
CMARK_EXPORT int cmark_node_get_start_line(cmark_node *node);
|
357
321
|
|
358
322
|
/** Returns the column at which 'node' begins.
|
359
323
|
*/
|
360
|
-
CMARK_EXPORT int
|
361
|
-
cmark_node_get_start_column(cmark_node *node);
|
324
|
+
CMARK_EXPORT int cmark_node_get_start_column(cmark_node *node);
|
362
325
|
|
363
326
|
/** Returns the line on which 'node' ends.
|
364
327
|
*/
|
365
|
-
CMARK_EXPORT int
|
366
|
-
cmark_node_get_end_line(cmark_node *node);
|
328
|
+
CMARK_EXPORT int cmark_node_get_end_line(cmark_node *node);
|
367
329
|
|
368
330
|
/** Returns the column at which 'node' ends.
|
369
331
|
*/
|
370
|
-
CMARK_EXPORT int
|
371
|
-
cmark_node_get_end_column(cmark_node *node);
|
332
|
+
CMARK_EXPORT int cmark_node_get_end_column(cmark_node *node);
|
372
333
|
|
373
334
|
/**
|
374
335
|
* ## Tree Manipulation
|
@@ -377,35 +338,30 @@ cmark_node_get_end_column(cmark_node *node);
|
|
377
338
|
/** Unlinks a 'node', removing it from the tree, but not freeing its
|
378
339
|
* memory. (Use 'cmark_node_free' for that.)
|
379
340
|
*/
|
380
|
-
CMARK_EXPORT void
|
381
|
-
cmark_node_unlink(cmark_node *node);
|
341
|
+
CMARK_EXPORT void cmark_node_unlink(cmark_node *node);
|
382
342
|
|
383
343
|
/** Inserts 'sibling' before 'node'. Returns 1 on success, 0 on failure.
|
384
344
|
*/
|
385
|
-
CMARK_EXPORT int
|
386
|
-
|
345
|
+
CMARK_EXPORT int cmark_node_insert_before(cmark_node *node,
|
346
|
+
cmark_node *sibling);
|
387
347
|
|
388
348
|
/** Inserts 'sibling' after 'node'. Returns 1 on success, 0 on failure.
|
389
349
|
*/
|
390
|
-
CMARK_EXPORT int
|
391
|
-
cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
|
350
|
+
CMARK_EXPORT int cmark_node_insert_after(cmark_node *node, cmark_node *sibling);
|
392
351
|
|
393
352
|
/** Adds 'child' to the beginning of the children of 'node'.
|
394
353
|
* Returns 1 on success, 0 on failure.
|
395
354
|
*/
|
396
|
-
CMARK_EXPORT int
|
397
|
-
cmark_node_prepend_child(cmark_node *node, cmark_node *child);
|
355
|
+
CMARK_EXPORT int cmark_node_prepend_child(cmark_node *node, cmark_node *child);
|
398
356
|
|
399
357
|
/** Adds 'child' to the end of the children of 'node'.
|
400
358
|
* Returns 1 on success, 0 on failure.
|
401
359
|
*/
|
402
|
-
CMARK_EXPORT int
|
403
|
-
cmark_node_append_child(cmark_node *node, cmark_node *child);
|
360
|
+
CMARK_EXPORT int cmark_node_append_child(cmark_node *node, cmark_node *child);
|
404
361
|
|
405
362
|
/** Consolidates adjacent text nodes.
|
406
363
|
*/
|
407
|
-
CMARK_EXPORT void
|
408
|
-
cmark_consolidate_text_nodes(cmark_node *root);
|
364
|
+
CMARK_EXPORT void cmark_consolidate_text_nodes(cmark_node *root);
|
409
365
|
|
410
366
|
/**
|
411
367
|
* ## Parsing
|
@@ -552,28 +508,28 @@ const char *cmark_version_string();
|
|
552
508
|
*/
|
553
509
|
|
554
510
|
#ifndef CMARK_NO_SHORT_NAMES
|
555
|
-
#define NODE_DOCUMENT
|
556
|
-
#define NODE_BLOCK_QUOTE
|
557
|
-
#define NODE_LIST
|
558
|
-
#define NODE_ITEM
|
559
|
-
#define NODE_CODE_BLOCK
|
560
|
-
#define NODE_HTML
|
561
|
-
#define NODE_PARAGRAPH
|
562
|
-
#define NODE_HEADER
|
563
|
-
#define NODE_HRULE
|
564
|
-
#define NODE_TEXT
|
565
|
-
#define NODE_SOFTBREAK
|
566
|
-
#define NODE_LINEBREAK
|
567
|
-
#define NODE_CODE
|
568
|
-
#define NODE_INLINE_HTML
|
569
|
-
#define NODE_EMPH
|
570
|
-
#define NODE_STRONG
|
571
|
-
#define NODE_LINK
|
572
|
-
#define NODE_IMAGE
|
573
|
-
#define BULLET_LIST
|
574
|
-
#define ORDERED_LIST
|
575
|
-
#define PERIOD_DELIM
|
576
|
-
#define PAREN_DELIM
|
511
|
+
#define NODE_DOCUMENT CMARK_NODE_DOCUMENT
|
512
|
+
#define NODE_BLOCK_QUOTE CMARK_NODE_BLOCK_QUOTE
|
513
|
+
#define NODE_LIST CMARK_NODE_LIST
|
514
|
+
#define NODE_ITEM CMARK_NODE_ITEM
|
515
|
+
#define NODE_CODE_BLOCK CMARK_NODE_CODE_BLOCK
|
516
|
+
#define NODE_HTML CMARK_NODE_HTML
|
517
|
+
#define NODE_PARAGRAPH CMARK_NODE_PARAGRAPH
|
518
|
+
#define NODE_HEADER CMARK_NODE_HEADER
|
519
|
+
#define NODE_HRULE CMARK_NODE_HRULE
|
520
|
+
#define NODE_TEXT CMARK_NODE_TEXT
|
521
|
+
#define NODE_SOFTBREAK CMARK_NODE_SOFTBREAK
|
522
|
+
#define NODE_LINEBREAK CMARK_NODE_LINEBREAK
|
523
|
+
#define NODE_CODE CMARK_NODE_CODE
|
524
|
+
#define NODE_INLINE_HTML CMARK_NODE_INLINE_HTML
|
525
|
+
#define NODE_EMPH CMARK_NODE_EMPH
|
526
|
+
#define NODE_STRONG CMARK_NODE_STRONG
|
527
|
+
#define NODE_LINK CMARK_NODE_LINK
|
528
|
+
#define NODE_IMAGE CMARK_NODE_IMAGE
|
529
|
+
#define BULLET_LIST CMARK_BULLET_LIST
|
530
|
+
#define ORDERED_LIST CMARK_ORDERED_LIST
|
531
|
+
#define PERIOD_DELIM CMARK_PERIOD_DELIM
|
532
|
+
#define PAREN_DELIM CMARK_PAREN_DELIM
|
577
533
|
#endif
|
578
534
|
|
579
535
|
#ifdef __cplusplus
|
@@ -5,49 +5,38 @@
|
|
5
5
|
/** 1 = space, 2 = punct, 3 = digit, 4 = alpha, 0 = other
|
6
6
|
*/
|
7
7
|
static const int8_t cmark_ctype_class[256] = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
};
|
8
|
+
/* 0 1 2 3 4 5 6 7 8 9 a b c d e f */
|
9
|
+
/* 0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,
|
10
|
+
/* 1 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
11
|
+
/* 2 */ 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
12
|
+
/* 3 */ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2,
|
13
|
+
/* 4 */ 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
14
|
+
/* 5 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 2,
|
15
|
+
/* 6 */ 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
|
16
|
+
/* 7 */ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 2, 2, 0,
|
17
|
+
/* 8 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
18
|
+
/* 9 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
19
|
+
/* a */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
20
|
+
/* b */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
21
|
+
/* c */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
22
|
+
/* d */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
23
|
+
/* e */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
24
|
+
/* f */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
26
25
|
|
27
26
|
/**
|
28
27
|
* Returns 1 if c is a "whitespace" character as defined by the spec.
|
29
28
|
*/
|
30
|
-
int cmark_isspace(char c)
|
31
|
-
{
|
32
|
-
return cmark_ctype_class[(int8_t)c] == 1;
|
33
|
-
}
|
29
|
+
int cmark_isspace(char c) { return cmark_ctype_class[(int8_t)c] == 1; }
|
34
30
|
|
35
31
|
/**
|
36
32
|
* Returns 1 if c is an ascii punctuation character.
|
37
33
|
*/
|
38
|
-
int cmark_ispunct(char c)
|
39
|
-
{
|
40
|
-
return cmark_ctype_class[(int8_t)c] == 2;
|
41
|
-
}
|
34
|
+
int cmark_ispunct(char c) { return cmark_ctype_class[(int8_t)c] == 2; }
|
42
35
|
|
43
|
-
int cmark_isalnum(char c)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
return (result == 3 || result == 4);
|
36
|
+
int cmark_isalnum(char c) {
|
37
|
+
int8_t result;
|
38
|
+
result = cmark_ctype_class[(int8_t)c];
|
39
|
+
return (result == 3 || result == 4);
|
48
40
|
}
|
49
41
|
|
50
|
-
int cmark_isdigit(char c)
|
51
|
-
{
|
52
|
-
return cmark_ctype_class[(int8_t)c] == 3;
|
53
|
-
}
|
42
|
+
int cmark_isdigit(char c) { return cmark_ctype_class[(int8_t)c] == 3; }
|