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
@@ -9,7 +9,6 @@ set(HEADERS
9
9
  iterator.h
10
10
  chunk.h
11
11
  references.h
12
- bench.h
13
12
  utf8.h
14
13
  scanners.h
15
14
  inlines.h
@@ -47,6 +46,15 @@ set(PROGRAM_SOURCES
47
46
  main.c
48
47
  )
49
48
 
49
+ # We make LIB_INSTALL_DIR configurable rather than
50
+ # hard-coding lib, because on some OSes different locations
51
+ # are used for different architectures (e.g. /usr/lib64 on
52
+ # 64-bit Fedora).
53
+ if(NOT LIB_INSTALL_DIR)
54
+ set(LIB_INSTALL_DIR "lib" CACHE STRING
55
+ "Set the installation directory for libraries." FORCE)
56
+ endif(NOT LIB_INSTALL_DIR)
57
+
50
58
  include_directories(. ${CMAKE_CURRENT_BINARY_DIR})
51
59
 
52
60
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
@@ -55,7 +63,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmark_version.h.in
55
63
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libcmark.pc.in
56
64
  ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc @ONLY)
57
65
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libcmark.pc
58
- DESTINATION lib/pkgconfig)
66
+ DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
59
67
 
60
68
  include (GenerateExportHeader)
61
69
 
@@ -117,9 +125,10 @@ endif(MSVC)
117
125
 
118
126
  set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON)
119
127
  include (InstallRequiredSystemLibraries)
