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,9 @@
1
+ #ifndef STRIKETHROUGH_H
2
+ #define STRIKETHROUGH_H
3
+
4
+ #include "core-extensions.h"
5
+
6
+ extern cmark_node_type CMARK_NODE_STRIKETHROUGH;
7
+ cmark_syntax_extension *create_strikethrough_extension(void);
8
+
9
+ #endif
@@ -0,0 +1,139 @@
1
+ #include <stdlib.h>
2
+ #include <assert.h>
3
+
4
+ #include "cmark.h"
5
+ #include "syntax_extension.h"
6
+ #include "buffer.h"
7
+
8
+ extern cmark_mem CMARK_DEFAULT_MEM_ALLOCATOR;
9
+
10
+ static cmark_mem *_mem = &CMARK_DEFAULT_MEM_ALLOCATOR;
11
+
12
+ void cmark_syntax_extension_free(cmark_mem *mem, cmark_syntax_extension *extension) {
13
+ if (extension->free_function && extension->priv) {
14
+ extension->free_function(mem, extension->priv);
15
+ }
16
+
17
+ cmark_llist_free(mem, extension->special_inline_chars);
18
+ mem->free(extension->name);
19
+ mem->free(extension);
20
+ }
21
+
22
+ cmark_syntax_extension *cmark_syntax_extension_new(const char *name) {
23
+ cmark_syntax_extension *res = (cmark_syntax_extension *) _mem->calloc(1, sizeof(cmark_syntax_extension));
24
+ res->name = (char *) _mem->calloc(1, sizeof(char) * (strlen(name)) + 1);
25
+ strcpy(res->name, name);
26
+ return res;
27
+ }
28
+
29
+ cmark_node_type cmark_syntax_extension_add_node(int is_inline) {
30
+ cmark_node_type *ref = !is_inline ? &CMARK_NODE_LAST_BLOCK : &CMARK_NODE_LAST_INLINE;
31
+
32
+ if ((*ref & CMARK_NODE_VALUE_MASK) == CMARK_NODE_VALUE_MASK) {
33
+ assert(false);
34
+ return (cmark_node_type) 0;
35
+ }
36
+
37
+ return *ref = (cmark_node_type) ((int) *ref + 1);
38
+ }
39
+
40
+ void cmark_syntax_extension_set_emphasis(cmark_syntax_extension *extension,
41
+ int emphasis) {
42
+ extension->emphasis = emphasis == 1;
43
+ }
44
+
45
+ void cmark_syntax_extension_set_open_block_func(cmark_syntax_extension *extension,
46
+ cmark_open_block_func func) {
47
+ extension->try_opening_block = func;
48
+ }
49
+
50
+ void cmark_syntax_extension_set_match_block_func(cmark_syntax_extension *extension,
51
+ cmark_match_block_func func) {
52
+ extension->last_block_matches = func;
53
+ }
54
+
55
+ void cmark_syntax_extension_set_match_inline_func(cmark_syntax_extension *extension,
56
+ cmark_match_inline_func func) {
57
+ extension->match_inline = func;
58
+ }
59
+
60
+ void cmark_syntax_extension_set_inline_from_delim_func(cmark_syntax_extension *extension,
61
+ cmark_inline_from_delim_func func) {
62
+ extension->insert_inline_from_delim = func;
63
+ }
64
+
65
+ void cmark_syntax_extension_set_special_inline_chars(cmark_syntax_extension *extension,
66
+ cmark_llist *special_chars) {
67
+ extension->special_inline_chars = special_chars;
68
+ }
69
+
70
+ void cmark_syntax_extension_set_get_type_string_func(cmark_syntax_extension *extension,
71
+ cmark_get_type_string_func func) {
72
+ extension->get_type_string_func = func;
73
+ }
74
+
75
+ void cmark_syntax_extension_set_can_contain_func(cmark_syntax_extension *extension,
76
+ cmark_can_contain_func func) {
77
+ extension->can_contain_func = func;
78
+ }
79
+
80
+ void cmark_syntax_extension_set_contains_inlines_func(cmark_syntax_extension *extension,
81
+ cmark_contains_inlines_func func) {
82
+ extension->contains_inlines_func = func;
83
+ }
84
+
85
+ void cmark_syntax_extension_set_commonmark_render_func(cmark_syntax_extension *extension,
86
+ cmark_common_render_func func) {
87
+ extension->commonmark_render_func = func;
88
+ }
89
+
90
+ void cmark_syntax_extension_set_plaintext_render_func(cmark_syntax_extension *extension,
91
+ cmark_common_render_func func) {
92
+ extension->plaintext_render_func = func;
93
+ }
94
+
95
+ void cmark_syntax_extension_set_latex_render_func(cmark_syntax_extension *extension,
96
+ cmark_common_render_func func) {
97
+ extension->latex_render_func = func;
98
+ }
99
+
100
+ void cmark_syntax_extension_set_man_render_func(cmark_syntax_extension *extension,
101
+ cmark_common_render_func func) {
102
+ extension->man_render_func = func;
103
+ }
104
+
105
+ void cmark_syntax_extension_set_html_render_func(cmark_syntax_extension *extension,
106
+ cmark_html_render_func func) {
107
+ extension->html_render_func = func;
108
+ }
109
+
110
+ void cmark_syntax_extension_set_html_filter_func(cmark_syntax_extension *extension,
111
+ cmark_html_filter_func func) {
112
+ extension->html_filter_func = func;
113
+ }
114
+
115
+ void cmark_syntax_extension_set_postprocess_func(cmark_syntax_extension *extension,
116
+ cmark_postprocess_func func) {
117
+ extension->postprocess_func = func;
118
+ }
119
+
120
+ void cmark_syntax_extension_set_private(cmark_syntax_extension *extension,
121
+ void *priv,
122
+ cmark_free_func free_func) {
123
+ extension->priv = priv;
124
+ extension->free_function = free_func;
125
+ }
126
+
127
+ void *cmark_syntax_extension_get_private(cmark_syntax_extension *extension) {
128
+ return extension->priv;
129
+ }
130
+
131
+ void cmark_syntax_extension_set_opaque_free_func(cmark_syntax_extension *extension,
132
+ cmark_opaque_free_func func) {
133
+ extension->opaque_free_func = func;
134
+ }
135
+
136
+ void cmark_syntax_extension_set_commonmark_escape_func(cmark_syntax_extension *extension,
137
+ cmark_commonmark_escape_func func) {
138
+ extension->commonmark_escape_func = func;
139
+ }
@@ -0,0 +1,32 @@
1
+ #ifndef CMARK_SYNTAX_EXTENSION_H
2
+ #define CMARK_SYNTAX_EXTENSION_H
3
+
4
+ #include "cmark.h"
5
+ #include "cmark_extension_api.h"
6
+ #include "config.h"
7
+
8
+ struct cmark_syntax_extension {
9
+ cmark_match_block_func last_block_matches;
10
+ cmark_open_block_func try_opening_block;
11
+ cmark_match_inline_func match_inline;
12
+ cmark_inline_from_delim_func insert_inline_from_delim;
13
+ cmark_llist * special_inline_chars;
14
+ char * name;
15
+ void * priv;
16
+ bool emphasis;
17
+ cmark_free_func free_function;
18
+ cmark_get_type_string_func get_type_string_func;
19
+ cmark_can_contain_func can_contain_func;
20
+ cmark_contains_inlines_func contains_inlines_func;
21
+ cmark_common_render_func commonmark_render_func;
22
+ cmark_common_render_func plaintext_render_func;
23
+ cmark_common_render_func latex_render_func;
24
+ cmark_common_render_func man_render_func;
25
+ cmark_html_render_func html_render_func;
26
+ cmark_html_filter_func html_filter_func;
27
+ cmark_postprocess_func postprocess_func;
28
+ cmark_opaque_free_func opaque_free_func;
29
+ cmark_commonmark_escape_func commonmark_escape_func;
30
+ };
31
+
32
+ #endif
@@ -0,0 +1,683 @@
1
+ #include <cmark_extension_api.h>
2
+ #include <html.h>
3
+ #include <inlines.h>
4
+ #include <parser.h>
5
+ #include <references.h>
6
+ #include <string.h>
7
+ #include <render.h>
8
+
9
+ #include "ext_scanners.h"
10
+ #include "strikethrough.h"
11
+ #include "table.h"
12
+
13
+ cmark_node_type CMARK_NODE_TABLE, CMARK_NODE_TABLE_ROW,
14
+ CMARK_NODE_TABLE_CELL;
15
+
16
+ typedef struct {
17
+ uint16_t n_columns;
18
+ cmark_llist *cells;
19
+ } table_row;
20
+
21
+ typedef struct {
22
+ uint16_t n_columns;
23
+ uint8_t *alignments;
24
+ } node_table;
25
+
26
+ typedef struct {
27
+ bool is_header;
28
+ } node_table_row;
29
+
30
+ typedef struct {
31
+ cmark_strbuf *buf;
32
+ int start_offset, end_offset, internal_offset;
33
+ } node_cell;
34
+
35
+ static void free_table_cell(cmark_mem *mem, void *data) {
36
+ node_cell *cell = (node_cell *)data;
37
+ cmark_strbuf_free((cmark_strbuf *)cell->buf);
38
+ mem->free(cell->buf);
39
+ mem->free(cell);
40
+ }
41
+
42
+ static void free_table_row(cmark_mem *mem, table_row *row) {
43
+ if (!row)
44
+ return;
45
+
46
+ cmark_llist_free_full(mem, row->cells, (cmark_free_func)free_table_cell);
47
+
48
+ mem->free(row);
49
+ }
50
+
51
+ static void free_node_table(cmark_mem *mem, void *ptr) {
52
+ node_table *t = (node_table *)ptr;
53
+ mem->free(t->alignments);
54
+ mem->free(t);
55
+ }
56
+
57
+ static void free_node_table_row(cmark_mem *mem, void *ptr) {
58
+ mem->free(ptr);
59
+ }
60
+
61
+ static int get_n_table_columns(cmark_node *node) {
62
+ if (!node || node->type != CMARK_NODE_TABLE)
63
+ return -1;
64
+
65
+ return (int)((node_table *)node->as.opaque)->n_columns;
66
+ }
67
+
68
+ static int set_n_table_columns(cmark_node *node, uint16_t n_columns) {
69
+ if (!node || node->type != CMARK_NODE_TABLE)
70
+ return 0;
71
+
72
+ ((node_table *)node->as.opaque)->n_columns = n_columns;
73
+ return 1;
74
+ }
75
+
76
+ static uint8_t *get_table_alignments(cmark_node *node) {
77
+ if (!node || node->type != CMARK_NODE_TABLE)
78
+ return 0;
79
+
80
+ return ((node_table *)node->as.opaque)->alignments;
81
+ }
82
+
83
+ static int set_table_alignments(cmark_node *node, uint8_t *alignments) {
84
+ if (!node || node->type != CMARK_NODE_TABLE)
85
+ return 0;
86
+
87
+ ((node_table *)node->as.opaque)->alignments = alignments;
88
+ return 1;
89
+ }
90
+
91
+ static cmark_strbuf *unescape_pipes(cmark_mem *mem, unsigned char *string, bufsize_t len)
92
+ {
93
+ cmark_strbuf *res = (cmark_strbuf *)mem->calloc(1, sizeof(cmark_strbuf));
94
+ bufsize_t r, w;
95
+
96
+ cmark_strbuf_init(mem, res, len + 1);
97
+ cmark_strbuf_put(res, string, len);
98
+ cmark_strbuf_putc(res, '\0');
99
+
100
+ for (r = 0, w = 0; r < len; ++r) {
101
+ if (res->ptr[r] == '\\' && res->ptr[r + 1] == '|')
102
+ r++;
103
+
104
+ res->ptr[w++] = res->ptr[r];
105
+ }
106
+
107
+ cmark_strbuf_truncate(res, w);
108
+
109
+ return res;
110
+ }
111
+
112
+ static table_row *row_from_string(cmark_syntax_extension *self,
113
+ cmark_parser *parser, unsigned char *string,
114
+ int len) {
115
+ table_row *row = NULL;
116
+ bufsize_t cell_matched, pipe_matched, offset;
117
+
118
+ row = (table_row *)parser->mem->calloc(1, sizeof(table_row));
119
+ row->n_columns = 0;
120
+ row->cells = NULL;
121
+
122
+ offset = scan_table_cell_end(string, len, 0);
123
+
124
+ do {
125
+ cell_matched = scan_table_cell(string, len, offset);
126
+ pipe_matched = scan_table_cell_end(string, len, offset + cell_matched);
127
+
128
+ if (cell_matched || pipe_matched) {
129
+ cmark_strbuf *cell_buf = unescape_pipes(parser->mem, string + offset,
130
+ cell_matched);
131
+ cmark_strbuf_trim(cell_buf);
132
+
133
+ node_cell *cell = (node_cell *)parser->mem->calloc(1, sizeof(*cell));
134
+ cell->buf = cell_buf;
135
+ cell->start_offset = offset;
136
+ cell->end_offset = offset + cell_matched - 1;
137
+ while (cell->start_offset > 0 && string[cell->start_offset - 1] != '|') {
138
+ --cell->start_offset;
139
+ ++cell->internal_offset;
140
+ }
141
+ row->n_columns += 1;
142
+ row->cells = cmark_llist_append(parser->mem, row->cells, cell);
143
+ }
144
+
145
+ offset += cell_matched + pipe_matched;
146
+
147
+ if (!pipe_matched) {
148
+ pipe_matched = scan_table_row_end(string, len, offset);
149
+ offset += pipe_matched;
150
+ }
151
+ } while ((cell_matched || pipe_matched) && offset < len);
152
+
153
+ if (offset != len || !row->n_columns) {
154
+ free_table_row(parser->mem, row);
155
+ row = NULL;
156
+ }
157
+
158
+ return row;
159
+ }
160
+
161
+ static cmark_node *try_opening_table_header(cmark_syntax_extension *self,
162
+ cmark_parser *parser,
163
+ cmark_node *parent_container,
164
+ unsigned char *input, int len) {
165
+ bufsize_t matched =
166
+ scan_table_start(input, len, cmark_parser_get_first_nonspace(parser));
167
+ cmark_node *table_header;
168
+ table_row *header_row = NULL;
169
+ table_row *marker_row = NULL;
170
+ node_table_row *ntr;
171
+ const char *parent_string;
172
+ uint16_t i;
173
+
174
+ if (!matched)
175
+ return parent_container;
176
+
177
+ parent_string = cmark_node_get_string_content(parent_container);
178
+
179
+ cmark_arena_push();
180
+
181
+ header_row = row_from_string(self, parser, (unsigned char *)parent_string,
182
+ (int)strlen(parent_string));
183
+
184
+ if (!header_row) {
185
+ free_table_row(parser->mem, header_row);
186
+ cmark_arena_pop();
187
+ return parent_container;
188
+ }
189
+
190
+ marker_row = row_from_string(self, parser,
191
+ input + cmark_parser_get_first_nonspace(parser),
192
+ len - cmark_parser_get_first_nonspace(parser));
193
+
194
+ assert(marker_row);
195
+
196
+ if (header_row->n_columns != marker_row->n_columns) {
197
+ free_table_row(parser->mem, header_row);
198
+ free_table_row(parser->mem, marker_row);
199
+ cmark_arena_pop();
200
+ return parent_container;
201
+ }
202
+
203
+ if (cmark_arena_pop()) {
204
+ header_row = row_from_string(self, parser, (unsigned char *)parent_string,
205
+ (int)strlen(parent_string));
206
+ marker_row = row_from_string(self, parser,
207
+ input + cmark_parser_get_first_nonspace(parser),
208
+ len - cmark_parser_get_first_nonspace(parser));
209
+ }
210
+
211
+ if (!cmark_node_set_type(parent_container, CMARK_NODE_TABLE)) {
212
+ free_table_row(parser->mem, header_row);
213
+ free_table_row(parser->mem, marker_row);
214
+ return parent_container;
215
+ }
216
+
217
+ cmark_node_set_syntax_extension(parent_container, self);
218
+
219
+ parent_container->as.opaque = parser->mem->calloc(1, sizeof(node_table));
220
+
221
+ set_n_table_columns(parent_container, header_row->n_columns);
222
+
223
+ uint8_t *alignments =
224
+ (uint8_t *)parser->mem->calloc(header_row->n_columns, sizeof(uint8_t));
225
+ cmark_llist *it = marker_row->cells;
226
+ for (i = 0; it; it = it->next, ++i) {
227
+ node_cell *node = (node_cell *)it->data;
228
+ bool left = node->buf->ptr[0] == ':', right = node->buf->ptr[node->buf->size - 1] == ':';
229
+
230
+ if (left && right)
231
+ alignments[i] = 'c';
232
+ else if (left)
233
+ alignments[i] = 'l';
234
+ else if (right)
235
+ alignments[i] = 'r';
236
+ }
237
+ set_table_alignments(parent_container, alignments);
238
+
239
+ table_header =
240
+ cmark_parser_add_child(parser, parent_container, CMARK_NODE_TABLE_ROW,
241
+ parent_container->start_column);
242
+ cmark_node_set_syntax_extension(table_header, self);
243
+ table_header->end_column = parent_container->start_column + (int)strlen(parent_string) - 2;
244
+ table_header->start_line = table_header->end_line = parent_container->start_line;
245
+
246
+ table_header->as.opaque = ntr = (node_table_row *)parser->mem->calloc(1, sizeof(node_table_row));
247
+ ntr->is_header = true;
248
+
249
+ {
250
+ cmark_llist *tmp;
251
+
252
+ for (tmp = header_row->cells; tmp; tmp = tmp->next) {
253
+ node_cell *cell = (node_cell *) tmp->data;
254
+ cmark_node *header_cell = cmark_parser_add_child(parser, table_header,
255
+ CMARK_NODE_TABLE_CELL, parent_container->start_column + cell->start_offset);
256
+ header_cell->start_line = header_cell->end_line = parent_container->start_line;
257
+ header_cell->internal_offset = cell->internal_offset;
258
+ header_cell->end_column = parent_container->start_column + cell->end_offset;
259
+ cmark_node_set_string_content(header_cell, (char *) cell->buf->ptr);
260
+ cmark_node_set_syntax_extension(header_cell, self);
261
+ }
262
+ }
263
+
264
+ cmark_parser_advance_offset(
265
+ parser, (char *)input,
266
+ (int)strlen((char *)input) - 1 - cmark_parser_get_offset(parser), false);
267
+
268
+ free_table_row(parser->mem, header_row);
269
+ free_table_row(parser->mem, marker_row);
270
+ return parent_container;
271
+ }
272
+
273
+ static cmark_node *try_opening_table_row(cmark_syntax_extension *self,
274
+ cmark_parser *parser,
275
+ cmark_node *parent_container,
276
+ unsigned char *input, int len) {
277
+ cmark_node *table_row_block;
278
+ table_row *row;
279
+
280
+ if (cmark_parser_is_blank(parser))
281
+ return NULL;
282
+
283
+ table_row_block =
284
+ cmark_parser_add_child(parser, parent_container, CMARK_NODE_TABLE_ROW,
285
+ parent_container->start_column);
286
+ cmark_node_set_syntax_extension(table_row_block, self);
287
+ table_row_block->end_column = parent_container->end_column;
288
+ table_row_block->as.opaque = parser->mem->calloc(1, sizeof(node_table_row));
289
+
290
+ row = row_from_string(self, parser, input + cmark_parser_get_first_nonspace(parser),
291
+ len - cmark_parser_get_first_nonspace(parser));
292
+
293
+ {
294
+ cmark_llist *tmp;
295
+ int i, table_columns = get_n_table_columns(parent_container);
296
+
297
+ for (tmp = row->cells, i = 0; tmp && i < table_columns; tmp = tmp->next, ++i) {
298
+ node_cell *cell = (node_cell *) tmp->data;
299
+ cmark_node *node = cmark_parser_add_child(parser, table_row_block,
300
+ CMARK_NODE_TABLE_CELL, parent_container->start_column + cell->start_offset);
301
+ node->internal_offset = cell->internal_offset;
302
+ node->end_column = parent_container->start_column + cell->end_offset;
303
+ cmark_node_set_string_content(node, (char *) cell->buf->ptr);
304
+ cmark_node_set_syntax_extension(node, self);
305
+ }
306
+
307
+ for (; i < table_columns; ++i) {
308
+ cmark_node *node = cmark_parser_add_child(
309
+ parser, table_row_block, CMARK_NODE_TABLE_CELL, 0);
310
+ cmark_node_set_syntax_extension(node, self);
311
+ }
312
+ }
313
+
314
+ free_table_row(parser->mem, row);
315
+
316
+ cmark_parser_advance_offset(parser, (char *)input,
317
+ len - 1 - cmark_parser_get_offset(parser), false);
318
+
319
+ return table_row_block;
320
+ }
321
+
322
+ static cmark_node *try_opening_table_block(cmark_syntax_extension *self,
323
+ int indented, cmark_parser *parser,
324
+ cmark_node *parent_container,
325
+ unsigned char *input, int len) {
326
+ cmark_node_type parent_type = cmark_node_get_type(parent_container);
327
+
328
+ if (!indented && parent_type == CMARK_NODE_PARAGRAPH) {
329
+ return try_opening_table_header(self, parser, parent_container, input, len);
330
+ } else if (!indented && parent_type == CMARK_NODE_TABLE) {
331
+ return try_opening_table_row(self, parser, parent_container, input, len);
332
+ }
333
+
334
+ return NULL;
335
+ }
336
+
337
+ static int matches(cmark_syntax_extension *self, cmark_parser *parser,
338
+ unsigned char *input, int len,
339
+ cmark_node *parent_container) {
340
+ int res = 0;
341
+
342
+ if (cmark_node_get_type(parent_container) == CMARK_NODE_TABLE) {
343
+ cmark_arena_push();
344
+ table_row *new_row = row_from_string(
345
+ self, parser, input + cmark_parser_get_first_nonspace(parser),
346
+ len - cmark_parser_get_first_nonspace(parser));
347
+ if (new_row && new_row->n_columns)
348
+ res = 1;
349
+ free_table_row(parser->mem, new_row);
350
+ cmark_arena_pop();
351
+ }
352
+
353
+ return res;
354
+ }
355
+
356
+ static const char *get_type_string(cmark_syntax_extension *self,
357
+ cmark_node *node) {
358
+ if (node->type == CMARK_NODE_TABLE) {
359
+ return "table";
360
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
361
+ if (((node_table_row *)node->as.opaque)->is_header)
362
+ return "table_header";
363
+ else
364
+ return "table_row";
365
+ } else if (node->type == CMARK_NODE_TABLE_CELL) {
366
+ return "table_cell";
367
+ }
368
+
369
+ return "<unknown>";
370
+ }
371
+
372
+ static int can_contain(cmark_syntax_extension *extension, cmark_node *node,
373
+ cmark_node_type child_type) {
374
+ if (node->type == CMARK_NODE_TABLE) {
375
+ return child_type == CMARK_NODE_TABLE_ROW;
376
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
377
+ return child_type == CMARK_NODE_TABLE_CELL;
378
+ } else if (node->type == CMARK_NODE_TABLE_CELL) {
379
+ return child_type == CMARK_NODE_TEXT || child_type == CMARK_NODE_CODE ||
380
+ child_type == CMARK_NODE_EMPH || child_type == CMARK_NODE_STRONG ||
381
+ child_type == CMARK_NODE_LINK || child_type == CMARK_NODE_IMAGE ||
382
+ child_type == CMARK_NODE_STRIKETHROUGH ||
383
+ child_type == CMARK_NODE_HTML_INLINE;
384
+ }
385
+ return false;
386
+ }
387
+
388
+ static int contains_inlines(cmark_syntax_extension *extension,
389
+ cmark_node *node) {
390
+ return node->type == CMARK_NODE_TABLE_CELL;
391
+ }
392
+
393
+ static void commonmark_render(cmark_syntax_extension *extension,
394
+ cmark_renderer *renderer, cmark_node *node,
395
+ cmark_event_type ev_type, int options) {
396
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
397
+
398
+ if (node->type == CMARK_NODE_TABLE) {
399
+ renderer->blankline(renderer);
400
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
401
+ if (entering) {
402
+ renderer->cr(renderer);
403
+ renderer->out(renderer, node, "|", false, LITERAL);
404
+ }
405
+ } else if (node->type == CMARK_NODE_TABLE_CELL) {
406
+ if (entering) {
407
+ renderer->out(renderer, node, " ", false, LITERAL);
408
+ } else {
409
+ renderer->out(renderer, node, " |", false, LITERAL);
410
+ if (((node_table_row *)node->parent->as.opaque)->is_header &&
411
+ !node->next) {
412
+ int i;
413
+ uint8_t *alignments = get_table_alignments(node->parent->parent);
414
+ uint16_t n_cols =
415
+ ((node_table *)node->parent->parent->as.opaque)->n_columns;
416
+ renderer->cr(renderer);
417
+ renderer->out(renderer, node, "|", false, LITERAL);
418
+ for (i = 0; i < n_cols; i++) {
419
+ switch (alignments[i]) {
420
+ case 0: renderer->out(renderer, node, " --- |", false, LITERAL); break;
421
+ case 'l': renderer->out(renderer, node, " :-- |", false, LITERAL); break;
422
+ case 'c': renderer->out(renderer, node, " :-: |", false, LITERAL); break;
423
+ case 'r': renderer->out(renderer, node, " --: |", false, LITERAL); break;
424
+ }
425
+ }
426
+ renderer->cr(renderer);
427
+ }
428
+ }
429
+ } else {
430
+ assert(false);
431
+ }
432
+ }
433
+
434
+ static void latex_render(cmark_syntax_extension *extension,
435
+ cmark_renderer *renderer, cmark_node *node,
436
+ cmark_event_type ev_type, int options) {
437
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
438
+
439
+ if (node->type == CMARK_NODE_TABLE) {
440
+ if (entering) {
441
+ int i;
442
+ uint16_t n_cols;
443
+ uint8_t *alignments = get_table_alignments(node);
444
+
445
+ renderer->cr(renderer);
446
+ renderer->out(renderer, node, "\\begin{table}", false, LITERAL);
447
+ renderer->cr(renderer);
448
+ renderer->out(renderer, node, "\\begin{tabular}{", false, LITERAL);
449
+
450
+ n_cols = ((node_table *)node->as.opaque)->n_columns;
451
+ for (i = 0; i < n_cols; i++) {
452
+ switch(alignments[i]) {
453
+ case 0:
454
+ case 'l':
455
+ renderer->out(renderer, node, "l", false, LITERAL);
456
+ break;
457
+ case 'c':
458
+ renderer->out(renderer, node, "c", false, LITERAL);
459
+ break;
460
+ case 'r':
461
+ renderer->out(renderer, node, "r", false, LITERAL);
462
+ break;
463
+ }
464
+ }
465
+ renderer->out(renderer, node, "}", false, LITERAL);
466
+ renderer->cr(renderer);
467
+ } else {
468
+ renderer->out(renderer, node, "\\end{tabular}", false, LITERAL);
469
+ renderer->cr(renderer);
470
+ renderer->out(renderer, node, "\\end{table}", false, LITERAL);
471
+ renderer->cr(renderer);
472
+ }
473
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
474
+ if (!entering) {
475
+ renderer->cr(renderer);
476
+ }
477
+ } else if (node->type == CMARK_NODE_TABLE_CELL) {
478
+ if (!entering) {
479
+ if (node->next) {
480
+ renderer->out(renderer, node, " & ", false, LITERAL);
481
+ } else {
482
+ renderer->out(renderer, node, " \\\\", false, LITERAL);
483
+ }
484
+ }
485
+ } else {
486
+ assert(false);
487
+ }
488
+ }
489
+
490
+ static void man_render(cmark_syntax_extension *extension,
491
+ cmark_renderer *renderer, cmark_node *node,
492
+ cmark_event_type ev_type, int options) {
493
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
494
+
495
+ if (node->type == CMARK_NODE_TABLE) {
496
+ if (entering) {
497
+ int i;
498
+ uint16_t n_cols;
499
+ uint8_t *alignments = get_table_alignments(node);
500
+
501
+ renderer->cr(renderer);
502
+ renderer->out(renderer, node, ".TS", false, LITERAL);
503
+ renderer->cr(renderer);
504
+ renderer->out(renderer, node, "tab(@);", false, LITERAL);
505
+ renderer->cr(renderer);
506
+
507
+ n_cols = ((node_table *)node->as.opaque)->n_columns;
508
+
509
+ for (i = 0; i < n_cols; i++) {
510
+ switch (alignments[i]) {
511
+ case 'l':
512
+ renderer->out(renderer, node, "l", false, LITERAL);
513
+ break;
514
+ case 0:
515
+ case 'c':
516
+ renderer->out(renderer, node, "c", false, LITERAL);
517
+ break;
518
+ case 'r':
519
+ renderer->out(renderer, node, "r", false, LITERAL);
520
+ break;
521
+ }
522
+ }
523
+
524
+ if (n_cols) {
525
+ renderer->out(renderer, node, ".", false, LITERAL);
526
+ renderer->cr(renderer);
527
+ }
528
+ } else {
529
+ renderer->out(renderer, node, ".TE", false, LITERAL);
530
+ renderer->cr(renderer);
531
+ }
532
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
533
+ if (!entering) {
534
+ renderer->cr(renderer);
535
+ }
536
+ } else if (node->type == CMARK_NODE_TABLE_CELL) {
537
+ if (!entering && node->next) {
538
+ renderer->out(renderer, node, "@", false, LITERAL);
539
+ }
540
+ } else {
541
+ assert(false);
542
+ }
543
+ }
544
+
545
+ struct html_table_state {
546
+ unsigned need_closing_table_body : 1;
547
+ unsigned in_table_header : 1;
548
+ };
549
+
550
+ static void html_render(cmark_syntax_extension *extension,
551
+ cmark_html_renderer *renderer, cmark_node *node,
552
+ cmark_event_type ev_type, int options) {
553
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
554
+ cmark_strbuf *html = renderer->html;
555
+ cmark_node *n;
556
+
557
+ // XXX: we just monopolise renderer->opaque.
558
+ struct html_table_state *table_state =
559
+ (struct html_table_state *)&renderer->opaque;
560
+
561
+ if (node->type == CMARK_NODE_TABLE) {
562
+ if (entering) {
563
+ cmark_html_render_cr(html);
564
+ cmark_strbuf_puts(html, "<table");
565
+ cmark_html_render_sourcepos(node, html, options);
566
+ cmark_strbuf_putc(html, '>');
567
+ table_state->need_closing_table_body = false;
568
+ } else {
569
+ if (table_state->need_closing_table_body)
570
+ cmark_strbuf_puts(html, "</tbody>");
571
+ table_state->need_closing_table_body = false;
572
+ cmark_strbuf_puts(html, "</table>\n");
573
+ }
574
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
575
+ if (entering) {
576
+ cmark_html_render_cr(html);
577
+ if (((node_table_row *)node->as.opaque)->is_header) {
578
+ table_state->in_table_header = 1;
579
+ cmark_strbuf_puts(html, "<thead>");
580
+ cmark_html_render_cr(html);
581
+ } else if (!table_state->need_closing_table_body) {
582
+ cmark_strbuf_puts(html, "<tbody>");
583
+ cmark_html_render_cr(html);
584
+ table_state->need_closing_table_body = 1;
585
+ }
586
+ cmark_strbuf_puts(html, "<tr");
587
+ cmark_html_render_sourcepos(node, html, options);
588
+ cmark_strbuf_putc(html, '>');
589
+ } else {
590
+ cmark_html_render_cr(html);
591
+ cmark_strbuf_puts(html, "</tr>");
592
+ if (((node_table_row *)node->as.opaque)->is_header) {
593
+ cmark_html_render_cr(html);
594
+ cmark_strbuf_puts(html, "</thead>");
595
+ table_state->in_table_header = false;
596
+ }
597
+ }
598
+ } else if (node->type == CMARK_NODE_TABLE_CELL) {
599
+ uint8_t *alignments = get_table_alignments(node->parent->parent);
600
+ if (entering) {
601
+ cmark_html_render_cr(html);
602
+ if (table_state->in_table_header) {
603
+ cmark_strbuf_puts(html, "<th");
604
+ } else {
605
+ cmark_strbuf_puts(html, "<td");
606
+ }
607
+
608
+ int i = 0;
609
+ for (n = node->parent->first_child; n; n = n->next, ++i)
610
+ if (n == node)
611
+ break;
612
+
613
+ switch (alignments[i]) {
614
+ case 'l': cmark_strbuf_puts(html, " align=\"left\""); break;
615
+ case 'c': cmark_strbuf_puts(html, " align=\"center\""); break;
616
+ case 'r': cmark_strbuf_puts(html, " align=\"right\""); break;
617
+ }
618
+
619
+ cmark_html_render_sourcepos(node, html, options);
620
+ cmark_strbuf_putc(html, '>');
621
+ } else {
622
+ if (table_state->in_table_header) {
623
+ cmark_strbuf_puts(html, "</th>");
624
+ } else {
625
+ cmark_strbuf_puts(html, "</td>");
626
+ }
627
+ }
628
+ } else {
629
+ assert(false);
630
+ }
631
+ }
632
+
633
+ static void opaque_free(cmark_syntax_extension *self, cmark_mem *mem, cmark_node *node) {
634
+ if (node->type == CMARK_NODE_TABLE) {
635
+ free_node_table(mem, node->as.opaque);
636
+ } else if (node->type == CMARK_NODE_TABLE_ROW) {
637
+ free_node_table_row(mem, node->as.opaque);
638
+ }
639
+ }
640
+
641
+ static int escape(cmark_syntax_extension *self, cmark_node *node, int c) {
642
+ return
643
+ node->type != CMARK_NODE_TABLE &&
644
+ node->type != CMARK_NODE_TABLE_ROW &&
645
+ node->type != CMARK_NODE_TABLE_CELL &&
646
+ c == '|';
647
+ }
648
+
649
+ cmark_syntax_extension *create_table_extension(void) {
650
+ cmark_syntax_extension *self = cmark_syntax_extension_new("table");
651
+
652
+ cmark_syntax_extension_set_match_block_func(self, matches);
653
+ cmark_syntax_extension_set_open_block_func(self, try_opening_table_block);
654
+ cmark_syntax_extension_set_get_type_string_func(self, get_type_string);
655
+ cmark_syntax_extension_set_can_contain_func(self, can_contain);
656
+ cmark_syntax_extension_set_contains_inlines_func(self, contains_inlines);
657
+ cmark_syntax_extension_set_commonmark_render_func(self, commonmark_render);
658
+ cmark_syntax_extension_set_plaintext_render_func(self, commonmark_render);
659
+ cmark_syntax_extension_set_latex_render_func(self, latex_render);
660
+ cmark_syntax_extension_set_man_render_func(self, man_render);
661
+ cmark_syntax_extension_set_html_render_func(self, html_render);
662
+ cmark_syntax_extension_set_opaque_free_func(self, opaque_free);
663
+ cmark_syntax_extension_set_commonmark_escape_func(self, escape);
664
+ CMARK_NODE_TABLE = cmark_syntax_extension_add_node(0);
665
+ CMARK_NODE_TABLE_ROW = cmark_syntax_extension_add_node(0);
666
+ CMARK_NODE_TABLE_CELL = cmark_syntax_extension_add_node(0);
667
+
668
+ return self;
669
+ }
670
+
671
+ uint16_t cmarkextensions_get_table_columns(cmark_node *node) {
672
+ if (node->type != CMARK_NODE_TABLE)
673
+ return 0;
674
+
675
+ return ((node_table *)node->as.opaque)->n_columns;
676
+ }
677
+
678
+ uint8_t *cmarkextensions_get_table_alignments(cmark_node *node) {
679
+ if (node->type != CMARK_NODE_TABLE)
680
+ return 0;
681
+
682
+ return ((node_table *)node->as.opaque)->alignments;
683
+ }