commonmarker 0.0.1

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 (291) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +8 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +119 -0
  5. data/Rakefile +39 -0
  6. data/bin/commonmarker +41 -0
  7. data/commonmarker.gemspec +30 -0
  8. data/ext/commonmarker/cmark/CMakeLists.txt +25 -0
  9. data/ext/commonmarker/cmark/COPYING +192 -0
  10. data/ext/commonmarker/cmark/FindAsan.cmake +74 -0
  11. data/ext/commonmarker/cmark/Makefile +170 -0
  12. data/ext/commonmarker/cmark/Makefile.nmake +36 -0
  13. data/ext/commonmarker/cmark/README.md +169 -0
  14. data/ext/commonmarker/cmark/api_test/CMakeLists.txt +25 -0
  15. data/ext/commonmarker/cmark/api_test/cplusplus.cpp +15 -0
  16. data/ext/commonmarker/cmark/api_test/cplusplus.h +17 -0
  17. data/ext/commonmarker/cmark/api_test/harness.c +102 -0
  18. data/ext/commonmarker/cmark/api_test/harness.h +42 -0
  19. data/ext/commonmarker/cmark/api_test/main.c +700 -0
  20. data/ext/commonmarker/cmark/appveyor.yml +15 -0
  21. data/ext/commonmarker/cmark/bench/statistics.py +595 -0
  22. data/ext/commonmarker/cmark/bench/stats.py +19 -0
  23. data/ext/commonmarker/cmark/benchmarks.md +33 -0
  24. data/ext/commonmarker/cmark/build/CMakeCache.txt +362 -0
  25. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeCCompiler.cmake +63 -0
  26. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeCXXCompiler.cmake +64 -0
  27. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_C.bin +0 -0
  28. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeDetermineCompilerABI_CXX.bin +0 -0
  29. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CMakeSystem.cmake +15 -0
  30. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdC/CMakeCCompilerId.c +499 -0
  31. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdC/a.out +0 -0
  32. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdCXX/CMakeCXXCompilerId.cpp +489 -0
  33. data/ext/commonmarker/cmark/build/CMakeFiles/3.2.2/CompilerIdCXX/a.out +0 -0
  34. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  35. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeError.log +30 -0
  36. data/ext/commonmarker/cmark/build/CMakeFiles/CMakeOutput.log +598 -0
  37. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile.cmake +77 -0
  38. data/ext/commonmarker/cmark/build/CMakeFiles/Makefile2 +268 -0
  39. data/ext/commonmarker/cmark/build/CMakeFiles/TargetDirectories.txt +4 -0
  40. data/ext/commonmarker/cmark/build/CMakeFiles/cmake.check_cache +1 -0
  41. data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.bin +0 -0
  42. data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.c +34 -0
  43. data/ext/commonmarker/cmark/build/CMakeFiles/feature_tests.cxx +405 -0
  44. data/ext/commonmarker/cmark/build/CMakeFiles/progress.marks +1 -0
  45. data/ext/commonmarker/cmark/build/CTestTestfile.cmake +10 -0
  46. data/ext/commonmarker/cmark/build/Makefile +237 -0
  47. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  48. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/C.includecache +92 -0
  49. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/CXX.includecache +36 -0
  50. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/DependInfo.cmake +29 -0
  51. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/build.make +155 -0
  52. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cmake_clean.cmake +12 -0
  53. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/cplusplus.cpp.o +0 -0
  54. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.internal +25 -0
  55. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/depend.make +25 -0
  56. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/flags.make +13 -0
  57. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/harness.c.o +0 -0
  58. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/link.txt +1 -0
  59. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/main.c.o +0 -0
  60. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/api_test.dir/progress.make +4 -0
  61. data/ext/commonmarker/cmark/build/api_test/CMakeFiles/progress.marks +1 -0
  62. data/ext/commonmarker/cmark/build/api_test/Makefile +277 -0
  63. data/ext/commonmarker/cmark/build/api_test/api_test +0 -0
  64. data/ext/commonmarker/cmark/build/api_test/cmake_install.cmake +29 -0
  65. data/ext/commonmarker/cmark/build/cmake_install.cmake +48 -0
  66. data/ext/commonmarker/cmark/build/man/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  67. data/ext/commonmarker/cmark/build/man/CMakeFiles/progress.marks +1 -0
  68. data/ext/commonmarker/cmark/build/man/Makefile +181 -0
  69. data/ext/commonmarker/cmark/build/man/cmake_install.cmake +37 -0
  70. data/ext/commonmarker/cmark/build/src/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  71. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/C.includecache +422 -0
  72. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/DependInfo.cmake +39 -0
  73. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/blocks.c.o +0 -0
  74. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/buffer.c.o +0 -0
  75. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/build.make +544 -0
  76. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmake_clean.cmake +27 -0
  77. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmark.c.o +0 -0
  78. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/cmark_ctype.c.o +0 -0
  79. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/commonmark.c.o +0 -0
  80. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.internal +177 -0
  81. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/depend.make +177 -0
  82. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/flags.make +8 -0
  83. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_href_e.c.o +0 -0
  84. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_html_e.c.o +0 -0
  85. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/houdini_html_u.c.o +0 -0
  86. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/html.c.o +0 -0
  87. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/inlines.c.o +0 -0
  88. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/iterator.c.o +0 -0
  89. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/link.txt +1 -0
  90. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/main.c.o +0 -0
  91. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/man.c.o +0 -0
  92. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/node.c.o +0 -0
  93. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/progress.make +19 -0
  94. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/references.c.o +0 -0
  95. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/scanners.c.o +0 -0
  96. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/utf8.c.o +0 -0
  97. data/ext/commonmarker/cmark/build/src/CMakeFiles/cmark.dir/xml.c.o +0 -0
  98. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/C.includecache +394 -0
  99. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/DependInfo.cmake +44 -0
  100. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/blocks.c.o +0 -0
  101. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/buffer.c.o +0 -0
  102. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/build.make +522 -0
  103. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmake_clean.cmake +27 -0
  104. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmark.c.o +0 -0
  105. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/cmark_ctype.c.o +0 -0
  106. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/commonmark.c.o +0 -0
  107. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.internal +169 -0
  108. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/depend.make +169 -0
  109. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/flags.make +8 -0
  110. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_href_e.c.o +0 -0
  111. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_html_e.c.o +0 -0
  112. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/houdini_html_u.c.o +0 -0
  113. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/html.c.o +0 -0
  114. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/inlines.c.o +0 -0
  115. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/iterator.c.o +0 -0
  116. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/link.txt +1 -0
  117. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/man.c.o +0 -0
  118. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/node.c.o +0 -0
  119. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/progress.make +18 -0
  120. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/references.c.o +0 -0
  121. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/scanners.c.o +0 -0
  122. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/utf8.c.o +0 -0
  123. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark.dir/xml.c.o +0 -0
  124. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/C.includecache +394 -0
  125. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/DependInfo.cmake +38 -0
  126. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/blocks.c.o +0 -0
  127. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/buffer.c.o +0 -0
  128. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/build.make +519 -0
  129. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean.cmake +26 -0
  130. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmake_clean_target.cmake +3 -0
  131. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark.c.o +0 -0
  132. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/cmark_ctype.c.o +0 -0
  133. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/commonmark.c.o +0 -0
  134. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.internal +169 -0
  135. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/depend.make +169 -0
  136. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/flags.make +8 -0
  137. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_href_e.c.o +0 -0
  138. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_e.c.o +0 -0
  139. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/houdini_html_u.c.o +0 -0
  140. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/html.c.o +0 -0
  141. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/inlines.c.o +0 -0
  142. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/iterator.c.o +0 -0
  143. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/link.txt +2 -0
  144. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/man.c.o +0 -0
  145. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/node.c.o +0 -0
  146. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/progress.make +18 -0
  147. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/references.c.o +0 -0
  148. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/scanners.c.o +0 -0
  149. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/utf8.c.o +0 -0
  150. data/ext/commonmarker/cmark/build/src/CMakeFiles/libcmark_static.dir/xml.c.o +0 -0
  151. data/ext/commonmarker/cmark/build/src/CMakeFiles/progress.marks +1 -0
  152. data/ext/commonmarker/cmark/build/src/Makefile +814 -0
  153. data/ext/commonmarker/cmark/build/src/cmake_install.cmake +69 -0
  154. data/ext/commonmarker/cmark/build/src/cmark +0 -0
  155. data/ext/commonmarker/cmark/build/src/cmark_export.h +41 -0
  156. data/ext/commonmarker/cmark/build/src/cmark_version.h +7 -0
  157. data/ext/commonmarker/cmark/build/src/config.h +23 -0
  158. data/ext/commonmarker/cmark/build/src/libcmark.0.19.0.dylib +0 -0
  159. data/ext/commonmarker/cmark/build/src/libcmark.a +0 -0
  160. data/ext/commonmarker/cmark/build/src/libcmark.dylib +0 -0
  161. data/ext/commonmarker/cmark/build/src/libcmark.pc +10 -0
  162. data/ext/commonmarker/cmark/build/testdir/CMakeFiles/CMakeDirectoryInformation.cmake +16 -0
  163. data/ext/commonmarker/cmark/build/testdir/CMakeFiles/progress.marks +1 -0
  164. data/ext/commonmarker/cmark/build/testdir/CTestTestfile.cmake +12 -0
  165. data/ext/commonmarker/cmark/build/testdir/Makefile +181 -0
  166. data/ext/commonmarker/cmark/build/testdir/cmake_install.cmake +29 -0
  167. data/ext/commonmarker/cmark/changelog.txt +153 -0
  168. data/ext/commonmarker/cmark/data/CaseFolding-3.2.0.txt +912 -0
  169. data/ext/commonmarker/cmark/man/CMakeLists.txt +8 -0
  170. data/ext/commonmarker/cmark/man/make_man_page.py +131 -0
  171. data/ext/commonmarker/cmark/man/man1/cmark.1 +54 -0
  172. data/ext/commonmarker/cmark/man/man3/cmark.3 +583 -0
  173. data/ext/commonmarker/cmark/nmake.bat +1 -0
  174. data/ext/commonmarker/cmark/src/CMakeLists.txt +166 -0
  175. data/ext/commonmarker/cmark/src/bench.h +27 -0
  176. data/ext/commonmarker/cmark/src/blocks.c +887 -0
  177. data/ext/commonmarker/cmark/src/buffer.c +381 -0
  178. data/ext/commonmarker/cmark/src/buffer.h +113 -0
  179. data/ext/commonmarker/cmark/src/case_fold_switch.inc +2637 -0
  180. data/ext/commonmarker/cmark/src/chunk.h +110 -0
  181. data/ext/commonmarker/cmark/src/cmark.c +24 -0
  182. data/ext/commonmarker/cmark/src/cmark.h +565 -0
  183. data/ext/commonmarker/cmark/src/cmark_ctype.c +53 -0
  184. data/ext/commonmarker/cmark/src/cmark_ctype.h +24 -0
  185. data/ext/commonmarker/cmark/src/cmark_version.h.in +7 -0
  186. data/ext/commonmarker/cmark/src/commonmark.c +607 -0
  187. data/ext/commonmarker/cmark/src/config.h.in +23 -0
  188. data/ext/commonmarker/cmark/src/debug.h +36 -0
  189. data/ext/commonmarker/cmark/src/houdini.h +52 -0
  190. data/ext/commonmarker/cmark/src/houdini_href_e.c +107 -0
  191. data/ext/commonmarker/cmark/src/houdini_html_e.c +81 -0
  192. data/ext/commonmarker/cmark/src/houdini_html_u.c +116 -0
  193. data/ext/commonmarker/cmark/src/html.c +322 -0
  194. data/ext/commonmarker/cmark/src/html_unescape.gperf +2130 -0
  195. data/ext/commonmarker/cmark/src/html_unescape.h +13375 -0
  196. data/ext/commonmarker/cmark/src/inlines.c +1147 -0
  197. data/ext/commonmarker/cmark/src/inlines.h +19 -0
  198. data/ext/commonmarker/cmark/src/iterator.c +148 -0
  199. data/ext/commonmarker/cmark/src/iterator.h +25 -0
  200. data/ext/commonmarker/cmark/src/libcmark.pc.in +10 -0
  201. data/ext/commonmarker/cmark/src/main.c +191 -0
  202. data/ext/commonmarker/cmark/src/man.c +287 -0
  203. data/ext/commonmarker/cmark/src/node.c +873 -0
  204. data/ext/commonmarker/cmark/src/node.h +82 -0
  205. data/ext/commonmarker/cmark/src/parser.h +29 -0
  206. data/ext/commonmarker/cmark/src/references.c +154 -0
  207. data/ext/commonmarker/cmark/src/references.h +37 -0
  208. data/ext/commonmarker/cmark/src/scanners.c +15291 -0
  209. data/ext/commonmarker/cmark/src/scanners.h +41 -0
  210. data/ext/commonmarker/cmark/src/scanners.re +247 -0
  211. data/ext/commonmarker/cmark/src/utf8.c +452 -0
  212. data/ext/commonmarker/cmark/src/utf8.h +22 -0
  213. data/ext/commonmarker/cmark/src/xml.c +170 -0
  214. data/ext/commonmarker/cmark/test/CMakeLists.txt +53 -0
  215. data/ext/commonmarker/cmark/test/afl_dictionary/asterisk +1 -0
  216. data/ext/commonmarker/cmark/test/afl_dictionary/attr_generic +1 -0
  217. data/ext/commonmarker/cmark/test/afl_dictionary/attr_href +1 -0
  218. data/ext/commonmarker/cmark/test/afl_dictionary/attr_xml_lang +1 -0
  219. data/ext/commonmarker/cmark/test/afl_dictionary/attr_xmlns +1 -0
  220. data/ext/commonmarker/cmark/test/afl_dictionary/backslash +1 -0
  221. data/ext/commonmarker/cmark/test/afl_dictionary/backtick +1 -0
  222. data/ext/commonmarker/cmark/test/afl_dictionary/colon +1 -0
  223. data/ext/commonmarker/cmark/test/afl_dictionary/dashes +1 -0
  224. data/ext/commonmarker/cmark/test/afl_dictionary/double_quote +1 -0
  225. data/ext/commonmarker/cmark/test/afl_dictionary/entity_builtin +1 -0
  226. data/ext/commonmarker/cmark/test/afl_dictionary/entity_decimal +1 -0
  227. data/ext/commonmarker/cmark/test/afl_dictionary/entity_external +1 -0
  228. data/ext/commonmarker/cmark/test/afl_dictionary/entity_hex +1 -0
  229. data/ext/commonmarker/cmark/test/afl_dictionary/equals +1 -0
  230. data/ext/commonmarker/cmark/test/afl_dictionary/exclamation +1 -0
  231. data/ext/commonmarker/cmark/test/afl_dictionary/greater_than +1 -0
  232. data/ext/commonmarker/cmark/test/afl_dictionary/hash +1 -0
  233. data/ext/commonmarker/cmark/test/afl_dictionary/hyphen +0 -0
  234. data/ext/commonmarker/cmark/test/afl_dictionary/indent +1 -0
  235. data/ext/commonmarker/cmark/test/afl_dictionary/left_bracket +1 -0
  236. data/ext/commonmarker/cmark/test/afl_dictionary/left_paren +1 -0
  237. data/ext/commonmarker/cmark/test/afl_dictionary/less_than +1 -0
  238. data/ext/commonmarker/cmark/test/afl_dictionary/plus +1 -0
  239. data/ext/commonmarker/cmark/test/afl_dictionary/right_bracket +1 -0
  240. data/ext/commonmarker/cmark/test/afl_dictionary/right_paren +1 -0
  241. data/ext/commonmarker/cmark/test/afl_dictionary/single_quote +1 -0
  242. data/ext/commonmarker/cmark/test/afl_dictionary/string_any +1 -0
  243. data/ext/commonmarker/cmark/test/afl_dictionary/string_brackets +1 -0
  244. data/ext/commonmarker/cmark/test/afl_dictionary/string_cdata +1 -0
  245. data/ext/commonmarker/cmark/test/afl_dictionary/string_dashes +1 -0
  246. data/ext/commonmarker/cmark/test/afl_dictionary/string_empty_dblquotes +1 -0
  247. data/ext/commonmarker/cmark/test/afl_dictionary/string_empty_quotes +1 -0
  248. data/ext/commonmarker/cmark/test/afl_dictionary/string_idrefs +1 -0
  249. data/ext/commonmarker/cmark/test/afl_dictionary/string_parentheses +1 -0
  250. data/ext/commonmarker/cmark/test/afl_dictionary/string_pcdata +1 -0
  251. data/ext/commonmarker/cmark/test/afl_dictionary/tag_cdata +1 -0
  252. data/ext/commonmarker/cmark/test/afl_dictionary/tag_close +1 -0
  253. data/ext/commonmarker/cmark/test/afl_dictionary/tag_doctype +1 -0
  254. data/ext/commonmarker/cmark/test/afl_dictionary/tag_element +1 -0
  255. data/ext/commonmarker/cmark/test/afl_dictionary/tag_entity +1 -0
  256. data/ext/commonmarker/cmark/test/afl_dictionary/tag_notation +1 -0
  257. data/ext/commonmarker/cmark/test/afl_dictionary/tag_open +1 -0
  258. data/ext/commonmarker/cmark/test/afl_dictionary/tag_open_close +1 -0
  259. data/ext/commonmarker/cmark/test/afl_dictionary/tag_open_exclamation +1 -0
  260. data/ext/commonmarker/cmark/test/afl_dictionary/tag_open_q +1 -0
  261. data/ext/commonmarker/cmark/test/afl_dictionary/tag_sq2_close +1 -0
  262. data/ext/commonmarker/cmark/test/afl_dictionary/tag_xml_q +1 -0
  263. data/ext/commonmarker/cmark/test/afl_dictionary/underscore +1 -0
  264. data/ext/commonmarker/cmark/test/afl_test_cases/test.md +36 -0
  265. data/ext/commonmarker/cmark/test/cmark.py +40 -0
  266. data/ext/commonmarker/cmark/test/normalize.py +179 -0
  267. data/ext/commonmarker/cmark/test/pathological_tests.py +63 -0
  268. data/ext/commonmarker/cmark/test/roundtrip.sh +2 -0
  269. data/ext/commonmarker/cmark/test/smart_punct.txt +96 -0
  270. data/ext/commonmarker/cmark/test/spec.txt +7505 -0
  271. data/ext/commonmarker/cmark/test/spec_tests.py +139 -0
  272. data/ext/commonmarker/cmark/toolchain-mingw32.cmake +17 -0
  273. data/ext/commonmarker/cmark/tools/mkcasefold.pl +22 -0
  274. data/ext/commonmarker/cmark/wrappers/wrapper.lua +239 -0
  275. data/ext/commonmarker/cmark/wrappers/wrapper.py +37 -0
  276. data/ext/commonmarker/cmark/wrappers/wrapper.rb +15 -0
  277. data/ext/commonmarker/cmark/wrappers/wrapper.rkt +190 -0
  278. data/ext/commonmarker/commonmarker.c +165 -0
  279. data/ext/commonmarker/commonmarker.h +11 -0
  280. data/ext/commonmarker/extconf.rb +18 -0
  281. data/lib/commonmarker/config.rb +20 -0
  282. data/lib/commonmarker/version.rb +3 -0
  283. data/lib/commonmarker.rb +588 -0
  284. data/test/benchmark.rb +30 -0
  285. data/test/spec_tests.json +4074 -0
  286. data/test/test_basics.rb +44 -0
  287. data/test/test_helper.rb +5 -0
  288. data/test/test_maliciousness.rb +9 -0
  289. data/test/test_pathological_inputs.rb +52 -0
  290. data/test/test_spec.rb +20 -0
  291. metadata +399 -0
