commonmarker 0.5.1 → 0.6.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.

Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +23 -17
  3. data/ext/commonmarker/cmark/CMakeLists.txt +1 -1
  4. data/ext/commonmarker/cmark/Makefile +13 -14
  5. data/ext/commonmarker/cmark/README.md +1 -0
  6. data/ext/commonmarker/cmark/api_test/cplusplus.h +1 -2
  7. data/ext/commonmarker/cmark/api_test/harness.c +60 -79
  8. data/ext/commonmarker/cmark/api_test/harness.h +13 -20
  9. data/ext/commonmarker/cmark/api_test/main.c +809 -714
  10. data/ext/commonmarker/cmark/build/CMakeCache.txt +3 -0
  11. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +0 -67
  12. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +1 -1
  13. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -1
  14. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +1 -1
  15. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +23 -23
  16. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +1 -1
  17. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -1
  18. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
  19. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
  20. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o +0 -0
  21. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
  22. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
  23. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
  24. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
  25. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/latex.c.o +0 -0
  26. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
  27. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
  28. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/render.c.o +0 -0
  29. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
  30. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
  31. data/ext/commonmarker/cmark/build/src/cmake_install.cmake +10 -2
  32. data/ext/commonmarker/cmark/build/src/cmark_version.h +2 -2
  33. data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
  34. data/ext/commonmarker/cmark/build/src/libcmark.pc +1 -1
  35. data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +1 -0
  36. data/ext/commonmarker/cmark/changelog.txt +85 -0
  37. data/ext/commonmarker/cmark/man/man3/cmark.3 +75 -34
  38. data/ext/commonmarker/cmark/src/CMakeLists.txt +13 -8
  39. data/ext/commonmarker/cmark/src/blocks.c +78 -70
  40. data/ext/commonmarker/cmark/src/chunk.h +5 -7
  41. data/ext/commonmarker/cmark/src/cmark.h +88 -34
  42. data/ext/commonmarker/cmark/src/cmark_ctype.c +6 -6
  43. data/ext/commonmarker/cmark/src/commonmark.c +24 -8
  44. data/ext/commonmarker/cmark/src/houdini_html_u.c +6 -5
  45. data/ext/commonmarker/cmark/src/html.c +33 -11
  46. data/ext/commonmarker/cmark/src/inlines.c +9 -10
  47. data/ext/commonmarker/cmark/src/iterator.c +2 -2
  48. data/ext/commonmarker/cmark/src/latex.c +54 -28
  49. data/ext/commonmarker/cmark/src/main.c +0 -9
  50. data/ext/commonmarker/cmark/src/man.c +17 -5
  51. data/ext/commonmarker/cmark/src/node.c +123 -44
  52. data/ext/commonmarker/cmark/src/node.h +8 -2
  53. data/ext/commonmarker/cmark/src/render.c +8 -1
  54. data/ext/commonmarker/cmark/src/render.h +1 -0
  55. data/ext/commonmarker/cmark/src/scanners.c +3755 -4379
  56. data/ext/commonmarker/cmark/src/scanners.h +7 -6
  57. data/ext/commonmarker/cmark/src/scanners.re +9 -10
  58. data/ext/commonmarker/cmark/src/utf8.c +6 -3
  59. data/ext/commonmarker/cmark/src/utf8.h +4 -2
  60. data/ext/commonmarker/cmark/src/xml.c +18 -4
  61. data/ext/commonmarker/cmark/test/CMakeLists.txt +11 -0
  62. data/ext/commonmarker/cmark/test/normalize.py +5 -1
  63. data/ext/commonmarker/cmark/test/roundtrip.bat +1 -0
  64. data/ext/commonmarker/cmark/test/roundtrip.sh +1 -1
  65. data/ext/commonmarker/cmark/test/spec.txt +257 -157
  66. data/ext/commonmarker/cmark/why-cmark-and-not-x.md +104 -0
  67. data/lib/commonmarker/config.rb +6 -6
  68. data/lib/commonmarker/version.rb +1 -1
  69. metadata +5 -5
  70. data/ext/commonmarker/cmark/src/bench.h +0 -27
  71. data/ext/commonmarker/cmark/wrappers/wrapper.lua +0 -239
@@ -24,7 +24,7 @@ static const char *RIGHTSINGLEQUOTE = "\xE2\x80\x99";
24
24
  // Macros for creating various kinds of simple.