120
- install(TARGETS ${PROGRAM} ${LIBRARY}
128
+ install(TARGETS ${PROGRAM} ${LIBRARY} ${STATICLIBRARY}
121
129
  RUNTIME DESTINATION bin
122
- LIBRARY DESTINATION lib
130
+ LIBRARY DESTINATION ${LIB_INSTALL_DIR}
131
+ ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
123
132
  )
124
133
 
125
134
  install(FILES
@@ -165,10 +174,6 @@ if(MSVC)
165
174
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /TP")
166
175
  endif()
167
176
 
168
- if($ENV{TIMER})
169
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTIMER=1")
170
- endif($ENV{TIMER})
171
-
172
177
  if(CMAKE_BUILD_TYPE STREQUAL "Ubsan")
173
178
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
174
179
  endif()
@@ -48,7 +48,7 @@ static cmark_node *make_block(cmark_node_type tag, int start_line,
48
48
 
49
49
  // Create a root document node.
50
50
  static cmark_node *make_document() {
51
- cmark_node *e = make_block(NODE_DOCUMENT, 1, 1);
51
+ cmark_node *e = make_block(CMARK_NODE_DOCUMENT, 1, 1);
52
52
  return e;
53
53
  }
54
54
 
@@ -112,14 +112,16 @@ static bool is_blank(cmark_strbuf *s, bufsize_t offset) {
112
112
 
113
113
  static inline bool can_contain(cmark_node_type parent_type,
114
114
  cmark_node_type child_type) {
115
- return (parent_type == NODE_DOCUMENT || parent_type == NODE_BLOCK_QUOTE ||
116
- parent_type == NODE_ITEM ||
117
- (parent_type == NODE_LIST && child_type == NODE_ITEM));
115
+ return (parent_type == CMARK_NODE_DOCUMENT ||
116
+ parent_type == CMARK_NODE_BLOCK_QUOTE ||
117
+ parent_type == CMARK_NODE_ITEM ||
118
+ (parent_type == CMARK_NODE_LIST && child_type == CMARK_NODE_ITEM));
118
119
  }
119
120
 
120
121
  static inline bool accepts_lines(cmark_node_type block_type) {
121
- return (block_type == NODE_PARAGRAPH || block_type == NODE_HEADER ||
122
- block_type == NODE_CODE_BLOCK);
122
+ return (block_type == CMARK_NODE_PARAGRAPH ||
123
+ block_type == CMARK_NODE_HEADING ||
124
+ block_type == CMARK_NODE_CODE_BLOCK);
123
125
  }
124
126
 
125
127
  static void add_line(cmark_node *node, cmark_chunk *ch, bufsize_t offset) {
@@ -162,7 +164,7 @@ static bool ends_with_blank_line(cmark_node *node) {
162
164
  if (cur->last_line_blank) {
163
165
  return true;
164
166
  }
165
- if (cur->type == NODE_LIST || cur->type == NODE_ITEM) {
167
+ if (cur->type == CMARK_NODE_LIST || cur->type == CMARK_NODE_ITEM) {
166
168
  cur = cur->last_child;
167
169
  } else {
168
170
  cur = NULL;
@@ -176,7 +178,7 @@ static int break_out_of_lists(cmark_parser *parser, cmark_node **bptr) {
176
178
  cmark_node *container = *bptr;
177
179
  cmark_node *b = parser->root;
178
180
  // find first containing NODE_LIST:
179
- while (b && b->type != NODE_LIST) {
181
+ while (b && b->type != CMARK_NODE_LIST) {
180
182
  b = b->last_child;
181
183
  }
182
184
  if (b) {
@@ -204,9 +206,9 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
204
206
  // end of input - line number has not been incremented
205
207
  b->end_line = parser->line_number;
206
208
  b->end_column = parser->last_line_length;
207
- } else if (b->type == NODE_DOCUMENT ||
208
- (b->type == NODE_CODE_BLOCK && b->as.code.fenced) ||
209
- (b->type == NODE_HEADER && b->as.header.setext)) {
209
+ } else if (b->type == CMARK_NODE_DOCUMENT ||
210
+ (b->type == CMARK_NODE_CODE_BLOCK && b->as.code.fenced) ||
211
+ (b->type == CMARK_NODE_HEADING && b->as.heading.setext)) {
210
212
  b->end_line = parser->line_number;
211
213
  b->end_column = parser->curline->size;
212
214
  if (b->end_column && parser->curline->ptr[b->end_column - 1] == '\n')
@@ -219,7 +221,7 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
219
221
  }
220
222
 
221
223
  switch (b->type) {
222
- case NODE_PARAGRAPH:
224
+ case CMARK_NODE_PARAGRAPH:
223
225
  while (cmark_strbuf_at(&b->string_content, 0) == '[' &&
224
226
  (pos = cmark_parse_reference_inline(&b->string_content,
225
227
  parser->refmap))) {
@@ -232,7 +234,7 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
232
234
  }
233
235
  break;
234
236
 
235
- case NODE_CODE_BLOCK:
237
+ case CMARK_NODE_CODE_BLOCK:
236
238
  if (!b->as.code.fenced) { // indented code
237
239
  remove_trailing_blank_lines(&b->string_content);
238
240
  cmark_strbuf_putc(&b->string_content, '\n');
@@ -260,11 +262,11 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
260
262
  b->as.code.literal = cmark_chunk_buf_detach(&b->string_content);
261
263
  break;
262
264
 
263
- case NODE_HTML:
265
+ case CMARK_NODE_HTML_BLOCK:
264
266
  b->as.literal = cmark_chunk_buf_detach(&b->string_content);
265
267
  break;
266
268
 
267
- case NODE_LIST: // determine tight/loose status
269
+ case CMARK_NODE_LIST: // determine tight/loose status
268
270
  b->as.list.tight = true; // tight by default
269
271
  item = b->first_child;
270
272
 
@@ -334,7 +336,8 @@ static void process_inlines(cmark_node *root, cmark_reference_map *refmap,
334
336
  while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
335
337
  cur = cmark_iter_get_node(iter);
336
338
  if (ev_type == CMARK_EVENT_ENTER) {
337
- if (cur->type == NODE_PARAGRAPH || cur->type == NODE_HEADER) {
339
+ if (cur->type == CMARK_NODE_PARAGRAPH ||
340
+ cur->type == CMARK_NODE_HEADING) {
338
341
  cmark_parse_inlines(cur, refmap, options);
339
342
  }
340
343
  }
@@ -569,7 +572,7 @@ static void S_advance_offset(cmark_parser *parser, cmark_chunk *input,
569
572
  int chars_to_tab;
570
573
  while (count > 0 && (c = peek_at(input, parser->offset))) {
571
574
  if (c == '\t') {
572
- chars_to_tab = 4 - (parser->column % TAB_STOP);
575
+ chars_to_tab = TAB_STOP - (parser->column % TAB_STOP);
573
576
  parser->column += chars_to_tab;
574
577
  parser->offset += 1;
575
578
  count -= (columns ? chars_to_tab : 1);
@@ -601,7 +604,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
601
604
  }
602
605
  // ensure line ends with a newline:
603
606
  if (bytes == 0 || !S_is_line_end_char(parser->curline->ptr[bytes - 1])) {
604
- cmark_strbuf_putc(parser->curline, '\n');
607
+ cmark_strbuf_putc(parser->curline, '\n');
605
608
  }
606
609
  parser->offset = 0;
607
610
  parser->column = 0;
@@ -623,7 +626,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
623
626
 
624
627
  S_find_first_nonspace(parser, &input);
625
628
 
626
- if (container->type == NODE_BLOCK_QUOTE) {
629
+ if (container->type == CMARK_NODE_BLOCK_QUOTE) {
627
630
  matched =
628
631
  parser->indent <= 3 && peek_at(&input, parser->first_nonspace) == '>';
629
632
  if (matched) {
@@ -634,7 +637,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
634
637
  all_matched = false;
635
638
  }
636
639
 
637
- } else if (container->type == NODE_ITEM) {
640
+ } else if (container->type == CMARK_NODE_ITEM) {
638
641
  if (parser->indent >=
639
642
  container->as.list.marker_offset + container->as.list.padding) {
640
643
  S_advance_offset(parser, &input, container->as.list.marker_offset +
@@ -650,7 +653,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
650
653
  all_matched = false;
651
654
  }
652
655
 
653
- } else if (container->type == NODE_CODE_BLOCK) {
656
+ } else if (container->type == CMARK_NODE_CODE_BLOCK) {
654
657
 
655
658
  if (!container->as.code.fenced) { // indented
656
659
  if (parser->indent >= CODE_INDENT) {
@@ -683,12 +686,12 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
683
686
  }
684
687
  }
685
688
  }
686
- } else if (container->type == NODE_HEADER) {
689
+ } else if (container->type == CMARK_NODE_HEADING) {
687
690
 
688
- // a header can never contain more than one line
691
+ // a heading can never contain more than one line
689
692
  all_matched = false;
690
693
 
691
- } else if (container->type == NODE_HTML) {
694
+ } else if (container->type == CMARK_NODE_HTML_BLOCK) {
692
695
 
693
696
  switch (container->as.html_block_type) {
694
697
  case 1:
@@ -710,7 +713,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
710
713
  exit(1);
711
714
  }
712
715
 
713
- } else if (container->type == NODE_PARAGRAPH) {
716
+ } else if (container->type == CMARK_NODE_PARAGRAPH) {
714
717
 
715
718
  if (parser->blank) {
716
719
  all_matched = false;
@@ -730,9 +733,10 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
730
733
  break_out_of_lists(parser, &container);
731
734
  }
732
735
 
733
- maybe_lazy = parser->current->type == NODE_PARAGRAPH;
736
+ maybe_lazy = parser->current->type == CMARK_NODE_PARAGRAPH;
734
737
  // try new container starts:
735
- while (container->type != NODE_CODE_BLOCK && container->type != NODE_HTML) {
738
+ while (container->type != CMARK_NODE_CODE_BLOCK &&
739
+ container->type != CMARK_NODE_HTML_BLOCK) {
736
740
 
737
741
  S_find_first_nonspace(parser, &input);
738
742
  indented = parser->indent >= CODE_INDENT;
@@ -744,16 +748,17 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
744
748
  // optional following character
745
749
  if (peek_at(&input, parser->offset) == ' ')
746
750
  S_advance_offset(parser, &input, 1, false);
747
- container =
748
- add_child(parser, container, NODE_BLOCK_QUOTE, parser->offset + 1);
751
+ container = add_child(parser, container, CMARK_NODE_BLOCK_QUOTE,
752
+ parser->offset + 1);
749
753
 
750
- } else if (!indented && (matched = scan_atx_header_start(
754
+ } else if (!indented && (matched = scan_atx_heading_start(
751
755
  &input, parser->first_nonspace))) {
752
756
 
753
757
  S_advance_offset(parser, &input,
754
758
  parser->first_nonspace + matched - parser->offset,
755
759
  false);
756
- container = add_child(parser, container, NODE_HEADER, parser->offset + 1);
760
+ container =
761
+ add_child(parser, container, CMARK_NODE_HEADING, parser->offset + 1);
757
762
 
758
763
  bufsize_t hashpos =
759
764
  cmark_chunk_strchr(&input, '#', parser->first_nonspace);
@@ -763,18 +768,19 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
763
768
  level++;
764
769
  hashpos++;
765
770
  }
766
- container->as.header.level = level;
767
- container->as.header.setext = false;
771
+ container->as.heading.level = level;
772
+ container->as.heading.setext = false;
768
773
 
769
774
  } else if (!indented && (matched = scan_open_code_fence(
770
775
  &input, parser->first_nonspace))) {
771
776
 
772
- container = add_child(parser, container, NODE_CODE_BLOCK,
777
+ container = add_child(parser, container, CMARK_NODE_CODE_BLOCK,
773
778
  parser->first_nonspace + 1);
774
779
  container->as.code.fenced = true;
775
780
  container->as.code.fence_char = peek_at(&input, parser->first_nonspace);
776
781
  container->as.code.fence_length = matched;
777
- container->as.code.fence_offset = (int8_t)(parser->first_nonspace - parser->offset);
782
+ container->as.code.fence_offset =
783
+ (int8_t)(parser->first_nonspace - parser->offset);
778
784
  container->as.code.info = cmark_chunk_literal("");
779
785
  S_advance_offset(parser, &input,
780
786
  parser->first_nonspace + matched - parser->offset,
@@ -782,41 +788,42 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
782
788
 
783
789
  } else if (!indented && ((matched = scan_html_block_start(
784
790
  &input, parser->first_nonspace)) ||
785
- (container->type != NODE_PARAGRAPH &&
791
+ (container->type != CMARK_NODE_PARAGRAPH &&
786
792
  (matched = scan_html_block_start_7(
787
793
  &input, parser->first_nonspace))))) {
788
794
 
789
- container =
790
- add_child(parser, container, NODE_HTML, parser->first_nonspace + 1);
795
+ container = add_child(parser, container, CMARK_NODE_HTML_BLOCK,
796
+ parser->first_nonspace + 1);
791
797
  container->as.html_block_type = matched;
792
798
  // note, we don't adjust parser->offset because the tag is part of the
793
799
  // text
794
800
 
795
- } else if (!indented && container->type == NODE_PARAGRAPH &&
801
+ } else if (!indented && container->type == CMARK_NODE_PARAGRAPH &&
796
802
  (lev =
797
- scan_setext_header_line(&input, parser->first_nonspace)) &&
803
+ scan_setext_heading_line(&input, parser->first_nonspace)) &&
798
804
  // check that there is only one line in the paragraph:
799
805
  (cmark_strbuf_strrchr(
800
806
  &container->string_content, '\n',
801
807
  cmark_strbuf_len(&container->string_content) - 2) < 0)) {
802
808
 
803
- container->type = NODE_HEADER;
804
- container->as.header.level = lev;
805
- container->as.header.setext = true;
809
+ container->type = CMARK_NODE_HEADING;
810
+ container->as.heading.level = lev;
811
+ container->as.heading.setext = true;
806
812
  S_advance_offset(parser, &input, input.len - 1 - parser->offset, false);
807
813
 
808
814
  } else if (!indented &&
809
- !(container->type == NODE_PARAGRAPH && !all_matched) &&
810
- (matched = scan_hrule(&input, parser->first_nonspace))) {
815
+ !(container->type == CMARK_NODE_PARAGRAPH && !all_matched) &&
816
+ (matched =
817
+ scan_thematic_break(&input, parser->first_nonspace))) {
811
818
 
812
- // it's only now that we know the line is not part of a setext header:
813
- container =
814
- add_child(parser, container, NODE_HRULE, parser->first_nonspace + 1);
819
+ // it's only now that we know the line is not part of a setext heading:
820
+ container = add_child(parser, container, CMARK_NODE_THEMATIC_BREAK,
821
+ parser->first_nonspace + 1);
815
822
  S_advance_offset(parser, &input, input.len - 1 - parser->offset, false);
816
823
 
817
824
  } else if ((matched =
818
825
  parse_list_marker(&input, parser->first_nonspace, &data)) &&
819
- (!indented || container->type == NODE_LIST)) {
826
+ (!indented || container->type == CMARK_NODE_LIST)) {
820
827
  // Note that we can have new list items starting with >= 4
821
828
  // spaces indent, as long as the list container is still open.
822
829
 
@@ -845,25 +852,25 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
845
852
 
846
853
  data->marker_offset = parser->indent;
847
854
 
848
- if (container->type != NODE_LIST ||
855
+ if (container->type != CMARK_NODE_LIST ||
849
856
  !lists_match(&container->as.list, data)) {
850
- container =
851
- add_child(parser, container, NODE_LIST, parser->first_nonspace + 1);
857
+ container = add_child(parser, container, CMARK_NODE_LIST,
858
+ parser->first_nonspace + 1);
852
859
 
853
860
  memcpy(&container->as.list, data, sizeof(*data));
854
861
  }
855
862
 
856
863
  // add the list item
857
- container =
858
- add_child(parser, container, NODE_ITEM, parser->first_nonspace + 1);
864
+ container = add_child(parser, container, CMARK_NODE_ITEM,
865
+ parser->first_nonspace + 1);
859
866
  /* TODO: static */
860
867
  memcpy(&container->as.list, data, sizeof(*data));
861
868
  free(data);
862
869
 
863
870
  } else if (indented && !maybe_lazy && !parser->blank) {
864
871
  S_advance_offset(parser, &input, CODE_INDENT, true);
865
- container =
866
- add_child(parser, container, NODE_CODE_BLOCK, parser->offset + 1);
872
+ container = add_child(parser, container, CMARK_NODE_CODE_BLOCK,
873
+ parser->offset + 1);
867
874
  container->as.code.fenced = false;
868
875
  container->as.code.fence_char = 0;
869
876
  container->as.code.fence_length = 0;
@@ -895,11 +902,12 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
895
902
  // lists or breaking out of lists. we also don't set last_line_blank
896
903
  // on an empty list item.
897
904
  container->last_line_blank =
898
- (parser->blank && container->type != NODE_BLOCK_QUOTE &&
899
- container->type != NODE_HEADER &&
900
- container->type != NODE_HRULE &&
901
- !(container->type == NODE_CODE_BLOCK && container->as.code.fenced) &&
902
- !(container->type == NODE_ITEM && container->first_child == NULL &&
905
+ (parser->blank && container->type != CMARK_NODE_BLOCK_QUOTE &&
906
+ container->type != CMARK_NODE_HEADING &&
907
+ container->type != CMARK_NODE_THEMATIC_BREAK &&
908
+ !(container->type == CMARK_NODE_CODE_BLOCK &&
909
+ container->as.code.fenced) &&
910
+ !(container->type == CMARK_NODE_ITEM && container->first_child == NULL &&
903
911
  container->start_line == parser->line_number));
904
912
 
905
913
  cmark_node *cont = container;
@@ -910,7 +918,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
910
918
 
911
919
  if (parser->current != last_matched_container &&
912
920
  container == last_matched_container && !parser->blank &&
913
- parser->current->type == NODE_PARAGRAPH &&
921
+ parser->current->type == CMARK_NODE_PARAGRAPH &&
914
922
  cmark_strbuf_len(&parser->current->string_content) > 0) {
915
923
 
916
924
  add_line(parser->current, &input, parser->offset);
@@ -923,11 +931,11 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
923
931
  assert(parser->current != NULL);
924
932
  }
925
933
 
926
- if (container->type == NODE_CODE_BLOCK) {
934
+ if (container->type == CMARK_NODE_CODE_BLOCK) {
927
935
 
928
936
  add_line(container, &input, parser->offset);
929
937
 
930
- } else if (container->type == NODE_HTML) {
938
+ } else if (container->type == CMARK_NODE_HTML_BLOCK) {
931
939
 
932
940
  add_line(container, &input, parser->offset);
933
941
 
@@ -974,15 +982,15 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
974
982
 
975
983
  } else if (accepts_lines(container->type)) {
976
984
 
977
- if (container->type == NODE_HEADER &&
978
- container->as.header.setext == false) {
985
+ if (container->type == CMARK_NODE_HEADING &&
986
+ container->as.heading.setext == false) {
979
987
  chop_trailing_hashtags(&input);
980
988
  }
981
989
  add_line(container, &input, parser->first_nonspace);
982
990
 
983
991
  } else {
984
992
  // create paragraph container for line
985
- container = add_child(parser, container, NODE_PARAGRAPH,
993
+ container = add_child(parser, container, CMARK_NODE_PARAGRAPH,
986
994
  parser->first_nonspace + 1);
987
995
  add_line(container, &input, parser->first_nonspace);
988
996
  }
@@ -990,12 +998,12 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
990
998
  parser->current = container;
991
999
  }
992
1000
  finished:
993
- parser->last_line_length = parser->curline->size;
1001
+ parser->last_line_length = input.len;
994
1002
  if (parser->last_line_length &&
995
- parser->curline->ptr[parser->last_line_length - 1] == '\n')
1003
+ input.data[parser->last_line_length - 1] == '\n')
996
1004
  parser->last_line_length -= 1;
997
1005
  if (parser->last_line_length &&
998
- parser->curline->ptr[parser->last_line_length - 1] == '\r')
1006
+ input.data[parser->last_line_length - 1] == '\r')
999
1007
  parser->last_line_length -= 1;
1000
1008
 
1001
1009
  cmark_strbuf_clear(parser->curline);
@@ -48,8 +48,8 @@ static CMARK_INLINE void cmark_chunk_trim(cmark_chunk *c) {
48
48
  cmark_chunk_rtrim(c);
49
49
  }
50
50
 
51
- static CMARK_INLINE bufsize_t cmark_chunk_strchr(cmark_chunk *ch, int c,
52
- bufsize_t offset) {
51
+ static CMARK_INLINE bufsize_t
52
+ cmark_chunk_strchr(cmark_chunk *ch, int c, bufsize_t offset) {
53
53
  const unsigned char *p =
54
54
  (unsigned char *)memchr(ch->data + offset, c, ch->len - offset);
55
55
  return p ? (bufsize_t)(p - ch->data) : ch->len;
@@ -74,8 +74,7 @@ static CMARK_INLINE const char *cmark_chunk_to_cstr(cmark_chunk *c) {
74
74
  return (char *)str;
75
75
  }
76
76
 
77
- static CMARK_INLINE void
78
- cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
77
+ static CMARK_INLINE void cmark_chunk_set_cstr(cmark_chunk *c, const char *str) {
79
78
  if (c->alloc) {
80
79
  free(c->data);
81
80
  }
@@ -97,9 +96,8 @@ static CMARK_INLINE cmark_chunk cmark_chunk_literal(const char *data) {
97
96
  return c;
98
97
  }
99
98
 
100
- static CMARK_INLINE
101
- cmark_chunk cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos,
102
- bufsize_t len) {
99
+ static CMARK_INLINE cmark_chunk
100
+ cmark_chunk_dup(const cmark_chunk *ch, bufsize_t pos, bufsize_t len) {
103
101
  cmark_chunk c = {ch->data + pos, len, 0};
104
102
  return c;
105
103
  }