@@ -0,0 +1,19 @@
1
+ #ifndef CMARK_INLINES_H
2
+ #define CMARK_INLINES_H
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ unsigned char *cmark_clean_url(cmark_chunk *url);
9
+ unsigned char *cmark_clean_title(cmark_chunk *title);
10
+
11
+ void cmark_parse_inlines(cmark_node* parent, cmark_reference_map *refmap, int options);
12
+
13
+ int cmark_parse_reference_inline(cmark_strbuf *input, cmark_reference_map *refmap);
14
+
15
+ #ifdef __cplusplus
16
+ }
17
+ #endif
18
+
19
+ #endif
@@ -0,0 +1,148 @@
1
+ #include <assert.h>
2
+ #include <stdlib.h>
3
+
4
+ #include "config.h"
5
+ #include "node.h"
6
+ #include "cmark.h"
7
+ #include "iterator.h"
8
+
9
+ static const int S_leaf_mask =
10
+ (1 << CMARK_NODE_HTML) |
11
+ (1 << CMARK_NODE_HRULE) |
12
+ (1 << CMARK_NODE_CODE_BLOCK) |
13
+ (1 << CMARK_NODE_TEXT) |
14
+ (1 << CMARK_NODE_SOFTBREAK) |
15
+ (1 << CMARK_NODE_LINEBREAK) |
16
+ (1 << CMARK_NODE_CODE) |
17
+ (1 << CMARK_NODE_INLINE_HTML);
18
+
19
+ cmark_iter*
20
+ cmark_iter_new(cmark_node *root)
21
+ {
22
+ if (root == NULL) {
23
+ return NULL;
24
+ }
25
+ cmark_iter *iter = (cmark_iter*)malloc(sizeof(cmark_iter));
26
+ if (iter == NULL) {
27
+ return NULL;
28
+ }
29
+ iter->root = root;
30
+ iter->cur.ev_type = CMARK_EVENT_NONE;
31
+ iter->cur.node = NULL;
32
+ iter->next.ev_type = CMARK_EVENT_ENTER;
33
+ iter->next.node = root;
34
+ return iter;
35
+ }
36
+
37
+ void
38
+ cmark_iter_free(cmark_iter *iter)
39
+ {
40
+ free(iter);
41
+ }
42
+
43
+ static bool
44
+ S_is_leaf(cmark_node *node)
45
+ {
46
+ return (1 << node->type) & S_leaf_mask;
47
+ }
48
+
49
+ cmark_event_type
50
+ cmark_iter_next(cmark_iter *iter)
51
+ {
52
+ cmark_event_type ev_type = iter->next.ev_type;
53
+ cmark_node *node = iter->next.node;
54
+
55
+ iter->cur.ev_type = ev_type;
56
+ iter->cur.node = node;
57
+
58
+ if (ev_type == CMARK_EVENT_DONE) {
59
+ return ev_type;
60
+ }
61
+
62
+ /* roll forward to next item, setting both fields */
63
+ if (ev_type == CMARK_EVENT_ENTER && !S_is_leaf(node)) {
64
+ if (node->first_child == NULL) {
65
+ /* stay on this node but exit */
66
+ iter->next.ev_type = CMARK_EVENT_EXIT;
67
+ } else {
68
+ iter->next.ev_type = CMARK_EVENT_ENTER;
69
+ iter->next.node = node->first_child;
70
+ }
71
+ } else if (node == iter->root) {
72
+ /* don't move past root */
73
+ iter->next.ev_type = CMARK_EVENT_DONE;
74
+ iter->next.node = NULL;
75
+ } else if (node->next) {
76
+ iter->next.ev_type = CMARK_EVENT_ENTER;
77
+ iter->next.node = node->next;
78
+ } else if (node->parent) {
79
+ iter->next.ev_type = CMARK_EVENT_EXIT;
80
+ iter->next.node = node->parent;
81
+ } else {
82
+ assert(false);
83
+ iter->next.ev_type = CMARK_EVENT_DONE;
84
+ iter->next.node = NULL;
85
+ }
86
+
87
+ return ev_type;
88
+ }
89
+
90
+ void
91
+ cmark_iter_reset(cmark_iter *iter, cmark_node *current,
92
+ cmark_event_type event_type)
93
+ {
94
+ iter->next.ev_type = event_type;
95
+ iter->next.node = current;
96
+ cmark_iter_next(iter);
97
+ }
98
+
99
+ cmark_node*
100
+ cmark_iter_get_node(cmark_iter *iter)
101
+ {
102
+ return iter->cur.node;
103
+ }
104
+
105
+ cmark_event_type
106
+ cmark_iter_get_event_type(cmark_iter *iter)
107
+ {
108
+ return iter->cur.ev_type;
109
+ }
110
+
111
+ cmark_node*
112
+ cmark_iter_get_root(cmark_iter *iter)
113
+ {
114
+ return iter->root;
115
+ }
116
+
117
+
118
+ void cmark_consolidate_text_nodes(cmark_node *root)
119
+ {
120
+ cmark_iter *iter = cmark_iter_new(root);
121
+ cmark_strbuf buf = GH_BUF_INIT;
122
+ cmark_event_type ev_type;
123
+ cmark_node *cur, *tmp, *next;
124
+
125
+ while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
126
+ cur = cmark_iter_get_node(iter);
127
+ if (ev_type == CMARK_EVENT_ENTER &&
128
+ cur->type == CMARK_NODE_TEXT &&
129
+ cur->next &&
130
+ cur->next->type == CMARK_NODE_TEXT) {
131
+ cmark_strbuf_clear(&buf);
132
+ cmark_strbuf_put(&buf, cur->as.literal.data, cur->as.literal.len);
133
+ tmp = cur->next;
134
+ while (tmp && tmp->type == CMARK_NODE_TEXT) {
135
+ cmark_iter_next(iter); // advance pointer
136
+ cmark_strbuf_put(&buf, tmp->as.literal.data, tmp->as.literal.len);
137
+ next = tmp->next;
138
+ cmark_node_free(tmp);
139
+ tmp = next;
140
+ }
141
+ cmark_strbuf_putc(&buf, 0);
142
+ cmark_node_set_literal(cur, (char *)buf.ptr);
143
+ }
144
+ }
145
+
146
+ cmark_strbuf_free(&buf);
147
+ cmark_iter_free(iter);
148
+ }
@@ -0,0 +1,25 @@
1
+ #ifndef CMARK_ITERATOR_H
2
+ #define CMARK_ITERATOR_H
3
+
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #include "cmark.h"
9
+
10
+ typedef struct {
11
+ cmark_event_type ev_type;
12
+ cmark_node *node;
13
+ } cmark_iter_state;
14
+
15
+ struct cmark_iter {
16
+ cmark_node *root;
17
+ cmark_iter_state cur;
18
+ cmark_iter_state next;
19
+ };
20
+
21
+ #ifdef __cplusplus
22
+ }
23
+ #endif
24
+
25
+ #endif
@@ -0,0 +1,10 @@
1
+ prefix=@CMAKE_INSTALL_PREFIX@
2
+ exec_prefix=@CMAKE_INSTALL_PREFIX@
3
+ libdir=@CMAKE_INSTALL_PREFIX@/lib
4
+ includedir=@CMAKE_INSTALL_PREFIX@/include
5
+
6
+ Name: libcmark
7
+ Description: CommonMark parsing, rendering, and manipulation
8
+ Version: @PROJECT_VERSION@
9
+ Libs: -L${libdir} -lcmark
10
+ Cflags: -I${includedir}
@@ -0,0 +1,191 @@
1
+ #include <stdlib.h>
2
+ #include <stdio.h>
3
+ #include <string.h>
4
+ #include <errno.h>
5
+ #include "config.h"
6
+ #include "cmark.h"
7
+ #include "debug.h"
8
+ #include "bench.h"
9
+
10
+ #if defined(_WIN32) && !defined(__CYGWIN__)
11
+ #include <io.h>
12
+ #include <fcntl.h>
13
+ #endif
14
+
15
+ typedef enum {
16
+ FORMAT_NONE,
17
+ FORMAT_HTML,
18
+ FORMAT_XML,
19
+ FORMAT_MAN,
20
+ FORMAT_COMMONMARK
21
+ } writer_format;
22
+
23
+ void print_usage()
24
+ {
25
+ printf("Usage: cmark [FILE*]\n");
26
+ printf("Options:\n");
27
+ printf(" --to, -t FORMAT Specify output format (html, xml, man, commonmark)\n");
28
+ printf(" --width WIDTH Specify wrap width (default 0 = nowrap)\n");
29
+ printf(" --sourcepos Include source position attribute\n");
30
+ printf(" --hardbreaks Treat newlines as hard line breaks\n");
31
+ printf(" --smart Use smart punctuation\n");
32
+ printf(" --normalize Consolidate adjacent text nodes\n");
33
+ printf(" --help, -h Print usage information\n");
34
+ printf(" --version Print version\n");
35
+ }
36
+
37
+ static void print_document(cmark_node *document, writer_format writer,
38
+ int options, int width)
39
+ {
40
+ char *result;
41
+
42
+ switch (writer) {
43
+ case FORMAT_HTML:
44
+ result = cmark_render_html(document, options);
45
+ break;
46
+ case FORMAT_XML:
47
+ result = cmark_render_xml(document, options);
48
+ break;
49
+ case FORMAT_MAN:
50
+ result = cmark_render_man(document, options);
51
+ break;
52
+ case FORMAT_COMMONMARK:
53
+ result = cmark_render_commonmark(document, options, width);
54
+ break;
55
+ default:
56
+ fprintf(stderr, "Unknown format %d\n", writer);
57
+ exit(1);
58
+ }
59
+ printf("%s", result);
60
+ free(result);
61
+ }
62
+
63
+ int main(int argc, char *argv[])
64
+ {
65
+ int i, numfps = 0;
66
+ int *files;
67
+ char buffer[4096];
68
+ cmark_parser *parser;
69
+ size_t bytes;
70
+ cmark_node *document;
71
+ int width = 0;
72
+ char *unparsed;
73
+ writer_format writer = FORMAT_HTML;
74
+ int options = CMARK_OPT_DEFAULT;
75
+
76
+ #if defined(_WIN32) && !defined(__CYGWIN__)
77
+ _setmode(_fileno(stdout), _O_BINARY);
78
+ #endif
79
+
80
+ files = (int *)malloc(argc * sizeof(*files));
81
+
82
+ for (i = 1; i < argc; i++) {
83
+ if (strcmp(argv[i], "--version") == 0) {
84
+ printf("cmark %s", CMARK_VERSION_STRING);
85
+ printf(" - CommonMark converter\n(C) 2014, 2015 John MacFarlane\n");
86
+ exit(0);
87
+ } else if (strcmp(argv[i], "--sourcepos") == 0) {
88
+ options |= CMARK_OPT_SOURCEPOS;
89
+ } else if (strcmp(argv[i], "--hardbreaks") == 0) {
90
+ options |= CMARK_OPT_HARDBREAKS;
91
+ } else if (strcmp(argv[i], "--smart") == 0) {
92
+ options |= CMARK_OPT_SMART;
93
+ } else if (strcmp(argv[i], "--normalize") == 0) {
94
+ options |= CMARK_OPT_NORMALIZE;
95
+ } else if ((strcmp(argv[i], "--help") == 0) ||
96
+ (strcmp(argv[i], "-h") == 0)) {
97
+ print_usage();
98
+ exit(0);
99
+ } else if (strcmp(argv[i], "--width") == 0) {
100
+ i += 1;
101
+ if (i < argc) {
102
+ width = (int)strtol(argv[i], &unparsed, 10);
103
+ if (unparsed && strlen(unparsed) > 0) {
104
+ fprintf(stderr,
105
+ "failed parsing width '%s' at '%s'\n",
106
+ argv[i], unparsed);
107
+ exit(1);
108
+ }
109
+ } else {
110
+ fprintf(stderr,
111
+ "--width requires an argument\n");
112
+ exit(1);
113
+ }
114
+ } else if ((strcmp(argv[i], "-t") == 0) ||
115
+ (strcmp(argv[i], "--to") == 0)) {
116
+ i += 1;
117
+ if (i < argc) {
118
+ if (strcmp(argv[i], "man") == 0) {
119
+ writer = FORMAT_MAN;
120
+ } else if (strcmp(argv[i], "html") == 0) {
121
+ writer = FORMAT_HTML;
122
+ } else if (strcmp(argv[i], "xml") == 0) {
123
+ writer = FORMAT_XML;
124
+ } else if (strcmp(argv[i], "commonmark") == 0) {
125
+ writer = FORMAT_COMMONMARK;
126
+ } else {
127
+ fprintf(stderr,
128
+ "Unknown format %s\n", argv[i]);
129
+ exit(1);
130
+ }
131
+ } else {
132
+ fprintf(stderr, "No argument provided for %s\n",
133
+ argv[i - 1]);
134
+ exit(1);
135
+ }
136
+ } else if (*argv[i] == '-') {
137
+ print_usage();
138
+ exit(1);
139
+ } else { // treat as file argument
140
+ files[numfps++] = i;
141
+ }
142
+ }
143
+
144
+ parser = cmark_parser_new(options);
145
+ for (i = 0; i < numfps; i++) {
146
+ FILE *fp = fopen(argv[files[i]], "r");
147
+ if (fp == NULL) {
148
+ fprintf(stderr, "Error opening file %s: %s\n",
149
+ argv[files[i]], strerror(errno));
150
+ exit(1);
151
+ }
152
+
153
+ start_timer();
154
+ while ((bytes = fread(buffer, 1, sizeof(buffer), fp)) > 0) {
155
+ cmark_parser_feed(parser, buffer, bytes);
156
+ if (bytes < sizeof(buffer)) {
157
+ break;
158
+ }
159
+ }
160
+ end_timer("processing lines");
161
+
162
+ fclose(fp);
163
+ }
164
+
165
+ if (numfps == 0) {
166
+
167
+ while ((bytes = fread(buffer, 1, sizeof(buffer), stdin)) > 0) {
168
+ cmark_parser_feed(parser, buffer, bytes);
169
+ if (bytes < sizeof(buffer)) {
170
+ break;
171
+ }
172
+ }
173
+ }
174
+
175
+ start_timer();
176
+ document = cmark_parser_finish(parser);
177
+ end_timer("finishing document");
178
+ cmark_parser_free(parser);
179
+
180
+ start_timer();
181
+ print_document(document, writer, options, width);
182
+ end_timer("print_document");
183
+
184
+ start_timer();
185
+ cmark_node_free(document);
186
+ end_timer("free_blocks");
187
+
188
+ free(files);
189
+
190
+ return 0;
191
+ }
@@ -0,0 +1,287 @@
1
+ #include <stdlib.h>
2
+ #include <stdio.h>
3
+ #include <string.h>
4
+ #include <assert.h>
5
+
6
+ #include "config.h"
7
+ #include "cmark.h"
8
+ #include "node.h"
9
+ #include "buffer.h"
10
+ #include "utf8.h"
11
+
12
+ // Functions to convert cmark_nodes to groff man strings.
13
+
14
+ static void escape_man(cmark_strbuf *dest, const unsigned char *source, int length)
15
+ {
16
+ int32_t c;
17
+ int i = 0;
18
+ int len;
19
+ bool beginLine = true;
20
+
21
+ while (i < length) {
22
+ len = utf8proc_iterate(source + i, length - i, &c);
23
+ if (len == -1) { // error condition
24
+ return; // return without rendering anything
25
+ }
26
+ switch(c) {
27
+ case 46:
28
+ if (beginLine) {
29
+ cmark_strbuf_puts(dest, "\\&.");
30
+ } else {
31
+ utf8proc_encode_char(c, dest);
32
+ }
33
+ break;
34
+ case 39:
35
+ if (beginLine) {
36
+ cmark_strbuf_puts(dest, "\\&'");
37
+ } else {
38
+ utf8proc_encode_char(c, dest);
39
+ }
40
+ break;
41
+ case 45:
42
+ cmark_strbuf_puts(dest, "\\-");
43
+ break;
44
+ case 92:
45
+ cmark_strbuf_puts(dest, "\\e");
46
+ break;
47
+ case 8216: // left single quote
48
+ cmark_strbuf_puts(dest, "\\[oq]");
49
+ break;
50
+ case 8217: // right single quote
51
+ cmark_strbuf_puts(dest, "\\[cq]");
52
+ break;
53
+ case 8220: // left double quote
54
+ cmark_strbuf_puts(dest, "\\[lq]");
55
+ break;
56
+ case 8221: // right double quote
57
+ cmark_strbuf_puts(dest, "\\[rq]");
58
+ break;
59
+ case 8212: // em dash
60
+ cmark_strbuf_puts(dest, "\\[em]");
61
+ break;
62
+ case 8211: // en dash
63
+ cmark_strbuf_puts(dest, "\\[en]");
64
+ break;
65
+ default:
66
+ utf8proc_encode_char(c, dest);
67
+ }
68
+ beginLine = (c == 10);
69
+ i += len;
70
+ }
71
+ }
72
+
73
+ static inline void cr(cmark_strbuf *man)
74
+ {
75
+ if (man->size && man->ptr[man->size - 1] != '\n')
76
+ cmark_strbuf_putc(man, '\n');
77
+ }
78
+
79
+ struct render_state {
80
+ cmark_strbuf* man;
81
+ cmark_node *plain;
82
+ };
83
+
84
+ static int
85
+ S_render_node(cmark_node *node, cmark_event_type ev_type,
86
+ struct render_state *state)
87
+ {
88
+ cmark_node *tmp;
89
+ cmark_strbuf *man = state->man;
90
+ int list_number;
91
+ bool entering = (ev_type == CMARK_EVENT_ENTER);
92
+
93
+ if (state->plain == node) { // back at original node
94
+ state->plain = NULL;
95
+ }
96
+
97
+ if (state->plain != NULL) {
98
+ switch(node->type) {
99
+ case CMARK_NODE_TEXT:
100
+ case CMARK_NODE_CODE:
101
+ escape_man(man, node->as.literal.data,
102
+ node->as.literal.len);
103
+ break;
104
+
105
+ case CMARK_NODE_LINEBREAK:
106
+ case CMARK_NODE_SOFTBREAK:
107
+ cmark_strbuf_putc(man, ' ');
108
+ break;
109
+
110
+ default:
111
+ break;
112
+ }
113
+ return 1;
114
+ }
115
+
116
+ switch (node->type) {
117
+ case CMARK_NODE_DOCUMENT:
118
+ break;
119
+
120
+ case CMARK_NODE_BLOCK_QUOTE:
121
+ if (entering) {
122
+ cr(man);
123
+ cmark_strbuf_puts(man, ".RS");
124
+ cr(man);
125
+ } else {
126
+ cr(man);
127
+ cmark_strbuf_puts(man, ".RE");
128
+ cr(man);
129
+ }
130
+ break;
131
+
132
+ case CMARK_NODE_LIST:
133
+ break;
134
+
135
+ case CMARK_NODE_ITEM:
136
+ if (entering) {
137
+ cr(man);
138
+ cmark_strbuf_puts(man, ".IP ");
139
+ if (cmark_node_get_list_type(node->parent) ==
140
+ CMARK_BULLET_LIST) {
141
+ cmark_strbuf_puts(man, "\\[bu] 2");
142
+ } else {
143
+ list_number = cmark_node_get_list_start(node->parent);
144
+ tmp = node;
145
+ while (tmp->prev) {
146
+ tmp = tmp->prev;
147
+ list_number += 1;
148
+ }
149
+ cmark_strbuf_printf(man, "\"%d.\" 4", list_number);
150
+ }
151
+ cr(man);
152
+ } else {
153
+ cr(man);
154
+ }
155
+ break;
156
+
157
+ case CMARK_NODE_HEADER:
158
+ if (entering) {
159
+ cr(man);
160
+ cmark_strbuf_puts(man,
161
+ cmark_node_get_header_level(node) == 1 ?
162
+ ".SH" : ".SS");
163
+ cr(man);
164
+ } else {
165
+ cr(man);
166
+ }
167
+ break;
168
+
169
+ case CMARK_NODE_CODE_BLOCK:
170
+ cr(man);
171
+ cmark_strbuf_puts(man, ".IP\n.nf\n\\f[C]\n");
172
+ escape_man(man, node->as.code.literal.data,
173
+ node->as.code.literal.len);
174
+ cr(man);
175
+ cmark_strbuf_puts(man, "\\f[]\n.fi");
176
+ cr(man);
177
+ break;
178
+
179
+ case CMARK_NODE_HTML:
180
+ break;
181
+
182
+ case CMARK_NODE_HRULE:
183
+ cr(man);
184
+ cmark_strbuf_puts(man, ".PP\n * * * * *");
185
+ cr(man);
186
+ break;
187
+
188
+ case CMARK_NODE_PARAGRAPH:
189
+ if (entering) {
190
+ // no blank line if first paragraph in list:
191
+ if (node->parent &&
192
+ node->parent->type == CMARK_NODE_ITEM &&
193
+ node->prev == NULL) {
194
+ // no blank line or .PP
195
+ } else {
196
+ cr(man);
197
+ cmark_strbuf_puts(man, ".PP\n");
198
+ }
199
+ } else {
200
+ cr(man);
201
+ }
202
+ break;
203
+
204
+ case CMARK_NODE_TEXT:
205
+ escape_man(man, node->as.literal.data,
206
+ node->as.literal.len);
207
+ break;
208
+
209
+ case CMARK_NODE_LINEBREAK:
210
+ cmark_strbuf_puts(man, ".PD 0\n.P\n.PD");
211
+ cr(man);
212
+ break;
213
+
214
+ case CMARK_NODE_SOFTBREAK:
215
+ cmark_strbuf_putc(man, '\n');
216
+ break;
217
+
218
+ case CMARK_NODE_CODE:
219
+ cmark_strbuf_puts(man, "\\f[C]");
220
+ escape_man(man, node->as.literal.data, node->as.literal.len);
221
+ cmark_strbuf_puts(man, "\\f[]");
222
+ break;
223
+
224
+ case CMARK_NODE_INLINE_HTML:
225
+ break;
226
+
227
+ case CMARK_NODE_STRONG:
228
+ if (entering) {
229
+ cmark_strbuf_puts(man, "\\f[B]");
230
+ } else {
231
+ cmark_strbuf_puts(man, "\\f[]");
232
+ }
233
+ break;
234
+
235
+ case CMARK_NODE_EMPH:
236
+ if (entering) {
237
+ cmark_strbuf_puts(man, "\\f[I]");
238
+ } else {
239
+ cmark_strbuf_puts(man, "\\f[]");
240
+ }
241
+ break;
242
+
243
+ case CMARK_NODE_LINK:
244
+ if (!entering) {
245
+ cmark_strbuf_printf(man, " (%s)",
246
+ cmark_node_get_url(node));
247
+ }
248
+ break;
249
+
250
+ case CMARK_NODE_IMAGE:
251
+ if (entering) {
252
+ cmark_strbuf_puts(man, "[IMAGE: ");
253
+ state->plain = node;
254
+ } else {
255
+ cmark_strbuf_puts(man, "]");
256
+ }
257
+ break;
258
+
259
+ default:
260
+ assert(false);
261
+ break;
262
+ }
263
+
264
+ // cmark_strbuf_putc(man, 'x');
265
+ return 1;
266
+ }
267
+
268
+ char *cmark_render_man(cmark_node *root, int options)
269
+ {
270
+ char *result;
271
+ cmark_strbuf man = GH_BUF_INIT;
272
+ struct render_state state = { &man, NULL };
273
+ cmark_node *cur;
274
+ cmark_event_type ev_type;
275
+ cmark_iter *iter = cmark_iter_new(root);
276
+
277
+ if (options == 0) options = 0; // avoid warning about unused parameters
278
+
279
+ while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
280
+ cur = cmark_iter_get_node(iter);
281
+ S_render_node(cur, ev_type, &state);
282
+ }
283
+ result = (char *)cmark_strbuf_detach(&man);
284
+
285
+ cmark_iter_free(iter);
286
+ return result;
287
+ }