25
25
  #define make_str(s) make_literal(CMARK_NODE_TEXT, s)
26
26
  #define make_code(s) make_literal(CMARK_NODE_CODE, s)
27
- #define make_raw_html(s) make_literal(CMARK_NODE_INLINE_HTML, s)
27
+ #define make_raw_html(s) make_literal(CMARK_NODE_HTML_INLINE, s)
28
28
  #define make_linebreak() make_simple(CMARK_NODE_LINEBREAK)
29
29
  #define make_softbreak() make_simple(CMARK_NODE_SOFTBREAK)
30
30
  #define make_emph() make_simple(CMARK_NODE_EMPH)
@@ -284,7 +284,7 @@ static int scan_delims(subject *subj, unsigned char c, bool *can_open,
284
284
  before_char_pos -= 1;
285
285
  }
286
286
  len = cmark_utf8proc_iterate(subj->input.data + before_char_pos,
287
- subj->pos - before_char_pos, &before_char);
287
+ subj->pos - before_char_pos, &before_char);
288
288
  if (len == -1) {
289
289
  before_char = 10;
290
290
  }
@@ -301,7 +301,7 @@ static int scan_delims(subject *subj, unsigned char c, bool *can_open,
301
301
  }
302
302
 
303
303
  len = cmark_utf8proc_iterate(subj->input.data + subj->pos,
304
- subj->input.len - subj->pos, &after_char);
304
+ subj->input.len - subj->pos, &after_char);
305
305
  if (len == -1) {
306
306
  after_char = 10;
307
307
  }
