commonmarker 0.17.6 → 0.17.7

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 (405) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +0 -7
  3. data/ext/commonmarker/{cmark/src/arena.c → arena.c} +0 -0
  4. data/ext/commonmarker/{cmark/extensions/autolink.c → autolink.c} +0 -0
  5. data/ext/commonmarker/{cmark/extensions/autolink.h → autolink.h} +0 -0
  6. data/ext/commonmarker/{cmark/src/blocks.c → blocks.c} +0 -0
  7. data/ext/commonmarker/{cmark/src/buffer.c → buffer.c} +0 -0
  8. data/ext/commonmarker/{cmark/src/buffer.h → buffer.h} +0 -0
  9. data/ext/commonmarker/{cmark/src/case_fold_switch.inc → case_fold_switch.inc} +0 -0
  10. data/ext/commonmarker/{cmark/src/chunk.h → chunk.h} +0 -0
  11. data/ext/commonmarker/{cmark → cmark-upstream}/CMakeLists.txt +0 -0
  12. data/ext/commonmarker/{cmark → cmark-upstream}/COPYING +0 -0
  13. data/ext/commonmarker/{cmark → cmark-upstream}/FindAsan.cmake +0 -0
  14. data/ext/commonmarker/{cmark → cmark-upstream}/Makefile +0 -0
  15. data/ext/commonmarker/{cmark → cmark-upstream}/Makefile.nmake +0 -0
  16. data/ext/commonmarker/{cmark → cmark-upstream}/README.md +0 -0
  17. data/ext/commonmarker/{cmark → cmark-upstream}/api_test/CMakeLists.txt +0 -0
  18. data/ext/commonmarker/{cmark → cmark-upstream}/api_test/cplusplus.cpp +0 -0
  19. data/ext/commonmarker/{cmark → cmark-upstream}/api_test/cplusplus.h +0 -0
  20. data/ext/commonmarker/{cmark → cmark-upstream}/api_test/harness.c +0 -0
  21. data/ext/commonmarker/{cmark → cmark-upstream}/api_test/harness.h +0 -0
  22. data/ext/commonmarker/{cmark → cmark-upstream}/api_test/main.c +0 -0
  23. data/ext/commonmarker/{cmark → cmark-upstream}/appveyor.yml +0 -0
  24. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-bq-flat.md +0 -0
  25. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-bq-nested.md +0 -0
  26. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-code.md +0 -0
  27. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-fences.md +0 -0
  28. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-heading.md +0 -0
  29. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-hr.md +0 -0
  30. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-html.md +0 -0
  31. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-lheading.md +0 -0
  32. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-list-flat.md +0 -0
  33. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-list-nested.md +0 -0
  34. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-ref-flat.md +0 -0
  35. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/block-ref-nested.md +0 -0
  36. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-autolink.md +0 -0
  37. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-backticks.md +0 -0
  38. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-em-flat.md +0 -0
  39. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-em-nested.md +0 -0
  40. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-em-worst.md +0 -0
  41. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-entity.md +0 -0
  42. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-escape.md +0 -0
  43. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-html.md +0 -0
  44. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-links-flat.md +0 -0
  45. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-links-nested.md +0 -0
  46. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/inline-newlines.md +0 -0
  47. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/lorem1.md +0 -0
  48. data/ext/commonmarker/{cmark → cmark-upstream}/bench/samples/rawtabs.md +0 -0
  49. data/ext/commonmarker/{cmark → cmark-upstream}/bench/statistics.py +0 -0
  50. data/ext/commonmarker/{cmark → cmark-upstream}/bench/stats.py +0 -0
  51. data/ext/commonmarker/{cmark → cmark-upstream}/benchmarks.md +0 -0
  52. data/ext/commonmarker/cmark-upstream/build/CMakeCache.txt +478 -0
  53. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CMakeCCompiler.cmake +71 -0
  54. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CMakeCXXCompiler.cmake +73 -0
  55. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CMakeDetermineCompilerABI_C.bin +0 -0
  56. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CMakeDetermineCompilerABI_CXX.bin +0 -0
  57. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CMakeSystem.cmake +15 -0
  58. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CompilerIdC/CMakeCCompilerId.c +567 -0
  59. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CompilerIdC/a.out +0 -0
  60. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CompilerIdCXX/CMakeCXXCompilerId.cpp +539 -0
  61. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/3.9.6/CompilerIdCXX/a.out +0 -0
  62. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  63. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/CMakeError.log +18 -0
  64. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/CMakeOutput.log +709 -0
  65. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/Makefile.cmake +157 -0
  66. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/Makefile2 +391 -0
  67. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/TargetDirectories.txt +48 -0
  68. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/cmake.check_cache +1 -0
  69. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/feature_tests.bin +0 -0
  70. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/feature_tests.c +34 -0
  71. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/feature_tests.cxx +405 -0
  72. data/ext/commonmarker/cmark-upstream/build/CMakeFiles/progress.marks +1 -0
  73. data/ext/commonmarker/cmark-upstream/build/CTestTestfile.cmake +11 -0
  74. data/ext/commonmarker/cmark-upstream/build/Makefile +280 -0
  75. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  76. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/C.includecache +134 -0
  77. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/CXX.includecache +38 -0
  78. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake +38 -0
  79. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/build.make +169 -0
  80. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake +12 -0
  81. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/cplusplus.cpp.o +0 -0
  82. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/depend.internal +28 -0
  83. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/depend.make +28 -0
  84. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/flags.make +17 -0
  85. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/harness.c.o +0 -0
  86. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -0
  87. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/main.c.o +0 -0
  88. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/api_test.dir/progress.make +5 -0
  89. data/ext/commonmarker/cmark-upstream/build/api_test/CMakeFiles/progress.marks +1 -0
  90. data/ext/commonmarker/cmark-upstream/build/api_test/Makefile +302 -0
  91. data/ext/commonmarker/cmark-upstream/build/api_test/api_test +0 -0
  92. data/ext/commonmarker/cmark-upstream/build/api_test/cmake_install.cmake +29 -0
  93. data/ext/commonmarker/cmark-upstream/build/cmake_install.cmake +49 -0
  94. data/ext/commonmarker/cmark-upstream/build/compile_commands.json +352 -0
  95. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  96. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/Export/lib/cmake-gfmextensions/cmark-gfmextensions-release.cmake +30 -0
  97. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/Export/lib/cmake-gfmextensions/cmark-gfmextensions.cmake +108 -0
  98. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/C.includecache +246 -0
  99. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/DependInfo.cmake +36 -0
  100. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/autolink.c.o +0 -0
  101. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/build.make +253 -0
  102. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/cmake_clean.cmake +16 -0
  103. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/core-extensions.c.o +0 -0
  104. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/depend.internal +96 -0
  105. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/depend.make +96 -0
  106. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/ext_scanners.c.o +0 -0
  107. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/flags.make +10 -0
  108. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/link.txt +1 -0
  109. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/progress.make +8 -0
  110. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/strikethrough.c.o +0 -0
  111. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/table.c.o +0 -0
  112. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions.dir/tagfilter.c.o +0 -0
  113. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/C.includecache +246 -0
  114. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/DependInfo.cmake +29 -0
  115. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/autolink.c.o +0 -0
  116. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/build.make +249 -0
  117. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/cmake_clean.cmake +15 -0
  118. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/cmake_clean_target.cmake +3 -0
  119. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/core-extensions.c.o +0 -0
  120. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/depend.internal +96 -0
  121. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/depend.make +96 -0
  122. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/ext_scanners.c.o +0 -0
  123. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/flags.make +10 -0
  124. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/link.txt +2 -0
  125. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/progress.make +8 -0
  126. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/strikethrough.c.o +0 -0
  127. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/table.c.o +0 -0
  128. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/libcmark-gfmextensions_static.dir/tagfilter.c.o +0 -0
  129. data/ext/commonmarker/cmark-upstream/build/extensions/CMakeFiles/progress.marks +1 -0
  130. data/ext/commonmarker/cmark-upstream/build/extensions/Makefile +426 -0
  131. data/ext/commonmarker/cmark-upstream/build/extensions/cmake_install.cmake +84 -0
  132. data/ext/commonmarker/cmark-upstream/build/extensions/cmarkextensions_export.h +42 -0
  133. data/ext/commonmarker/cmark-upstream/build/extensions/libcmark-gfmextensions.0.28.3.gfm.11.dylib +0 -0
  134. data/ext/commonmarker/cmark-upstream/build/extensions/libcmark-gfmextensions.a +0 -0
  135. data/ext/commonmarker/cmark-upstream/build/extensions/libcmark-gfmextensions.dylib +1 -0
  136. data/ext/commonmarker/cmark-upstream/build/man/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  137. data/ext/commonmarker/cmark-upstream/build/man/CMakeFiles/progress.marks +1 -0
  138. data/ext/commonmarker/cmark-upstream/build/man/Makefile +196 -0
  139. data/ext/commonmarker/cmark-upstream/build/man/cmake_install.cmake +37 -0
  140. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  141. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/Export/lib/cmake/cmark-gfm-release.cmake +38 -0
  142. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/Export/lib/cmake/cmark-gfm.cmake +95 -0
  143. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/C.includecache +156 -0
  144. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/DependInfo.cmake +30 -0
  145. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/build.make +115 -0
  146. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/cmake_clean.cmake +10 -0
  147. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/depend.internal +20 -0
  148. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/depend.make +20 -0
  149. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/flags.make +10 -0
  150. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/link.txt +1 -0
  151. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/main.c.o +0 -0
  152. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/cmark-gfm.dir/progress.make +3 -0
  153. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/C.includecache +612 -0
  154. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/DependInfo.cmake +60 -0
  155. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/arena.c.o +0 -0
  156. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/blocks.c.o +0 -0
  157. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/buffer.c.o +0 -0
  158. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/build.make +819 -0
  159. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/cmake_clean.cmake +37 -0
  160. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/cmark.c.o +0 -0
  161. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/cmark_ctype.c.o +0 -0
  162. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/commonmark.c.o +0 -0
  163. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/depend.internal +319 -0
  164. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/depend.make +319 -0
  165. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/flags.make +10 -0
  166. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/footnotes.c.o +0 -0
  167. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/houdini_href_e.c.o +0 -0
  168. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/houdini_html_e.c.o +0 -0
  169. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/houdini_html_u.c.o +0 -0
  170. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/html.c.o +0 -0
  171. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/inlines.c.o +0 -0
  172. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/iterator.c.o +0 -0
  173. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/latex.c.o +0 -0
  174. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/link.txt +1 -0
  175. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/linked_list.c.o +0 -0
  176. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/man.c.o +0 -0
  177. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/map.c.o +0 -0
  178. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/node.c.o +0 -0
  179. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/plaintext.c.o +0 -0
  180. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/plugin.c.o +0 -0
  181. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/progress.make +29 -0
  182. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/references.c.o +0 -0
  183. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/registry.c.o +0 -0
  184. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/render.c.o +0 -0
  185. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/scanners.c.o +0 -0
  186. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/syntax_extension.c.o +0 -0
  187. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/utf8.c.o +0 -0
  188. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm.dir/xml.c.o +0 -0
  189. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/C.includecache +612 -0
  190. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/DependInfo.cmake +54 -0
  191. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/arena.c.o +0 -0
  192. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/blocks.c.o +0 -0
  193. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/buffer.c.o +0 -0
  194. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/build.make +816 -0
  195. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/cmake_clean.cmake +36 -0
  196. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/cmake_clean_target.cmake +3 -0
  197. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/cmark.c.o +0 -0
  198. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/cmark_ctype.c.o +0 -0
  199. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/commonmark.c.o +0 -0
  200. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/depend.internal +319 -0
  201. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/depend.make +319 -0
  202. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/flags.make +10 -0
  203. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/footnotes.c.o +0 -0
  204. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/houdini_href_e.c.o +0 -0
  205. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/houdini_html_e.c.o +0 -0
  206. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/houdini_html_u.c.o +0 -0
  207. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/html.c.o +0 -0
  208. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/inlines.c.o +0 -0
  209. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/iterator.c.o +0 -0
  210. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/latex.c.o +0 -0
  211. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/link.txt +2 -0
  212. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/linked_list.c.o +0 -0
  213. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/man.c.o +0 -0
  214. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/map.c.o +0 -0
  215. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/node.c.o +0 -0
  216. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/plaintext.c.o +0 -0
  217. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/plugin.c.o +0 -0
  218. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/progress.make +29 -0
  219. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/references.c.o +0 -0
  220. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/registry.c.o +0 -0
  221. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/render.c.o +0 -0
  222. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/scanners.c.o +0 -0
  223. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/syntax_extension.c.o +0 -0
  224. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/utf8.c.o +0 -0
  225. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/libcmark-gfm_static.dir/xml.c.o +0 -0
  226. data/ext/commonmarker/cmark-upstream/build/src/CMakeFiles/progress.marks +1 -0
  227. data/ext/commonmarker/cmark-upstream/build/src/Makefile +1165 -0
  228. data/ext/commonmarker/cmark-upstream/build/src/cmake_install.cmake +97 -0
  229. data/ext/commonmarker/cmark-upstream/build/src/cmark-gfm +0 -0
  230. data/ext/commonmarker/cmark-upstream/build/src/cmark_export.h +42 -0
  231. data/ext/commonmarker/cmark-upstream/build/src/cmark_version.h +8 -0
  232. data/ext/commonmarker/cmark-upstream/build/src/config.h +76 -0
  233. data/ext/commonmarker/cmark-upstream/build/src/libcmark-gfm.0.28.3.gfm.11.dylib +0 -0
  234. data/ext/commonmarker/cmark-upstream/build/src/libcmark-gfm.a +0 -0
  235. data/ext/commonmarker/cmark-upstream/build/src/libcmark-gfm.dylib +1 -0
  236. data/ext/commonmarker/cmark-upstream/build/src/libcmark-gfm.pc +10 -0
  237. data/ext/commonmarker/cmark-upstream/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  238. data/ext/commonmarker/cmark-upstream/build/testdir/CMakeFiles/progress.marks +1 -0
  239. data/ext/commonmarker/cmark-upstream/build/testdir/CTestTestfile.cmake +17 -0
  240. data/ext/commonmarker/cmark-upstream/build/testdir/Makefile +196 -0
  241. data/ext/commonmarker/cmark-upstream/build/testdir/cmake_install.cmake +29 -0
  242. data/ext/commonmarker/{cmark → cmark-upstream}/changelog.txt +0 -0
  243. data/ext/commonmarker/{cmark → cmark-upstream}/data/CaseFolding.txt +0 -0
  244. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/CMakeLists.txt +0 -0
  245. data/ext/commonmarker/cmark-upstream/extensions/autolink.c +421 -0
  246. data/ext/commonmarker/cmark-upstream/extensions/autolink.h +8 -0
  247. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/core-extensions.c +0 -0
  248. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/core-extensions.h +0 -0
  249. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/ext_scanners.c +0 -0
  250. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/ext_scanners.h +0 -0
  251. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/ext_scanners.re +0 -0
  252. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/strikethrough.c +0 -0
  253. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/strikethrough.h +0 -0
  254. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/table.c +0 -0
  255. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/table.h +0 -0
  256. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/tagfilter.c +0 -0
  257. data/ext/commonmarker/{cmark → cmark-upstream}/extensions/tagfilter.h +0 -0
  258. data/ext/commonmarker/{cmark → cmark-upstream}/man/CMakeLists.txt +0 -0
  259. data/ext/commonmarker/{cmark → cmark-upstream}/man/make_man_page.py +0 -0
  260. data/ext/commonmarker/{cmark → cmark-upstream}/man/man1/cmark-gfm.1 +0 -0
  261. data/ext/commonmarker/{cmark → cmark-upstream}/man/man3/cmark-gfm.3 +0 -0
  262. data/ext/commonmarker/{cmark → cmark-upstream}/nmake.bat +0 -0
  263. data/ext/commonmarker/{cmark → cmark-upstream}/src/CMakeLists.txt +0 -0
  264. data/ext/commonmarker/cmark-upstream/src/arena.c +103 -0
  265. data/ext/commonmarker/cmark-upstream/src/blocks.c +1519 -0
  266. data/ext/commonmarker/cmark-upstream/src/buffer.c +279 -0
  267. data/ext/commonmarker/cmark-upstream/src/buffer.h +116 -0
  268. data/ext/commonmarker/cmark-upstream/src/case_fold_switch.inc +4327 -0
  269. data/ext/commonmarker/cmark-upstream/src/chunk.h +136 -0
  270. data/ext/commonmarker/{cmark → cmark-upstream}/src/cmark.c +0 -0
  271. data/ext/commonmarker/{cmark → cmark-upstream}/src/cmark.h +0 -0
  272. data/ext/commonmarker/{cmark → cmark-upstream}/src/cmark_ctype.c +0 -0
  273. data/ext/commonmarker/{cmark → cmark-upstream}/src/cmark_ctype.h +0 -0
  274. data/ext/commonmarker/{cmark → cmark-upstream}/src/cmark_extension_api.h +0 -0
  275. data/ext/commonmarker/{cmark → cmark-upstream}/src/cmark_version.h.in +0 -0
  276. data/ext/commonmarker/{cmark → cmark-upstream}/src/commonmark.c +0 -0
  277. data/ext/commonmarker/{cmark → cmark-upstream}/src/config.h.in +0 -0
  278. data/ext/commonmarker/{cmark → cmark-upstream}/src/entities.inc +0 -0
  279. data/ext/commonmarker/{cmark → cmark-upstream}/src/footnotes.c +0 -0
  280. data/ext/commonmarker/{cmark → cmark-upstream}/src/footnotes.h +0 -0
  281. data/ext/commonmarker/{cmark → cmark-upstream}/src/houdini.h +0 -0
  282. data/ext/commonmarker/{cmark → cmark-upstream}/src/houdini_href_e.c +0 -0
  283. data/ext/commonmarker/{cmark → cmark-upstream}/src/houdini_html_e.c +0 -0
  284. data/ext/commonmarker/{cmark → cmark-upstream}/src/houdini_html_u.c +0 -0
  285. data/ext/commonmarker/{cmark → cmark-upstream}/src/html.c +0 -0
  286. data/ext/commonmarker/{cmark → cmark-upstream}/src/html.h +0 -0
  287. data/ext/commonmarker/{cmark → cmark-upstream}/src/inlines.c +8 -4
  288. data/ext/commonmarker/{cmark → cmark-upstream}/src/inlines.h +0 -0
  289. data/ext/commonmarker/{cmark → cmark-upstream}/src/iterator.c +0 -0
  290. data/ext/commonmarker/{cmark → cmark-upstream}/src/iterator.h +0 -0
  291. data/ext/commonmarker/{cmark → cmark-upstream}/src/latex.c +0 -0
  292. data/ext/commonmarker/{cmark → cmark-upstream}/src/libcmark-gfm.pc.in +0 -0
  293. data/ext/commonmarker/{cmark → cmark-upstream}/src/linked_list.c +0 -0
  294. data/ext/commonmarker/{cmark → cmark-upstream}/src/main.c +0 -0
  295. data/ext/commonmarker/{cmark → cmark-upstream}/src/man.c +0 -0
  296. data/ext/commonmarker/{cmark → cmark-upstream}/src/map.c +0 -0
  297. data/ext/commonmarker/{cmark → cmark-upstream}/src/map.h +0 -0
  298. data/ext/commonmarker/{cmark → cmark-upstream}/src/node.c +0 -0
  299. data/ext/commonmarker/{cmark → cmark-upstream}/src/node.h +0 -0
  300. data/ext/commonmarker/{cmark → cmark-upstream}/src/parser.h +0 -0
  301. data/ext/commonmarker/{cmark → cmark-upstream}/src/plaintext.c +0 -0
  302. data/ext/commonmarker/{cmark → cmark-upstream}/src/plugin.c +0 -0
  303. data/ext/commonmarker/{cmark → cmark-upstream}/src/plugin.h +0 -0
  304. data/ext/commonmarker/{cmark → cmark-upstream}/src/references.c +0 -0
  305. data/ext/commonmarker/{cmark → cmark-upstream}/src/references.h +0 -0
  306. data/ext/commonmarker/{cmark → cmark-upstream}/src/registry.c +0 -0
  307. data/ext/commonmarker/{cmark → cmark-upstream}/src/registry.h +0 -0
  308. data/ext/commonmarker/{cmark → cmark-upstream}/src/render.c +0 -0
  309. data/ext/commonmarker/{cmark → cmark-upstream}/src/render.h +0 -0
  310. data/ext/commonmarker/{cmark → cmark-upstream}/src/scanners.c +0 -0
  311. data/ext/commonmarker/{cmark → cmark-upstream}/src/scanners.h +0 -0
  312. data/ext/commonmarker/{cmark → cmark-upstream}/src/scanners.re +0 -0
  313. data/ext/commonmarker/{cmark → cmark-upstream}/src/syntax_extension.c +0 -0
  314. data/ext/commonmarker/{cmark → cmark-upstream}/src/syntax_extension.h +0 -0
  315. data/ext/commonmarker/{cmark → cmark-upstream}/src/utf8.c +0 -0
  316. data/ext/commonmarker/{cmark → cmark-upstream}/src/utf8.h +0 -0
  317. data/ext/commonmarker/{cmark → cmark-upstream}/src/xml.c +0 -0
  318. data/ext/commonmarker/{cmark → cmark-upstream}/suppressions +0 -0
  319. data/ext/commonmarker/{cmark → cmark-upstream}/test/CMakeLists.txt +0 -0
  320. data/ext/commonmarker/{cmark → cmark-upstream}/test/afl_test_cases/test.md +0 -0
  321. data/ext/commonmarker/{cmark → cmark-upstream}/test/cmark-fuzz.c +0 -0
  322. data/ext/commonmarker/{cmark → cmark-upstream}/test/cmark.py +0 -0
  323. data/ext/commonmarker/{cmark → cmark-upstream}/test/entity_tests.py +0 -0
  324. data/ext/commonmarker/{cmark → cmark-upstream}/test/extensions.txt +2 -2
  325. data/ext/commonmarker/{cmark → cmark-upstream}/test/fuzzing_dictionary +0 -0
  326. data/ext/commonmarker/{cmark → cmark-upstream}/test/normalize.py +0 -0
  327. data/ext/commonmarker/{cmark → cmark-upstream}/test/pathological_tests.py +0 -0
  328. data/ext/commonmarker/{cmark → cmark-upstream}/test/regression.txt +0 -0
  329. data/ext/commonmarker/{cmark → cmark-upstream}/test/roundtrip_tests.py +0 -0
  330. data/ext/commonmarker/{cmark → cmark-upstream}/test/run-cmark-fuzz +0 -0
  331. data/ext/commonmarker/{cmark → cmark-upstream}/test/smart_punct.txt +0 -0
  332. data/ext/commonmarker/{cmark → cmark-upstream}/test/spec.txt +0 -0
  333. data/ext/commonmarker/{cmark → cmark-upstream}/test/spec_tests.py +0 -0
  334. data/ext/commonmarker/{cmark → cmark-upstream}/toolchain-mingw32.cmake +0 -0
  335. data/ext/commonmarker/{cmark → cmark-upstream}/tools/Dockerfile +0 -0
  336. data/ext/commonmarker/{cmark → cmark-upstream}/tools/appveyor-build.bat +0 -0
  337. data/ext/commonmarker/{cmark → cmark-upstream}/tools/make_entities_inc.py +0 -0
  338. data/ext/commonmarker/{cmark → cmark-upstream}/tools/mkcasefold.pl +0 -0
  339. data/ext/commonmarker/{cmark → cmark-upstream}/why-cmark-and-not-x.md +0 -0
  340. data/ext/commonmarker/{cmark → cmark-upstream}/wrappers/wrapper.js +0 -0
  341. data/ext/commonmarker/{cmark → cmark-upstream}/wrappers/wrapper.py +0 -0
  342. data/ext/commonmarker/{cmark → cmark-upstream}/wrappers/wrapper.rb +0 -0
  343. data/ext/commonmarker/{cmark → cmark-upstream}/wrappers/wrapper.rkt +0 -0
  344. data/ext/commonmarker/cmark.c +55 -0
  345. data/ext/commonmarker/cmark.h +789 -0
  346. data/ext/commonmarker/cmark_ctype.c +44 -0
  347. data/ext/commonmarker/cmark_ctype.h +33 -0
  348. data/ext/commonmarker/cmark_export.h +42 -0
  349. data/ext/commonmarker/cmark_extension_api.h +719 -0
  350. data/ext/commonmarker/cmark_version.h +8 -0
  351. data/ext/commonmarker/cmarkextensions_export.h +42 -0
  352. data/ext/commonmarker/commonmark.c +508 -0
  353. data/ext/commonmarker/config.h +76 -0
  354. data/ext/commonmarker/core-extensions.c +25 -0
  355. data/ext/commonmarker/core-extensions.h +25 -0
  356. data/ext/commonmarker/entities.inc +2138 -0
  357. data/ext/commonmarker/ext_scanners.c +941 -0
  358. data/ext/commonmarker/ext_scanners.h +22 -0
  359. data/ext/commonmarker/extconf.rb +1 -48
  360. data/ext/commonmarker/footnotes.c +40 -0
  361. data/ext/commonmarker/footnotes.h +25 -0
  362. data/ext/commonmarker/houdini.h +57 -0
  363. data/ext/commonmarker/houdini_href_e.c +100 -0
  364. data/ext/commonmarker/houdini_html_e.c +66 -0
  365. data/ext/commonmarker/houdini_html_u.c +149 -0
  366. data/ext/commonmarker/html.c +457 -0
  367. data/ext/commonmarker/html.h +27 -0
  368. data/ext/commonmarker/inlines.c +1594 -0
  369. data/ext/commonmarker/inlines.h +29 -0
  370. data/ext/commonmarker/iterator.c +159 -0
  371. data/ext/commonmarker/iterator.h +27 -0
  372. data/ext/commonmarker/latex.c +466 -0
  373. data/ext/commonmarker/linked_list.c +37 -0
  374. data/ext/commonmarker/man.c +278 -0
  375. data/ext/commonmarker/map.c +122 -0
  376. data/ext/commonmarker/map.h +42 -0
  377. data/ext/commonmarker/node.c +965 -0
  378. data/ext/commonmarker/node.h +116 -0
  379. data/ext/commonmarker/parser.h +57 -0
  380. data/ext/commonmarker/plaintext.c +213 -0
  381. data/ext/commonmarker/plugin.c +36 -0
  382. data/ext/commonmarker/plugin.h +34 -0
  383. data/ext/commonmarker/references.c +42 -0
  384. data/ext/commonmarker/references.h +26 -0
  385. data/ext/commonmarker/registry.c +63 -0
  386. data/ext/commonmarker/registry.h +24 -0
  387. data/ext/commonmarker/render.c +202 -0
  388. data/ext/commonmarker/render.h +63 -0
  389. data/ext/commonmarker/scanners.c +18195 -0
  390. data/ext/commonmarker/scanners.h +64 -0
  391. data/ext/commonmarker/scanners.re +341 -0
  392. data/ext/commonmarker/strikethrough.c +157 -0
  393. data/ext/commonmarker/strikethrough.h +9 -0
  394. data/ext/commonmarker/syntax_extension.c +139 -0
  395. data/ext/commonmarker/syntax_extension.h +32 -0
  396. data/ext/commonmarker/table.c +683 -0
  397. data/ext/commonmarker/table.h +8 -0
  398. data/ext/commonmarker/tagfilter.c +60 -0
  399. data/ext/commonmarker/tagfilter.h +8 -0
  400. data/ext/commonmarker/utf8.c +317 -0
  401. data/ext/commonmarker/utf8.h +35 -0
  402. data/ext/commonmarker/xml.c +174 -0
  403. data/lib/commonmarker/version.rb +1 -1
  404. data/test/test_helper.rb +1 -1
  405. metadata +401 -145