@@ -309,10 +309,10 @@ static int scan_delims(subject *subj, unsigned char c, bool *can_open,
309
309
  !(cmark_utf8proc_is_punctuation(after_char) &&
310
310
  !cmark_utf8proc_is_space(before_char) &&
311
311
  !cmark_utf8proc_is_punctuation(before_char));
312
- right_flanking =
313
- numdelims > 0 && !cmark_utf8proc_is_space(before_char) &&
314
- !(cmark_utf8proc_is_punctuation(before_char) &&
315
- !cmark_utf8proc_is_space(after_char) && !cmark_utf8proc_is_punctuation(after_char));
312
+ right_flanking = numdelims > 0 && !cmark_utf8proc_is_space(before_char) &&
313
+ !(cmark_utf8proc_is_punctuation(before_char) &&
314
+ !cmark_utf8proc_is_space(after_char) &&
315
+ !cmark_utf8proc_is_punctuation(after_char));
316
316
  if (c == '_') {
317
317
  *can_open = left_flanking &&
318
318
  (!right_flanking || cmark_utf8proc_is_punctuation(before_char));
@@ -865,7 +865,6 @@ static cmark_node *handle_close_bracket(subject *subj, cmark_node *parent) {
865
865
 
866
866
  // Next, look for a following [link label] that matches in refmap.
867
867
  // skip spaces
868
- subj->pos = subj->pos + scan_spacechars(&subj->input, subj->pos);
869
868
  raw_label = cmark_chunk_literal("");
870
869
  found_label = link_label(subj, &raw_label);
871
870
  if (!found_label || raw_label.len == 0) {
@@ -944,10 +943,10 @@ static cmark_node *handle_newline(subject *subj) {
944
943
  bufsize_t nlpos = subj->pos;
945
944
  // skip over cr, crlf, or lf:
946
945
  if (peek_at(subj, subj->pos) == '\r') {
947
- advance(subj);
946
+ advance(subj);
948
947
  }
949
948
  if (peek_at(subj, subj->pos) == '\n') {
950
- advance(subj);
949
+ advance(subj);
951
950
  }
952
951
  // skip spaces at beginning of line
953
952
  skip_spaces(subj);
@@ -7,10 +7,10 @@
7
7
  #include "iterator.h"
8
8
 
9
9
  static const int S_leaf_mask =
10
- (1 << CMARK_NODE_HTML) | (1 << CMARK_NODE_HRULE) |
10
+ (1 << CMARK_NODE_HTML_BLOCK) | (1 << CMARK_NODE_THEMATIC_BREAK) |
11
11
  (1 << CMARK_NODE_CODE_BLOCK) | (1 << CMARK_NODE_TEXT) |
12
12
  (1 << CMARK_NODE_SOFTBREAK) | (1 << CMARK_NODE_LINEBREAK) |
13
- (1 << CMARK_NODE_CODE) | (1 << CMARK_NODE_INLINE_HTML);
13
+ (1 << CMARK_NODE_CODE) | (1 << CMARK_NODE_HTML_INLINE);
14
14
 
15
15
  cmark_iter *cmark_iter_new(cmark_node *root) {
16
16
  if (root == NULL) {
@@ -142,7 +142,13 @@ static inline void outc(cmark_renderer *renderer, cmark_escaping escape,
142
142
  }
143
143
  }
144
144
 
145
- typedef enum { NO_LINK, URL_AUTOLINK, EMAIL_AUTOLINK, NORMAL_LINK } link_type;
145
+ typedef enum {
146
+ NO_LINK,
147
+ URL_AUTOLINK,
148
+ EMAIL_AUTOLINK,
149
+ NORMAL_LINK,
150
+ INTERNAL_LINK
151
+ } link_type;
146
152
 
147
153
  static link_type get_link_type(cmark_node *node) {
148
154
  size_t title_len, url_len;
@@ -158,6 +164,10 @@ static link_type get_link_type(cmark_node *node) {
158
164
  const char *url = cmark_node_get_url(node);
159
165
  cmark_chunk url_chunk = cmark_chunk_literal(url);
160
166
 
167
+ if (url && *url == '#') {
168
+ return INTERNAL_LINK;
169
+ }
170
+
161
171
  url_len = safe_strlen(url);
162
172
  if (url_len == 0 || scan_scheme(&url_chunk, 0) == 0) {
163
173
  return NO_LINK;
@@ -166,30 +176,29 @@ static link_type get_link_type(cmark_node *node) {
166
176
  const char *title = cmark_node_get_title(node);
167
177
  title_len = safe_strlen(title);
168
178
  // if it has a title, we can't treat it as an autolink:
169
- if (title_len > 0) {
170
- return NORMAL_LINK;
171
- }
172
-
173
- link_text = node->first_child;
174
- cmark_consolidate_text_nodes(link_text);
175
- realurl = (char *)url;
176
- realurllen = url_len;
177
- if (strncmp(realurl, "mailto:", 7) == 0) {
178
- realurl += 7;
179
- realurllen -= 7;
180
- isemail = true;
181
- }
182
- if (realurllen == link_text->as.literal.len &&
183
- strncmp(realurl, (char *)link_text->as.literal.data,
184
- link_text->as.literal.len) == 0) {
185
- if (isemail) {
186
- return EMAIL_AUTOLINK;
187
- } else {
188
- return URL_AUTOLINK;
179
+ if (title_len == 0) {
180
+
181
+ link_text = node->first_child;
182
+ cmark_consolidate_text_nodes(link_text);
183
+ realurl = (char *)url;
184
+ realurllen = url_len;
185
+ if (strncmp(realurl, "mailto:", 7) == 0) {
186
+ realurl += 7;
187
+ realurllen -= 7;
188
+ isemail = true;
189
+ }
190
+ if (realurllen == link_text->as.literal.len &&
191
+ strncmp(realurl, (char *)link_text->as.literal.data,
192
+ link_text->as.literal.len) == 0) {
193
+ if (isemail) {
194
+ return EMAIL_AUTOLINK;
195
+ } else {
196
+ return URL_AUTOLINK;
197
+ }
189
198
  }
190
- } else {
191
- return NORMAL_LINK;
192
199
  }
200
+
201
+ return NORMAL_LINK;
193
202
  }
194
203
 
195
204
  static int S_get_enumlevel(cmark_node *node) {
@@ -264,9 +273,9 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
264
273
  }
265
274
  break;
266
275
 
267
- case CMARK_NODE_HEADER:
276
+ case CMARK_NODE_HEADING:
268
277
  if (entering) {
269
- switch (cmark_node_get_header_level(node)) {
278
+ switch (cmark_node_get_heading_level(node)) {
270
279
  case 1:
271
280
  LIT("\\section");
272
281
  break;
@@ -300,10 +309,17 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
300
309
  BLANKLINE();
301
310
  break;
302
311
 
303
- case CMARK_NODE_HTML:
312
+ case CMARK_NODE_HTML_BLOCK:
304
313
  break;
305
314
 
306
- case CMARK_NODE_HRULE:
315
+ case CMARK_NODE_CUSTOM_BLOCK:
316
+ CR();
317
+ OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
318
+ false, LITERAL);
319
+ CR();
320
+ break;
321
+
322
+ case CMARK_NODE_THEMATIC_BREAK:
307
323
  BLANKLINE();
308
324
  LIT("\\begin{center}\\rule{0.5\\linewidth}{\\linethickness}\\end{center}");
309
325
  BLANKLINE();
@@ -338,7 +354,12 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
338
354
  LIT("}");
339
355
  break;
340
356
 
341
- case CMARK_NODE_INLINE_HTML:
357
+ case CMARK_NODE_HTML_INLINE:
358
+ break;
359
+
360
+ case CMARK_NODE_CUSTOM_INLINE:
361
+ OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
362
+ false, LITERAL);
342
363
  break;
343
364
 
344
365
  case CMARK_NODE_STRONG:
@@ -376,6 +397,11 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
376
397
  OUT(url, false, URL);
377
398
  LIT("}{");
378
399
  break;
400
+ case INTERNAL_LINK:
401
+ LIT("\\protect\\hyperlink{");
402
+ OUT(url + 1, false, URL);
403
+ LIT("}{");
404
+ break;
379
405
  case NO_LINK:
380
406
  LIT("{"); // error?
381
407
  }
@@ -4,7 +4,6 @@
4
4
  #include <errno.h>
5
5
  #include "config.h"
6
6
  #include "cmark.h"
7
- #include "bench.h"
8
7
 
9
8
  #if defined(_WIN32) && !defined(__CYGWIN__)
10
9
  #include <io.h>
@@ -153,14 +152,12 @@ int main(int argc, char *argv[]) {
153
152
  exit(1);
154
153
  }
155
154
 
156
- start_timer();
157
155
  while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
158
156
  cmark_parser_feed(parser, buffer, bytes);
159
157
  if (bytes < sizeof(buffer)) {
160
158
  break;
161
159
  }
162
160
  }
163
- end_timer("processing lines");
164
161
 
165
162
  fclose(fp);
166
163
  }
@@ -175,18 +172,12 @@ int main(int argc, char *argv[]) {
175
172
  }
176
173
  }
177
174
 
178
- start_timer();
179
175
  document = cmark_parser_finish(parser);
180
- end_timer("finishing document");
181
176
  cmark_parser_free(parser);
182
177
 
183
- start_timer();
184
178
  print_document(document, writer, options, width);
185
- end_timer("print_document");
186
179
 
187
- start_timer();
188
180
  cmark_node_free(document);
189
- end_timer("free_blocks");
190
181
 
191
182
  free(files);
192
183
 
@@ -120,10 +120,10 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
120
120
  }
121
121
  break;
122
122
 
123
- case CMARK_NODE_HEADER:
123
+ case CMARK_NODE_HEADING:
124
124
  if (entering) {
125
125
  CR();
126
- LIT(cmark_node_get_header_level(node) == 1 ? ".SH" : ".SS");
126
+ LIT(cmark_node_get_heading_level(node) == 1 ? ".SH" : ".SS");
127
127
  CR();
128
128
  } else {
129
129
  CR();
@@ -139,10 +139,17 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
139
139
  CR();
140
140
  break;
141
141
 
142
- case CMARK_NODE_HTML:
142
+ case CMARK_NODE_HTML_BLOCK:
143
143
  break;
144
144
 
145
- case CMARK_NODE_HRULE:
145
+ case CMARK_NODE_CUSTOM_BLOCK:
146
+ CR();
147
+ OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
148
+ false, LITERAL);
149
+ CR();
150
+ break;
151
+
152
+ case CMARK_NODE_THEMATIC_BREAK:
146
153
  CR();
147
154
  LIT(".PP\n * * * * *");
148
155
  CR();
@@ -187,7 +194,12 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
187
194
  LIT("\\f[]");
188
195
  break;
189
196
 
190
- case CMARK_NODE_INLINE_HTML:
197
+ case CMARK_NODE_HTML_INLINE:
198
+ break;
199
+
200
+ case CMARK_NODE_CUSTOM_INLINE:
201
+ OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node),
202
+ false, LITERAL);
191
203
  break;
192
204
 
193
205
  case CMARK_NODE_STRONG:
@@ -51,12 +51,16 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
51
51
  case CMARK_NODE_LIST:
52
52
  return child->type == CMARK_NODE_ITEM;
53
53
 
54
+ case CMARK_NODE_CUSTOM_BLOCK:
55
+ return true;
56
+
54
57
  case CMARK_NODE_PARAGRAPH:
55
- case CMARK_NODE_HEADER:
58
+ case CMARK_NODE_HEADING:
56
59
  case CMARK_NODE_EMPH:
57
60
  case CMARK_NODE_STRONG:
58
61
  case CMARK_NODE_LINK:
59
62
  case CMARK_NODE_IMAGE:
63
+ case CMARK_NODE_CUSTOM_INLINE:
60
64
  return S_is_inline(child);
61
65
 
62
66
  default:
@@ -71,8 +75,8 @@ cmark_node *cmark_node_new(cmark_node_type type) {
71
75
  node->type = type;
72
76
 
73
77
  switch (node->type) {
74
- case CMARK_NODE_HEADER:
75
- node->as.header.level = 1;
78
+ case CMARK_NODE_HEADING:
79
+ node->as.heading.level = 1;
76
80
  break;
77
81
 
78
82
  case CMARK_NODE_LIST: {
@@ -98,21 +102,26 @@ static void S_free_nodes(cmark_node *e) {
98
102
  cmark_strbuf_free(&e->string_content);
99
103
  }
100
104
  switch (e->type) {
101
- case NODE_CODE_BLOCK:
105
+ case CMARK_NODE_CODE_BLOCK:
102
106
  cmark_chunk_free(&e->as.code.info);
103
107
  cmark_chunk_free(&e->as.code.literal);
104
108
  break;
105
- case NODE_TEXT:
106
- case NODE_INLINE_HTML:
107
- case NODE_CODE:
108
- case NODE_HTML:
109
+ case CMARK_NODE_TEXT:
110
+ case CMARK_NODE_HTML_INLINE:
111
+ case CMARK_NODE_CODE:
112
+ case CMARK_NODE_HTML_BLOCK:
109
113
  cmark_chunk_free(&e->as.literal);
110
114
  break;
111
- case NODE_LINK:
112
- case NODE_IMAGE:
115
+ case CMARK_NODE_LINK:
116
+ case CMARK_NODE_IMAGE:
113
117
  cmark_chunk_free(&e->as.link.url);
114
118
  cmark_chunk_free(&e->as.link.title);
115
119
  break;
120
+ case CMARK_NODE_CUSTOM_BLOCK:
121
+ case CMARK_NODE_CUSTOM_INLINE:
122
+ cmark_chunk_free(&e->as.custom.on_enter);
123
+ cmark_chunk_free(&e->as.custom.on_exit);
124
+ break;
116
125
  default:
117
126
  break;
118
127
  }
@@ -159,14 +168,16 @@ const char *cmark_node_get_type_string(cmark_node *node) {
159
168
  return "item";
160
169
  case CMARK_NODE_CODE_BLOCK:
161
170
  return "code_block";
162
- case CMARK_NODE_HTML:
163
- return "html";
171
+ case CMARK_NODE_HTML_BLOCK:
172
+ return "html_block";
173
+ case CMARK_NODE_CUSTOM_BLOCK:
174
+ return "raw_block";
164
175
  case CMARK_NODE_PARAGRAPH:
165
176
  return "paragraph";
166
- case CMARK_NODE_HEADER:
167
- return "header";
168
- case CMARK_NODE_HRULE:
169
- return "hrule";
177
+ case CMARK_NODE_HEADING:
178
+ return "heading";
179
+ case CMARK_NODE_THEMATIC_BREAK:
180
+ return "thematic_break";
170
181
  case CMARK_NODE_TEXT:
171
182
  return "text";
172
183
  case CMARK_NODE_SOFTBREAK:
@@ -175,8 +186,10 @@ const char *cmark_node_get_type_string(cmark_node *node) {
175
186
  return "linebreak";
176
187
  case CMARK_NODE_CODE:
177
188
  return "code";
178
- case CMARK_NODE_INLINE_HTML:
179
- return "inline_html";
189
+ case CMARK_NODE_HTML_INLINE:
190
+ return "html_inline";
191
+ case CMARK_NODE_CUSTOM_INLINE:
192
+ return "raw_inline";
180
193
  case CMARK_NODE_EMPH:
181
194
  return "emph";
182
195
  case CMARK_NODE_STRONG:
@@ -252,13 +265,13 @@ const char *cmark_node_get_literal(cmark_node *node) {
252
265
  }
253
266
 
254
267
  switch (node->type) {
255
- case NODE_HTML:
256
- case NODE_TEXT:
257
- case NODE_INLINE_HTML:
258
- case NODE_CODE:
268
+ case CMARK_NODE_HTML_BLOCK:
269
+ case CMARK_NODE_TEXT:
270
+ case CMARK_NODE_HTML_INLINE:
271
+ case CMARK_NODE_CODE:
259
272
  return cmark_chunk_to_cstr(&node->as.literal);
260
273
 
261
- case NODE_CODE_BLOCK:
274
+ case CMARK_NODE_CODE_BLOCK:
262
275
  return cmark_chunk_to_cstr(&node->as.code.literal);
263
276
 
264
277
  default:
@@ -274,14 +287,14 @@ int cmark_node_set_literal(cmark_node *node, const char *content) {
274
287
  }
275
288
 
276
289
  switch (node->type) {
277
- case NODE_HTML:
278
- case NODE_TEXT:
279
- case NODE_INLINE_HTML:
280
- case NODE_CODE:
290
+ case CMARK_NODE_HTML_BLOCK:
291
+ case CMARK_NODE_TEXT:
292
+ case CMARK_NODE_HTML_INLINE:
293
+ case CMARK_NODE_CODE:
281
294
  cmark_chunk_set_cstr(&node->as.literal, content);
282
295
  return 1;
283
296
 
284
- case NODE_CODE_BLOCK:
297
+ case CMARK_NODE_CODE_BLOCK:
285
298
  cmark_chunk_set_cstr(&node->as.code.literal, content);
286
299
  return 1;
287
300
 
@@ -292,14 +305,14 @@ int cmark_node_set_literal(cmark_node *node, const char *content) {
292
305
  return 0;
293
306
  }
294
307
 
295
- int cmark_node_get_header_level(cmark_node *node) {
308
+ int cmark_node_get_heading_level(cmark_node *node) {
296
309
  if (node == NULL) {
297
310
  return 0;
298
311
  }
299
312
 
300
313
  switch (node->type) {
301
- case CMARK_NODE_HEADER:
302
- return node->as.header.level;
314
+ case CMARK_NODE_HEADING:
315
+ return node->as.heading.level;
303
316
 
304
317
  default:
305
318
  break;
@@ -308,14 +321,14 @@ int cmark_node_get_header_level(cmark_node *node) {
308
321
  return 0;
309
322
  }
310
323
 
311
- int cmark_node_set_header_level(cmark_node *node, int level) {
324
+ int cmark_node_set_heading_level(cmark_node *node, int level) {
312
325
  if (node == NULL || level < 1 || level > 6) {
313
326
  return 0;
314
327
  }
315
328
 
316
329
  switch (node->type) {
317
- case CMARK_NODE_HEADER:
318
- node->as.header.level = level;
330
+ case CMARK_NODE_HEADING:
331
+ node->as.heading.level = level;
319
332
  return 1;
320
333
 
321
334
  default:
@@ -438,7 +451,7 @@ const char *cmark_node_get_fence_info(cmark_node *node) {
438
451
  return NULL;
439
452
  }
440
453
 
441
- if (node->type == NODE_CODE_BLOCK) {
454
+ if (node->type == CMARK_NODE_CODE_BLOCK) {
442
455
  return cmark_chunk_to_cstr(&node->as.code.info);
443
456
  } else {
444
457
  return NULL;
@@ -450,7 +463,7 @@ int cmark_node_set_fence_info(cmark_node *node, const char *info) {
450
463
  return 0;
451
464
  }
452
465
 
453
- if (node->type == NODE_CODE_BLOCK) {
466
+ if (node->type == CMARK_NODE_CODE_BLOCK) {
454
467
  cmark_chunk_set_cstr(&node->as.code.info, info);
455
468
  return 1;
456
469
  } else {
@@ -464,8 +477,8 @@ const char *cmark_node_get_url(cmark_node *node) {
464
477
  }
465
478
 
466
479
  switch (node->type) {
467
- case NODE_LINK:
468
- case NODE_IMAGE:
480
+ case CMARK_NODE_LINK:
481
+ case CMARK_NODE_IMAGE:
469
482
  return cmark_chunk_to_cstr(&node->as.link.url);
470
483
  default:
471
484
  break;
@@ -480,8 +493,8 @@ int cmark_node_set_url(cmark_node *node, const char *url) {
480
493
  }
481
494
 
482
495
  switch (node->type) {
483
- case NODE_LINK:
484
- case NODE_IMAGE:
496
+ case CMARK_NODE_LINK:
497
+ case CMARK_NODE_IMAGE:
485
498
  cmark_chunk_set_cstr(&node->as.link.url, url);
486
499
  return 1;
487
500
  default:
@@ -497,8 +510,8 @@ const char *cmark_node_get_title(cmark_node *node) {
497
510
  }
498
511
 
499
512
  switch (node->type) {
500
- case NODE_LINK:
501
- case NODE_IMAGE:
513
+ case CMARK_NODE_LINK:
514
+ case CMARK_NODE_IMAGE:
502
515
  return cmark_chunk_to_cstr(&node->as.link.title);
503
516
  default:
504
517
  break;
@@ -513,8 +526,8 @@ int cmark_node_set_title(cmark_node *node, const char *title) {
513
526
  }
514
527
 
515
528
  switch (node->type) {
516
- case NODE_LINK:
517
- case NODE_IMAGE:
529
+ case CMARK_NODE_LINK:
530
+ case CMARK_NODE_IMAGE:
518
531
  cmark_chunk_set_cstr(&node->as.link.title, title);
519
532
  return 1;
520
533
  default:
@@ -524,6 +537,72 @@ int cmark_node_set_title(cmark_node *node, const char *title) {
524
537
  return 0;
525
538
  }
526
539
 
540
+ const char *cmark_node_get_on_enter(cmark_node *node) {
541
+ if (node == NULL) {
542
+ return NULL;
543
+ }
544
+
545
+ switch (node->type) {
546
+ case CMARK_NODE_CUSTOM_INLINE:
547
+ case CMARK_NODE_CUSTOM_BLOCK:
548
+ return cmark_chunk_to_cstr(&node->as.custom.on_enter);
549
+ default:
550
+ break;
551
+ }
552
+
553
+ return NULL;
554
+ }
555
+
556
+ int cmark_node_set_on_enter(cmark_node *node, const char *on_enter) {
557
+ if (node == NULL) {
558
+ return 0;
559
+ }
560
+
561
+ switch (node->type) {
562
+ case CMARK_NODE_CUSTOM_INLINE:
563
+ case CMARK_NODE_CUSTOM_BLOCK:
564
+ cmark_chunk_set_cstr(&node->as.custom.on_enter, on_enter);
565
+ return 1;
566
+ default:
567
+ break;
568
+ }
569
+
570
+ return 0;
571
+ }
572
+
573
+ const char *cmark_node_get_on_exit(cmark_node *node) {
574
+ if (node == NULL) {
575
+ return NULL;
576
+ }
577
+
578
+ switch (node->type) {
579
+ case CMARK_NODE_CUSTOM_INLINE:
580
+ case CMARK_NODE_CUSTOM_BLOCK:
581
+ return cmark_chunk_to_cstr(&node->as.custom.on_exit);
582
+ default:
583
+ break;
584
+ }
585
+
586
+ return NULL;
587
+ }
588
+
589
+ int cmark_node_set_on_exit(cmark_node *node, const char *on_exit) {
590
+ if (node == NULL) {
591
+ return 0;
592
+ }
593
+
594
+ switch (node->type) {
595
+ case CMARK_NODE_CUSTOM_INLINE:
596
+ case CMARK_NODE_CUSTOM_BLOCK:
597
+ cmark_chunk_set_cstr(&node->as.custom.on_exit, on_exit);
598
+ return 1;
599
+ default:
600
+ break;
601
+ }
602
+
603
+ return 0;
604
+ }
605
+
527
606
  int cmark_node_get_start_line(cmark_node *node) {
528
607
  if (node == NULL) {
529
608
  return 0;