@@ -0,0 +1,965 @@
1
+ #include <stdlib.h>
2
+ #include <string.h>
3
+
4
+ #include "config.h"
5
+ #include "node.h"
6
+ #include "syntax_extension.h"
7
+
8
+ static void S_node_unlink(cmark_node *node);
9
+
10
+ #define NODE_MEM(node) cmark_node_mem(node)
11
+
12
+ bool cmark_node_can_contain_type(cmark_node *node, cmark_node_type child_type) {
13
+ if (child_type == CMARK_NODE_DOCUMENT) {
14
+ return false;
15
+ }
16
+
17
+ if (node->extension && node->extension->can_contain_func) {
18
+ return node->extension->can_contain_func(node->extension, node, child_type) != 0;
19
+ }
20
+
21
+ switch (node->type) {
22
+ case CMARK_NODE_DOCUMENT:
23
+ case CMARK_NODE_BLOCK_QUOTE:
24
+ case CMARK_NODE_FOOTNOTE_DEFINITION:
25
+ case CMARK_NODE_ITEM:
26
+ return CMARK_NODE_TYPE_BLOCK_P(child_type) && child_type != CMARK_NODE_ITEM;
27
+
28
+ case CMARK_NODE_LIST:
29
+ return child_type == CMARK_NODE_ITEM;
30
+
31
+ case CMARK_NODE_CUSTOM_BLOCK:
32
+ return true;
33
+
34
+ case CMARK_NODE_PARAGRAPH:
35
+ case CMARK_NODE_HEADING:
36
+ case CMARK_NODE_EMPH:
37
+ case CMARK_NODE_STRONG:
38
+ case CMARK_NODE_LINK:
39
+ case CMARK_NODE_IMAGE:
40
+ case CMARK_NODE_CUSTOM_INLINE:
41
+ return CMARK_NODE_TYPE_INLINE_P(child_type);
42
+
43
+ default:
44
+ break;
45
+ }
46
+
47
+ return false;
48
+ }
49
+
50
+ static bool S_can_contain(cmark_node *node, cmark_node *child) {
51
+ cmark_node *cur;
52
+
53
+ if (node == NULL || child == NULL) {
54
+ return false;
55
+ }
56
+ if (NODE_MEM(node) != NODE_MEM(child)) {
57
+ return 0;
58
+ }
59
+
60
+ // Verify that child is not an ancestor of node or equal to node.
61
+ cur = node;
62
+ do {
63
+ if (cur == child) {
64
+ return false;
65
+ }
66
+ cur = cur->parent;
67
+ } while (cur != NULL);
68
+
69
+ return cmark_node_can_contain_type(node, (cmark_node_type) child->type);
70
+ }
71
+
72
+ cmark_node *cmark_node_new_with_mem(cmark_node_type type, cmark_mem *mem) {
73
+ cmark_node *node = (cmark_node *)mem->calloc(1, sizeof(*node));
74
+ cmark_strbuf_init(mem, &node->content, 0);
75
+ node->type = (uint16_t)type;
76
+
77
+ switch (node->type) {
78
+ case CMARK_NODE_HEADING:
79
+ node->as.heading.level = 1;
80
+ break;
81
+
82
+ case CMARK_NODE_LIST: {
83
+ cmark_list *list = &node->as.list;
84
+ list->list_type = CMARK_BULLET_LIST;
85
+ list->start = 0;
86
+ list->tight = false;
87
+ break;
88
+ }
89
+
90
+ default:
91
+ break;
92
+ }
93
+
94
+ return node;
95
+ }
96
+
97
+ cmark_node *cmark_node_new(cmark_node_type type) {
98
+ extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;
99
+ return cmark_node_new_with_mem(type, &CMARK_DEFAULT_MEM_ALLOCATOR);
100
+ }
101
+
102
+ static void free_node_as(cmark_node *node) {
103
+ switch (node->type) {
104
+ case CMARK_NODE_CODE_BLOCK:
105
+ cmark_chunk_free(NODE_MEM(node), &node->as.code.info);
106
+ cmark_chunk_free(NODE_MEM(node), &node->as.code.literal);
107
+ break;
108
+ case CMARK_NODE_TEXT:
109
+ case CMARK_NODE_HTML_INLINE:
110
+ case CMARK_NODE_CODE:
111
+ case CMARK_NODE_HTML_BLOCK:
112
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
113
+ case CMARK_NODE_FOOTNOTE_DEFINITION:
114
+ cmark_chunk_free(NODE_MEM(node), &node->as.literal);
115
+ break;
116
+ case CMARK_NODE_LINK:
117
+ case CMARK_NODE_IMAGE:
118
+ cmark_chunk_free(NODE_MEM(node), &node->as.link.url);
119
+ cmark_chunk_free(NODE_MEM(node), &node->as.link.title);
120
+ break;
121
+ case CMARK_NODE_CUSTOM_BLOCK:
122
+ case CMARK_NODE_CUSTOM_INLINE:
123
+ cmark_chunk_free(NODE_MEM(node), &node->as.custom.on_enter);
124
+ cmark_chunk_free(NODE_MEM(node), &node->as.custom.on_exit);
125
+ break;
126
+ default:
127
+ break;
128
+ }
129
+ }
130
+
131
+ // Free a cmark_node list and any children.
132
+ static void S_free_nodes(cmark_node *e) {
133
+ cmark_node *next;
134
+ while (e != NULL) {
135
+ cmark_strbuf_free(&e->content);
136
+
137
+ if (e->user_data && e->user_data_free_func)
138
+ e->user_data_free_func(NODE_MEM(e), e->user_data);
139
+
140
+ if (e->as.opaque && e->extension && e->extension->opaque_free_func)
141
+ e->extension->opaque_free_func(e->extension, NODE_MEM(e), e);
142
+
143
+ free_node_as(e);
144
+
145
+ if (e->last_child) {
146
+ // Splice children into list
147
+ e->last_child->next = e->next;
148
+ e->next = e->first_child;
149
+ }
150
+ next = e->next;
151
+ NODE_MEM(e)->free(e);
152
+ e = next;
153
+ }
154
+ }
155
+
156
+ void cmark_node_free(cmark_node *node) {
157
+ S_node_unlink(node);
158
+ node->next = NULL;
159
+ S_free_nodes(node);
160
+ }
161
+
162
+ cmark_node_type cmark_node_get_type(cmark_node *node) {
163
+ if (node == NULL) {
164
+ return CMARK_NODE_NONE;
165
+ } else {
166
+ return (cmark_node_type)node->type;
167
+ }
168
+ }
169
+
170
+ int cmark_node_set_type(cmark_node * node, cmark_node_type type) {
171
+ cmark_node_type initial_type;
172
+
173
+ if (type == node->type)
174
+ return 1;
175
+
176
+ initial_type = (cmark_node_type) node->type;
177
+ node->type = (uint16_t)type;
178
+
179
+ if (!S_can_contain(node->parent, node)) {
180
+ node->type = (uint16_t)initial_type;
181
+ return 0;
182
+ }
183
+
184
+ /* We rollback the type to free the union members appropriately */
185
+ node->type = (uint16_t)initial_type;
186
+ free_node_as(node);
187
+
188
+ node->type = (uint16_t)type;
189
+
190
+ return 1;
191
+ }
192
+
193
+ const char *cmark_node_get_type_string(cmark_node *node) {
194
+ if (node == NULL) {
195
+ return "NONE";
196
+ }
197
+
198
+ if (node->extension && node->extension->get_type_string_func) {
199
+ return node->extension->get_type_string_func(node->extension, node);
200
+ }
201
+
202
+ switch (node->type) {
203
+ case CMARK_NODE_NONE:
204
+ return "none";
205
+ case CMARK_NODE_DOCUMENT:
206
+ return "document";
207
+ case CMARK_NODE_BLOCK_QUOTE:
208
+ return "block_quote";
209
+ case CMARK_NODE_LIST:
210
+ return "list";
211
+ case CMARK_NODE_ITEM:
212
+ return "item";
213
+ case CMARK_NODE_CODE_BLOCK:
214
+ return "code_block";
215
+ case CMARK_NODE_HTML_BLOCK:
216
+ return "html_block";
217
+ case CMARK_NODE_CUSTOM_BLOCK:
218
+ return "custom_block";
219
+ case CMARK_NODE_PARAGRAPH:
220
+ return "paragraph";
221
+ case CMARK_NODE_HEADING:
222
+ return "heading";
223
+ case CMARK_NODE_THEMATIC_BREAK:
224
+ return "thematic_break";
225
+ case CMARK_NODE_TEXT:
226
+ return "text";
227
+ case CMARK_NODE_SOFTBREAK:
228
+ return "softbreak";
229
+ case CMARK_NODE_LINEBREAK:
230
+ return "linebreak";
231
+ case CMARK_NODE_CODE:
232
+ return "code";
233
+ case CMARK_NODE_HTML_INLINE:
234
+ return "html_inline";
235
+ case CMARK_NODE_CUSTOM_INLINE:
236
+ return "custom_inline";
237
+ case CMARK_NODE_EMPH:
238
+ return "emph";
239
+ case CMARK_NODE_STRONG:
240
+ return "strong";
241
+ case CMARK_NODE_LINK:
242
+ return "link";
243
+ case CMARK_NODE_IMAGE:
244
+ return "image";
245
+ }
246
+
247
+ return "<unknown>";
248
+ }
249
+
250
+ cmark_node *cmark_node_next(cmark_node *node) {
251
+ if (node == NULL) {
252
+ return NULL;
253
+ } else {
254
+ return node->next;
255
+ }
256
+ }
257
+
258
+ cmark_node *cmark_node_previous(cmark_node *node) {
259
+ if (node == NULL) {
260
+ return NULL;
261
+ } else {
262
+ return node->prev;
263
+ }
264
+ }
265
+
266
+ cmark_node *cmark_node_parent(cmark_node *node) {
267
+ if (node == NULL) {
268
+ return NULL;
269
+ } else {
270
+ return node->parent;
271
+ }
272
+ }
273
+
274
+ cmark_node *cmark_node_first_child(cmark_node *node) {
275
+ if (node == NULL) {
276
+ return NULL;
277
+ } else {
278
+ return node->first_child;
279
+ }
280
+ }
281
+
282
+ cmark_node *cmark_node_last_child(cmark_node *node) {
283
+ if (node == NULL) {
284
+ return NULL;
285
+ } else {
286
+ return node->last_child;
287
+ }
288
+ }
289
+
290
+ void *cmark_node_get_user_data(cmark_node *node) {
291
+ if (node == NULL) {
292
+ return NULL;
293
+ } else {
294
+ return node->user_data;
295
+ }
296
+ }
297
+
298
+ int cmark_node_set_user_data(cmark_node *node, void *user_data) {
299
+ if (node == NULL) {
300
+ return 0;
301
+ }
302
+ node->user_data = user_data;
303
+ return 1;
304
+ }
305
+
306
+ int cmark_node_set_user_data_free_func(cmark_node *node,
307
+ cmark_free_func free_func) {
308
+ if (node == NULL) {
309
+ return 0;
310
+ }
311
+ node->user_data_free_func = free_func;
312
+ return 1;
313
+ }
314
+
315
+ const char *cmark_node_get_literal(cmark_node *node) {
316
+ if (node == NULL) {
317
+ return NULL;
318
+ }
319
+
320
+ switch (node->type) {
321
+ case CMARK_NODE_HTML_BLOCK:
322
+ case CMARK_NODE_TEXT:
323
+ case CMARK_NODE_HTML_INLINE:
324
+ case CMARK_NODE_CODE:
325
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
326
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.literal);
327
+
328
+ case CMARK_NODE_CODE_BLOCK:
329
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.code.literal);
330
+
331
+ default:
332
+ break;
333
+ }
334
+
335
+ return NULL;
336
+ }
337
+
338
+ int cmark_node_set_literal(cmark_node *node, const char *content) {
339
+ if (node == NULL) {
340
+ return 0;
341
+ }
342
+
343
+ switch (node->type) {
344
+ case CMARK_NODE_HTML_BLOCK:
345
+ case CMARK_NODE_TEXT:
346
+ case CMARK_NODE_HTML_INLINE:
347
+ case CMARK_NODE_CODE:
348
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
349
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.literal, content);
350
+ return 1;
351
+
352
+ case CMARK_NODE_CODE_BLOCK:
353
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.code.literal, content);
354
+ return 1;
355
+
356
+ default:
357
+ break;
358
+ }
359
+
360
+ return 0;
361
+ }
362
+
363
+ const char *cmark_node_get_string_content(cmark_node *node) {
364
+ return (char *) node->content.ptr;
365
+ }
366
+
367
+ int cmark_node_set_string_content(cmark_node *node, const char *content) {
368
+ cmark_strbuf_sets(&node->content, content);
369
+ return true;
370
+ }
371
+
372
+ int cmark_node_get_heading_level(cmark_node *node) {
373
+ if (node == NULL) {
374
+ return 0;
375
+ }
376
+
377
+ switch (node->type) {
378
+ case CMARK_NODE_HEADING:
379
+ return node->as.heading.level;
380
+
381
+ default:
382
+ break;
383
+ }
384
+
385
+ return 0;
386
+ }
387
+
388
+ int cmark_node_set_heading_level(cmark_node *node, int level) {
389
+ if (node == NULL || level < 1 || level > 6) {
390
+ return 0;
391
+ }
392
+
393
+ switch (node->type) {
394
+ case CMARK_NODE_HEADING:
395
+ node->as.heading.level = level;
396
+ return 1;
397
+
398
+ default:
399
+ break;
400
+ }
401
+
402
+ return 0;
403
+ }
404
+
405
+ cmark_list_type cmark_node_get_list_type(cmark_node *node) {
406
+ if (node == NULL) {
407
+ return CMARK_NO_LIST;
408
+ }
409
+
410
+ if (node->type == CMARK_NODE_LIST) {
411
+ return node->as.list.list_type;
412
+ } else {
413
+ return CMARK_NO_LIST;
414
+ }
415
+ }
416
+
417
+ int cmark_node_set_list_type(cmark_node *node, cmark_list_type type) {
418
+ if (!(type == CMARK_BULLET_LIST || type == CMARK_ORDERED_LIST)) {
419
+ return 0;
420
+ }
421
+
422
+ if (node == NULL) {
423
+ return 0;
424
+ }
425
+
426
+ if (node->type == CMARK_NODE_LIST) {
427
+ node->as.list.list_type = type;
428
+ return 1;
429
+ } else {
430
+ return 0;
431
+ }
432
+ }
433
+
434
+ cmark_delim_type cmark_node_get_list_delim(cmark_node *node) {
435
+ if (node == NULL) {
436
+ return CMARK_NO_DELIM;
437
+ }
438
+
439
+ if (node->type == CMARK_NODE_LIST) {
440
+ return node->as.list.delimiter;
441
+ } else {
442
+ return CMARK_NO_DELIM;
443
+ }
444
+ }
445
+
446
+ int cmark_node_set_list_delim(cmark_node *node, cmark_delim_type delim) {
447
+ if (!(delim == CMARK_PERIOD_DELIM || delim == CMARK_PAREN_DELIM)) {
448
+ return 0;
449
+ }
450
+
451
+ if (node == NULL) {
452
+ return 0;
453
+ }
454
+
455
+ if (node->type == CMARK_NODE_LIST) {
456
+ node->as.list.delimiter = delim;
457
+ return 1;
458
+ } else {
459
+ return 0;
460
+ }
461
+ }
462
+
463
+ int cmark_node_get_list_start(cmark_node *node) {
464
+ if (node == NULL) {
465
+ return 0;
466
+ }
467
+
468
+ if (node->type == CMARK_NODE_LIST) {
469
+ return node->as.list.start;
470
+ } else {
471
+ return 0;
472
+ }
473
+ }
474
+
475
+ int cmark_node_set_list_start(cmark_node *node, int start) {
476
+ if (node == NULL || start < 0) {
477
+ return 0;
478
+ }
479
+
480
+ if (node->type == CMARK_NODE_LIST) {
481
+ node->as.list.start = start;
482
+ return 1;
483
+ } else {
484
+ return 0;
485
+ }
486
+ }
487
+
488
+ int cmark_node_get_list_tight(cmark_node *node) {
489
+ if (node == NULL) {
490
+ return 0;
491
+ }
492
+
493
+ if (node->type == CMARK_NODE_LIST) {
494
+ return node->as.list.tight;
495
+ } else {
496
+ return 0;
497
+ }
498
+ }
499
+
500
+ int cmark_node_set_list_tight(cmark_node *node, int tight) {
501
+ if (node == NULL) {
502
+ return 0;
503
+ }
504
+
505
+ if (node->type == CMARK_NODE_LIST) {
506
+ node->as.list.tight = tight == 1;
507
+ return 1;
508
+ } else {
509
+ return 0;
510
+ }
511
+ }
512
+
513
+ const char *cmark_node_get_fence_info(cmark_node *node) {
514
+ if (node == NULL) {
515
+ return NULL;
516
+ }
517
+
518
+ if (node->type == CMARK_NODE_CODE_BLOCK) {
519
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.code.info);
520
+ } else {
521
+ return NULL;
522
+ }
523
+ }
524
+
525
+ int cmark_node_set_fence_info(cmark_node *node, const char *info) {
526
+ if (node == NULL) {
527
+ return 0;
528
+ }
529
+
530
+ if (node->type == CMARK_NODE_CODE_BLOCK) {
531
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.code.info, info);
532
+ return 1;
533
+ } else {
534
+ return 0;
535
+ }
536
+ }
537
+
538
+ int cmark_node_get_fenced(cmark_node *node, int *length, int *offset, char *character) {
539
+ if (node == NULL) {
540
+ return 0;
541
+ }
542
+
543
+ if (node->type == CMARK_NODE_CODE_BLOCK) {
544
+ *length = node->as.code.fence_length;
545
+ *offset = node->as.code.fence_offset;
546
+ *character = node->as.code.fence_char;
547
+ return node->as.code.fenced;
548
+ } else {
549
+ return 0;
550
+ }
551
+ }
552
+
553
+ int cmark_node_set_fenced(cmark_node * node, int fenced,
554
+ int length, int offset, char character) {
555
+ if (node == NULL) {
556
+ return 0;
557
+ }
558
+
559
+ if (node->type == CMARK_NODE_CODE_BLOCK) {
560
+ node->as.code.fenced = (int8_t)fenced;
561
+ node->as.code.fence_length = (uint8_t)length;
562
+ node->as.code.fence_offset = (uint8_t)offset;
563
+ node->as.code.fence_char = character;
564
+ return 1;
565
+ } else {
566
+ return 0;
567
+ }
568
+ }
569
+
570
+ const char *cmark_node_get_url(cmark_node *node) {
571
+ if (node == NULL) {
572
+ return NULL;
573
+ }
574
+
575
+ switch (node->type) {
576
+ case CMARK_NODE_LINK:
577
+ case CMARK_NODE_IMAGE:
578
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.link.url);
579
+ default:
580
+ break;
581
+ }
582
+
583
+ return NULL;
584
+ }
585
+
586
+ int cmark_node_set_url(cmark_node *node, const char *url) {
587
+ if (node == NULL) {
588
+ return 0;
589
+ }
590
+
591
+ switch (node->type) {
592
+ case CMARK_NODE_LINK:
593
+ case CMARK_NODE_IMAGE:
594
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.link.url, url);
595
+ return 1;
596
+ default:
597
+ break;
598
+ }
599
+
600
+ return 0;
601
+ }
602
+
603
+ const char *cmark_node_get_title(cmark_node *node) {
604
+ if (node == NULL) {
605
+ return NULL;
606
+ }
607
+
608
+ switch (node->type) {
609
+ case CMARK_NODE_LINK:
610
+ case CMARK_NODE_IMAGE:
611
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.link.title);
612
+ default:
613
+ break;
614
+ }
615
+
616
+ return NULL;
617
+ }
618
+
619
+ int cmark_node_set_title(cmark_node *node, const char *title) {
620
+ if (node == NULL) {
621
+ return 0;
622
+ }
623
+
624
+ switch (node->type) {
625
+ case CMARK_NODE_LINK:
626
+ case CMARK_NODE_IMAGE:
627
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.link.title, title);
628
+ return 1;
629
+ default:
630
+ break;
631
+ }
632
+
633
+ return 0;
634
+ }
635
+
636
+ const char *cmark_node_get_on_enter(cmark_node *node) {
637
+ if (node == NULL) {
638
+ return NULL;
639
+ }
640
+
641
+ switch (node->type) {
642
+ case CMARK_NODE_CUSTOM_INLINE:
643
+ case CMARK_NODE_CUSTOM_BLOCK:
644
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.custom.on_enter);
645
+ default:
646
+ break;
647
+ }
648
+
649
+ return NULL;
650
+ }
651
+
652
+ int cmark_node_set_on_enter(cmark_node *node, const char *on_enter) {
653
+ if (node == NULL) {
654
+ return 0;
655
+ }
656
+
657
+ switch (node->type) {
658
+ case CMARK_NODE_CUSTOM_INLINE:
659
+ case CMARK_NODE_CUSTOM_BLOCK:
660
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.custom.on_enter, on_enter);
661
+ return 1;
662
+ default:
663
+ break;
664
+ }
665
+
666
+ return 0;
667
+ }
668
+
669
+ const char *cmark_node_get_on_exit(cmark_node *node) {
670
+ if (node == NULL) {
671
+ return NULL;
672
+ }
673
+
674
+ switch (node->type) {
675
+ case CMARK_NODE_CUSTOM_INLINE:
676
+ case CMARK_NODE_CUSTOM_BLOCK:
677
+ return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.custom.on_exit);
678
+ default:
679
+ break;
680
+ }
681
+
682
+ return NULL;
683
+ }
684
+
685
+ int cmark_node_set_on_exit(cmark_node *node, const char *on_exit) {
686
+ if (node == NULL) {
687
+ return 0;
688
+ }
689
+
690
+ switch (node->type) {
691
+ case CMARK_NODE_CUSTOM_INLINE:
692
+ case CMARK_NODE_CUSTOM_BLOCK:
693
+ cmark_chunk_set_cstr(NODE_MEM(node), &node->as.custom.on_exit, on_exit);
694
+ return 1;
695
+ default:
696
+ break;
697
+ }
698
+
699
+ return 0;
700
+ }
701
+
702
+ cmark_syntax_extension *cmark_node_get_syntax_extension(cmark_node *node) {
703
+ if (node == NULL) {
704
+ return NULL;
705
+ }
706
+
707
+ return node->extension;
708
+ }
709
+
710
+ int cmark_node_set_syntax_extension(cmark_node *node, cmark_syntax_extension *extension) {
711
+ if (node == NULL) {
712
+ return 0;
713
+ }
714
+
715
+ node->extension = extension;
716
+ return 1;
717
+ }
718
+
719
+ int cmark_node_get_start_line(cmark_node *node) {
720
+ if (node == NULL) {
721
+ return 0;
722
+ }
723
+ return node->start_line;
724
+ }
725
+
726
+ int cmark_node_get_start_column(cmark_node *node) {
727
+ if (node == NULL) {
728
+ return 0;
729
+ }
730
+ return node->start_column;
731
+ }
732
+
733
+ int cmark_node_get_end_line(cmark_node *node) {
734
+ if (node == NULL) {
735
+ return 0;
736
+ }
737
+ return node->end_line;
738
+ }
739
+
740
+ int cmark_node_get_end_column(cmark_node *node) {
741
+ if (node == NULL) {
742
+ return 0;
743
+ }
744
+ return node->end_column;
745
+ }
746
+
747
+ // Unlink a node without adjusting its next, prev, and parent pointers.
748
+ static void S_node_unlink(cmark_node *node) {
749
+ if (node == NULL) {
750
+ return;
751
+ }
752
+
753
+ if (node->prev) {
754
+ node->prev->next = node->next;
755
+ }
756
+ if (node->next) {
757
+ node->next->prev = node->prev;
758
+ }
759
+
760
+ // Adjust first_child and last_child of parent.
761
+ cmark_node *parent = node->parent;
762
+ if (parent) {
763
+ if (parent->first_child == node) {
764
+ parent->first_child = node->next;
765
+ }
766
+ if (parent->last_child == node) {
767
+ parent->last_child = node->prev;
768
+ }
769
+ }
770
+ }
771
+
772
+ void cmark_node_unlink(cmark_node *node) {
773
+ S_node_unlink(node);
774
+
775
+ node->next = NULL;
776
+ node->prev = NULL;
777
+ node->parent = NULL;
778
+ }
779
+
780
+ int cmark_node_insert_before(cmark_node *node, cmark_node *sibling) {
781
+ if (node == NULL || sibling == NULL) {
782
+ return 0;
783
+ }
784
+
785
+ if (!node->parent || !S_can_contain(node->parent, sibling)) {
786
+ return 0;
787
+ }
788
+
789
+ S_node_unlink(sibling);
790
+
791
+ cmark_node *old_prev = node->prev;
792
+
793
+ // Insert 'sibling' between 'old_prev' and 'node'.
794
+ if (old_prev) {
795
+ old_prev->next = sibling;
796
+ }
797
+ sibling->prev = old_prev;
798
+ sibling->next = node;
799
+ node->prev = sibling;
800
+
801
+ // Set new parent.
802
+ cmark_node *parent = node->parent;
803
+ sibling->parent = parent;
804
+
805
+ // Adjust first_child of parent if inserted as first child.
806
+ if (parent && !old_prev) {
807
+ parent->first_child = sibling;
808
+ }
809
+
810
+ return 1;
811
+ }
812
+
813
+ int cmark_node_insert_after(cmark_node *node, cmark_node *sibling) {
814
+ if (node == NULL || sibling == NULL) {
815
+ return 0;
816
+ }
817
+
818
+ if (!node->parent || !S_can_contain(node->parent, sibling)) {
819
+ return 0;
820
+ }
821
+
822
+ S_node_unlink(sibling);
823
+
824
+ cmark_node *old_next = node->next;
825
+
826
+ // Insert 'sibling' between 'node' and 'old_next'.
827
+ if (old_next) {
828
+ old_next->prev = sibling;
829
+ }
830
+ sibling->next = old_next;
831
+ sibling->prev = node;
832
+ node->next = sibling;
833
+
834
+ // Set new parent.
835
+ cmark_node *parent = node->parent;
836
+ sibling->parent = parent;
837
+
838
+ // Adjust last_child of parent if inserted as last child.
839
+ if (parent && !old_next) {
840
+ parent->last_child = sibling;
841
+ }
842
+
843
+ return 1;
844
+ }
845
+
846
+ int cmark_node_replace(cmark_node *oldnode, cmark_node *newnode) {
847
+ if (!cmark_node_insert_before(oldnode, newnode)) {
848
+ return 0;
849
+ }
850
+ cmark_node_unlink(oldnode);
851
+ return 1;
852
+ }
853
+
854
+ int cmark_node_prepend_child(cmark_node *node, cmark_node *child) {
855
+ if (!S_can_contain(node, child)) {
856
+ return 0;
857
+ }
858
+
859
+ S_node_unlink(child);
860
+
861
+ cmark_node *old_first_child = node->first_child;
862
+
863
+ child->next = old_first_child;
864
+ child->prev = NULL;
865
+ child->parent = node;
866
+ node->first_child = child;
867
+
868
+ if (old_first_child) {
869
+ old_first_child->prev = child;
870
+ } else {
871
+ // Also set last_child if node previously had no children.
872
+ node->last_child = child;
873
+ }
874
+
875
+ return 1;
876
+ }
877
+
878
+ int cmark_node_append_child(cmark_node *node, cmark_node *child) {
879
+ if (!S_can_contain(node, child)) {
880
+ return 0;
881
+ }
882
+
883
+ S_node_unlink(child);
884
+
885
+ cmark_node *old_last_child = node->last_child;
886
+
887
+ child->next = NULL;
888
+ child->prev = old_last_child;
889
+ child->parent = node;
890
+ node->last_child = child;
891
+
892
+ if (old_last_child) {
893
+ old_last_child->next = child;
894
+ } else {
895
+ // Also set first_child if node previously had no children.
896
+ node->first_child = child;
897
+ }
898
+
899
+ return 1;
900
+ }
901
+
902
+ static void S_print_error(FILE *out, cmark_node *node, const char *elem) {
903
+ if (out == NULL) {
904
+ return;
905
+ }
906
+ fprintf(out, "Invalid '%s' in node type %s at %d:%d\n", elem,
907
+ cmark_node_get_type_string(node), node->start_line,
908
+ node->start_column);
909
+ }
910
+
911
+ int cmark_node_check(cmark_node *node, FILE *out) {
912
+ cmark_node *cur;
913
+ int errors = 0;
914
+
915
+ if (!node) {
916
+ return 0;
917
+ }
918
+
919
+ cur = node;
920
+ for (;;) {
921
+ if (cur->first_child) {
922
+ if (cur->first_child->prev != NULL) {
923
+ S_print_error(out, cur->first_child, "prev");
924
+ cur->first_child->prev = NULL;
925
+ ++errors;
926
+ }
927
+ if (cur->first_child->parent != cur) {
928
+ S_print_error(out, cur->first_child, "parent");
929
+ cur->first_child->parent = cur;
930
+ ++errors;
931
+ }
932
+ cur = cur->first_child;
933
+ continue;
934
+ }
935
+
936
+ next_sibling:
937
+ if (cur == node) {
938
+ break;
939
+ }
940
+ if (cur->next) {
941
+ if (cur->next->prev != cur) {
942
+ S_print_error(out, cur->next, "prev");
943
+ cur->next->prev = cur;
944
+ ++errors;
945
+ }
946
+ if (cur->next->parent != cur->parent) {
947
+ S_print_error(out, cur->next, "parent");
948
+ cur->next->parent = cur->parent;
949
+ ++errors;
950
+ }
951
+ cur = cur->next;
952
+ continue;
953
+ }
954
+
955
+ if (cur->parent->last_child != cur) {
956
+ S_print_error(out, cur->parent, "last_child");
957
+ cur->parent->last_child = cur;
958
+ ++errors;
959
+ }
960
+ cur = cur->parent;
961
+ goto next_sibling;
962
+ }
963
+
964
+ return errors;
965
+ }