apex-ruby 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (501) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +119 -0
  3. data/apex-ruby.gemspec +31 -0
  4. data/ext/apex_ext/apex_ext.c +215 -0
  5. data/ext/apex_ext/apex_src/BENCHMARK.md +32 -0
  6. data/ext/apex_ext/apex_src/BENCHMARK_COMPARISON.md +67 -0
  7. data/ext/apex_ext/apex_src/CHANGELOG.md +2454 -0
  8. data/ext/apex_ext/apex_src/CMakeLists.txt +454 -0
  9. data/ext/apex_ext/apex_src/Dockerfile.linux-build +15 -0
  10. data/ext/apex_ext/apex_src/Formula/apex.rb +38 -0
  11. data/ext/apex_ext/apex_src/Info.plist.in +27 -0
  12. data/ext/apex_ext/apex_src/LICENSE +21 -0
  13. data/ext/apex_ext/apex_src/Package.swift +160 -0
  14. data/ext/apex_ext/apex_src/PackageSupport/README.md +17 -0
  15. data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/cmark-gfm_export.h +20 -0
  16. data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/cmark-gfm_version.h +14 -0
  17. data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/cmark_gfm_spm_stub.c +4 -0
  18. data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/config.h +41 -0
  19. data/ext/apex_ext/apex_src/README.md +452 -0
  20. data/ext/apex_ext/apex_src/VERSION +1 -0
  21. data/ext/apex_ext/apex_src/apex-header-2-rb@2x.webp +0 -0
  22. data/ext/apex_ext/apex_src/apex-plugins.json.example +20 -0
  23. data/ext/apex_ext/apex_src/apex.pc.in +11 -0
  24. data/ext/apex_ext/apex_src/cli/main.c +2720 -0
  25. data/ext/apex_ext/apex_src/debug_test.sh +22 -0
  26. data/ext/apex_ext/apex_src/docs/API_REFERENCE.md +451 -0
  27. data/ext/apex_ext/apex_src/docs/ARCHITECTURE.md +166 -0
  28. data/ext/apex_ext/apex_src/docs/CMARK_INTEGRATION.md +220 -0
  29. data/ext/apex_ext/apex_src/docs/CRITICMARKUP.md +501 -0
  30. data/ext/apex_ext/apex_src/docs/DEBUGGING.md +73 -0
  31. data/ext/apex_ext/apex_src/docs/FINAL_STATUS.md +391 -0
  32. data/ext/apex_ext/apex_src/docs/FINAL_STATUS_UPDATE.md +237 -0
  33. data/ext/apex_ext/apex_src/docs/FUTURE_FEATURES.md +456 -0
  34. data/ext/apex_ext/apex_src/docs/IAL_FEATURES.md +210 -0
  35. data/ext/apex_ext/apex_src/docs/IAL_STATUS.md +344 -0
  36. data/ext/apex_ext/apex_src/docs/INTEGRATION_EXAMPLE.m +144 -0
  37. data/ext/apex_ext/apex_src/docs/LIMITATIONS_RESOLVED.md +278 -0
  38. data/ext/apex_ext/apex_src/docs/OUTPUT_MODES.md +321 -0
  39. data/ext/apex_ext/apex_src/docs/PROGRESS.md +167 -0
  40. data/ext/apex_ext/apex_src/docs/STANDALONE_FEATURE.md +174 -0
  41. data/ext/apex_ext/apex_src/docs/TABLE_SPANS_STATUS.md +243 -0
  42. data/ext/apex_ext/apex_src/docs/TEST_COVERAGE.md +316 -0
  43. data/ext/apex_ext/apex_src/docs/USER_GUIDE.md +803 -0
  44. data/ext/apex_ext/apex_src/docs/WIKI_LINKS_ISSUE.md +91 -0
  45. data/ext/apex_ext/apex_src/documentation/README.md +160 -0
  46. data/ext/apex_ext/apex_src/documentation/docsets/Apex Command Line Options.cheatsheet.txt +365 -0
  47. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Info.plist +24 -0
  48. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/C-API.html +1737 -0
  49. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Citations.html +1420 -0
  50. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Command-Line-Options.html +3574 -0
  51. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Configuration.html +1603 -0
  52. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Credits.html +910 -0
  53. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Examples.html +1168 -0
  54. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Getting-Started.html +1003 -0
  55. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Header-IDs.html +1308 -0
  56. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Home.html +1078 -0
  57. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Inline-Attribute-Lists.html +1622 -0
  58. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Installation.html +1168 -0
  59. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Limitations-and-Roadmap.html +1698 -0
  60. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Metadata-Transforms.html +1531 -0
  61. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Modes.html +1980 -0
  62. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Multi-File-Documents.html +1368 -0
  63. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Pandoc-Integration.html +1151 -0
  64. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Plugins.html +2861 -0
  65. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Syntax.html +3981 -0
  66. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Troubleshooting.html +1454 -0
  67. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Usage.html +1200 -0
  68. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Xcode-Integration.html +2066 -0
  69. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/docSet.dsidx +0 -0
  70. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/optimizedIndex.dsidx +0 -0
  71. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/tempOptimizedIndex.dsidx +0 -0
  72. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Info.plist +22 -0
  73. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans.woff +0 -0
  74. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Bold.woff +0 -0
  75. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Bold_Italic.woff +0 -0
  76. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Extrabold.woff +0 -0
  77. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Extrabold_Italic.woff +0 -0
  78. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Italic.woff +0 -0
  79. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Semibold.woff +0 -0
  80. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Semibold_Italic.woff +0 -0
  81. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/index.html +914 -0
  82. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/style.css +399 -0
  83. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/docSet.dsidx +0 -0
  84. data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/optimizedIndex.dsidx +0 -0
  85. data/ext/apex_ext/apex_src/documentation/generate_app_docs.rb +772 -0
  86. data/ext/apex_ext/apex_src/documentation/generate_app_docs_ai.rb +678 -0
  87. data/ext/apex_ext/apex_src/documentation/generate_docset.rb +873 -0
  88. data/ext/apex_ext/apex_src/documentation/generate_single_html.rb +733 -0
  89. data/ext/apex_ext/apex_src/documentation/html/apex-docs.html +17073 -0
  90. data/ext/apex_ext/apex_src/documentation/shared_scripts.js +64 -0
  91. data/ext/apex_ext/apex_src/documentation/shared_styles.css +646 -0
  92. data/ext/apex_ext/apex_src/documentation/transform_for_app.example.md +260 -0
  93. data/ext/apex_ext/apex_src/examples/bracketed_spans_demo.md +119 -0
  94. data/ext/apex_ext/apex_src/examples/emoji_span_plugin.yml +11 -0
  95. data/ext/apex_ext/apex_src/examples/example.html +53 -0
  96. data/ext/apex_ext/apex_src/examples/example.md +85 -0
  97. data/ext/apex_ext/apex_src/examples/fenced_divs_demo.md +158 -0
  98. data/ext/apex_ext/apex_src/examples/kbd.md +8 -0
  99. data/ext/apex_ext/apex_src/examples/kbd_plugin.rb +250 -0
  100. data/ext/apex_ext/apex_src/examples/kbd_plugin.yml +9 -0
  101. data/ext/apex_ext/apex_src/icon/apexicon-outline-black.png +0 -0
  102. data/ext/apex_ext/apex_src/icon/apexicon-outline-black@2x.png +0 -0
  103. data/ext/apex_ext/apex_src/icon/apexicon-outline-mark.png +0 -0
  104. data/ext/apex_ext/apex_src/icon/apexicon-outline-mark@2x.png +0 -0
  105. data/ext/apex_ext/apex_src/icon/apexicon-outline-white.png +0 -0
  106. data/ext/apex_ext/apex_src/icon/apexicon-outline-white@2x.png +0 -0
  107. data/ext/apex_ext/apex_src/icon/apexicon.png +0 -0
  108. data/ext/apex_ext/apex_src/icon/apexicon@2x.png +0 -0
  109. data/ext/apex_ext/apex_src/include/apex/apex.h +247 -0
  110. data/ext/apex_ext/apex_src/include/apex/buffer.h +93 -0
  111. data/ext/apex_ext/apex_src/include/apex/module.modulemap +16 -0
  112. data/ext/apex_ext/apex_src/include/apex/parser.h +150 -0
  113. data/ext/apex_ext/apex_src/include/apex/renderer.h +39 -0
  114. data/ext/apex_ext/apex_src/man/apex-config.5 +374 -0
  115. data/ext/apex_ext/apex_src/man/apex-config.5.md +260 -0
  116. data/ext/apex_ext/apex_src/man/apex-plugins.7 +456 -0
  117. data/ext/apex_ext/apex_src/man/apex-plugins.7.md +365 -0
  118. data/ext/apex_ext/apex_src/man/apex.1 +828 -0
  119. data/ext/apex_ext/apex_src/man/apex.1.md +643 -0
  120. data/ext/apex_ext/apex_src/man/apex.1.new +338 -0
  121. data/ext/apex_ext/apex_src/objc/Apex.swift +237 -0
  122. data/ext/apex_ext/apex_src/objc/NSString+Apex.h +117 -0
  123. data/ext/apex_ext/apex_src/objc/NSString+Apex.m +332 -0
  124. data/ext/apex_ext/apex_src/src/_README.md +358 -0
  125. data/ext/apex_ext/apex_src/src/apex.c +6326 -0
  126. data/ext/apex_ext/apex_src/src/buffer.c +93 -0
  127. data/ext/apex_ext/apex_src/src/extensions/abbreviations.c +362 -0
  128. data/ext/apex_ext/apex_src/src/extensions/abbreviations.h +45 -0
  129. data/ext/apex_ext/apex_src/src/extensions/advanced_footnotes.c +184 -0
  130. data/ext/apex_ext/apex_src/src/extensions/advanced_footnotes.h +50 -0
  131. data/ext/apex_ext/apex_src/src/extensions/advanced_tables.c +1897 -0
  132. data/ext/apex_ext/apex_src/src/extensions/advanced_tables.h +42 -0
  133. data/ext/apex_ext/apex_src/src/extensions/callouts.c +215 -0
  134. data/ext/apex_ext/apex_src/src/extensions/callouts.h +53 -0
  135. data/ext/apex_ext/apex_src/src/extensions/citations.c +2042 -0
  136. data/ext/apex_ext/apex_src/src/extensions/citations.h +163 -0
  137. data/ext/apex_ext/apex_src/src/extensions/critic.c +329 -0
  138. data/ext/apex_ext/apex_src/src/extensions/critic.h +48 -0
  139. data/ext/apex_ext/apex_src/src/extensions/definition_list.c +1670 -0
  140. data/ext/apex_ext/apex_src/src/extensions/definition_list.h +42 -0
  141. data/ext/apex_ext/apex_src/src/extensions/emoji.c +710 -0
  142. data/ext/apex_ext/apex_src/src/extensions/emoji.h +38 -0
  143. data/ext/apex_ext/apex_src/src/extensions/emoji_data.h +942 -0
  144. data/ext/apex_ext/apex_src/src/extensions/fenced_divs.c +925 -0
  145. data/ext/apex_ext/apex_src/src/extensions/fenced_divs.h +43 -0
  146. data/ext/apex_ext/apex_src/src/extensions/github-emoji.txt +869 -0
  147. data/ext/apex_ext/apex_src/src/extensions/grid_tables.c +1121 -0
  148. data/ext/apex_ext/apex_src/src/extensions/grid_tables.h +33 -0
  149. data/ext/apex_ext/apex_src/src/extensions/header_ids.c +626 -0
  150. data/ext/apex_ext/apex_src/src/extensions/header_ids.h +60 -0
  151. data/ext/apex_ext/apex_src/src/extensions/highlight.c +135 -0
  152. data/ext/apex_ext/apex_src/src/extensions/highlight.h +16 -0
  153. data/ext/apex_ext/apex_src/src/extensions/html_markdown.c +408 -0
  154. data/ext/apex_ext/apex_src/src/extensions/html_markdown.h +42 -0
  155. data/ext/apex_ext/apex_src/src/extensions/ial.c +4084 -0
  156. data/ext/apex_ext/apex_src/src/extensions/ial.h +145 -0
  157. data/ext/apex_ext/apex_src/src/extensions/includes.c +1536 -0
  158. data/ext/apex_ext/apex_src/src/extensions/includes.h +54 -0
  159. data/ext/apex_ext/apex_src/src/extensions/index.c +967 -0
  160. data/ext/apex_ext/apex_src/src/extensions/index.h +90 -0
  161. data/ext/apex_ext/apex_src/src/extensions/inline_footnotes.c +205 -0
  162. data/ext/apex_ext/apex_src/src/extensions/inline_footnotes.h +34 -0
  163. data/ext/apex_ext/apex_src/src/extensions/inline_tables.c +332 -0
  164. data/ext/apex_ext/apex_src/src/extensions/inline_tables.h +13 -0
  165. data/ext/apex_ext/apex_src/src/extensions/insert.c +248 -0
  166. data/ext/apex_ext/apex_src/src/extensions/insert.h +18 -0
  167. data/ext/apex_ext/apex_src/src/extensions/math.c +279 -0
  168. data/ext/apex_ext/apex_src/src/extensions/math.h +32 -0
  169. data/ext/apex_ext/apex_src/src/extensions/metadata.c +3046 -0
  170. data/ext/apex_ext/apex_src/src/extensions/metadata.h +125 -0
  171. data/ext/apex_ext/apex_src/src/extensions/relaxed_tables.c +1297 -0
  172. data/ext/apex_ext/apex_src/src/extensions/relaxed_tables.h +39 -0
  173. data/ext/apex_ext/apex_src/src/extensions/special_markers.c +194 -0
  174. data/ext/apex_ext/apex_src/src/extensions/special_markers.h +29 -0
  175. data/ext/apex_ext/apex_src/src/extensions/sup_sub.c +405 -0
  176. data/ext/apex_ext/apex_src/src/extensions/sup_sub.h +16 -0
  177. data/ext/apex_ext/apex_src/src/extensions/syntax_highlight.c +468 -0
  178. data/ext/apex_ext/apex_src/src/extensions/syntax_highlight.h +44 -0
  179. data/ext/apex_ext/apex_src/src/extensions/table_html_postprocess.c +2679 -0
  180. data/ext/apex_ext/apex_src/src/extensions/table_html_postprocess.h +23 -0
  181. data/ext/apex_ext/apex_src/src/extensions/toc.c +255 -0
  182. data/ext/apex_ext/apex_src/src/extensions/toc.h +34 -0
  183. data/ext/apex_ext/apex_src/src/extensions/wiki_links.c +624 -0
  184. data/ext/apex_ext/apex_src/src/extensions/wiki_links.h +58 -0
  185. data/ext/apex_ext/apex_src/src/html_renderer.c +2762 -0
  186. data/ext/apex_ext/apex_src/src/html_renderer.h +126 -0
  187. data/ext/apex_ext/apex_src/src/parser.c +227 -0
  188. data/ext/apex_ext/apex_src/src/plugins.c +895 -0
  189. data/ext/apex_ext/apex_src/src/plugins.h +39 -0
  190. data/ext/apex_ext/apex_src/src/plugins_env.c +187 -0
  191. data/ext/apex_ext/apex_src/src/plugins_remote.c +263 -0
  192. data/ext/apex_ext/apex_src/src/pretty_html.c +358 -0
  193. data/ext/apex_ext/apex_src/src/renderer.c +241 -0
  194. data/ext/apex_ext/apex_src/src/utf8.c +56 -0
  195. data/ext/apex_ext/apex_src/test-linux-build.sh +20 -0
  196. data/ext/apex_ext/apex_src/test.html +103 -0
  197. data/ext/apex_ext/apex_src/test_coverage.sh +121 -0
  198. data/ext/apex_ext/apex_src/test_ial_fenced.md +6 -0
  199. data/ext/apex_ext/apex_src/test_math_norm.py +79 -0
  200. data/ext/apex_ext/apex_src/test_pandoc_output.html +48 -0
  201. data/ext/apex_ext/apex_src/test_spm.sh +107 -0
  202. data/ext/apex_ext/apex_src/tests/ApexSPMTest/main.swift +50 -0
  203. data/ext/apex_ext/apex_src/tests/BENCHMARK_RESULTS.md +229 -0
  204. data/ext/apex_ext/apex_src/tests/CMakeLists.txt +24 -0
  205. data/ext/apex_ext/apex_src/tests/README.md +146 -0
  206. data/ext/apex_ext/apex_src/tests/benchmark.sh +113 -0
  207. data/ext/apex_ext/apex_src/tests/benchmark_comparison.sh +166 -0
  208. data/ext/apex_ext/apex_src/tests/compare_header_ids.sh +31 -0
  209. data/ext/apex_ext/apex_src/tests/fixtures/basic/headers.md +25 -0
  210. data/ext/apex_ext/apex_src/tests/fixtures/basic/list-interruption.md +24 -0
  211. data/ext/apex_ext/apex_src/tests/fixtures/basic/misc_markup.md +33 -0
  212. data/ext/apex_ext/apex_src/tests/fixtures/basic/test_basic.md +26 -0
  213. data/ext/apex_ext/apex_src/tests/fixtures/code/code-blocks.md +260 -0
  214. data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/SUMMARY.md +6 -0
  215. data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/chapter1.md +7 -0
  216. data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/index.txt +9 -0
  217. data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/intro.md +5 -0
  218. data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/section1_1.md +5 -0
  219. data/ext/apex_ext/apex_src/tests/fixtures/comprehensive_test.md +620 -0
  220. data/ext/apex_ext/apex_src/tests/fixtures/debug_ref_image_ial.md +3 -0
  221. data/ext/apex_ext/apex_src/tests/fixtures/demos/ial.md +11 -0
  222. data/ext/apex_ext/apex_src/tests/fixtures/demos/ial_demo.md +177 -0
  223. data/ext/apex_ext/apex_src/tests/fixtures/extensions/emoji-autocorrect.md +94 -0
  224. data/ext/apex_ext/apex_src/tests/fixtures/extensions/emoji_test.md +3 -0
  225. data/ext/apex_ext/apex_src/tests/fixtures/extensions/kbd_test.md +3 -0
  226. data/ext/apex_ext/apex_src/tests/fixtures/ial/bracketed_spans_test.md +74 -0
  227. data/ext/apex_ext/apex_src/tests/fixtures/images/image_and_encoding_test.md +27 -0
  228. data/ext/apex_ext/apex_src/tests/fixtures/images/multimarkdown_image_attributes_test.md +60 -0
  229. data/ext/apex_ext/apex_src/tests/fixtures/images/pandoc_ial_image_test.md +27 -0
  230. data/ext/apex_ext/apex_src/tests/fixtures/images/width_height_conversion_test.md +94 -0
  231. data/ext/apex_ext/apex_src/tests/fixtures/img-in-div.md +16 -0
  232. data/ext/apex_ext/apex_src/tests/fixtures/includes/code.py +4 -0
  233. data/ext/apex_ext/apex_src/tests/fixtures/includes/data.csv +5 -0
  234. data/ext/apex_ext/apex_src/tests/fixtures/includes/data.tsv +5 -0
  235. data/ext/apex_ext/apex_src/tests/fixtures/includes/image.png +2 -0
  236. data/ext/apex_ext/apex_src/tests/fixtures/includes/metadata_options.yml +11 -0
  237. data/ext/apex_ext/apex_src/tests/fixtures/includes/nested.md +8 -0
  238. data/ext/apex_ext/apex_src/tests/fixtures/includes/raw.html +4 -0
  239. data/ext/apex_ext/apex_src/tests/fixtures/includes/simple.md +7 -0
  240. data/ext/apex_ext/apex_src/tests/fixtures/includes/test_image.png +0 -0
  241. data/ext/apex_ext/apex_src/tests/fixtures/large_doc.md +1094 -0
  242. data/ext/apex_ext/apex_src/tests/fixtures/metadata_options.yml +11 -0
  243. data/ext/apex_ext/apex_src/tests/fixtures/output/gfm_header_id_test.md +96 -0
  244. data/ext/apex_ext/apex_src/tests/fixtures/output/test_citations.md +43 -0
  245. data/ext/apex_ext/apex_src/tests/fixtures/output/test_def_list_links.md +12 -0
  246. data/ext/apex_ext/apex_src/tests/fixtures/output/test_index_mmark.md +53 -0
  247. data/ext/apex_ext/apex_src/tests/fixtures/output/test_index_textindex.md +37 -0
  248. data/ext/apex_ext/apex_src/tests/fixtures/tables/advanced_tables_test.md +93 -0
  249. data/ext/apex_ext/apex_src/tests/fixtures/tables/inline_tables_test.md +38 -0
  250. data/ext/apex_ext/apex_src/tests/fixtures/tables/relaxed-table.md +12 -0
  251. data/ext/apex_ext/apex_src/tests/fixtures/tables/table_cr_line_endings.md +15 -0
  252. data/ext/apex_ext/apex_src/tests/fixtures/tables/table_no_trailing_newline.md +15 -0
  253. data/ext/apex_ext/apex_src/tests/generate_gfm_ids.sh +105 -0
  254. data/ext/apex_ext/apex_src/tests/generate_ial_demo.sh +143 -0
  255. data/ext/apex_ext/apex_src/tests/gfm_id_comparison_summary.md +96 -0
  256. data/ext/apex_ext/apex_src/tests/gh_api_test.md +6 -0
  257. data/ext/apex_ext/apex_src/tests/ial_demo.html +186 -0
  258. data/ext/apex_ext/apex_src/tests/include_code.py +19 -0
  259. data/ext/apex_ext/apex_src/tests/include_snippet.md +15 -0
  260. data/ext/apex_ext/apex_src/tests/multi_file_cli_test.sh +64 -0
  261. data/ext/apex_ext/apex_src/tests/sample_data.csv +7 -0
  262. data/ext/apex_ext/apex_src/tests/table_escaped_ltlt.md +4 -0
  263. data/ext/apex_ext/apex_src/tests/test_basic.c +74 -0
  264. data/ext/apex_ext/apex_src/tests/test_extensions.c +2116 -0
  265. data/ext/apex_ext/apex_src/tests/test_helpers.c +183 -0
  266. data/ext/apex_ext/apex_src/tests/test_helpers.h +91 -0
  267. data/ext/apex_ext/apex_src/tests/test_ial.c +282 -0
  268. data/ext/apex_ext/apex_src/tests/test_links.c +418 -0
  269. data/ext/apex_ext/apex_src/tests/test_marked_integration.c +265 -0
  270. data/ext/apex_ext/apex_src/tests/test_metadata.c +908 -0
  271. data/ext/apex_ext/apex_src/tests/test_output.c +1118 -0
  272. data/ext/apex_ext/apex_src/tests/test_plugins.c +219 -0
  273. data/ext/apex_ext/apex_src/tests/test_refs.bib +31 -0
  274. data/ext/apex_ext/apex_src/tests/test_runner.c +244 -0
  275. data/ext/apex_ext/apex_src/tests/test_syntax_highlight.c +198 -0
  276. data/ext/apex_ext/apex_src/tests/test_tables.c +862 -0
  277. data/ext/apex_ext/apex_src/tests/update_benchmarks.sh +9 -0
  278. data/ext/apex_ext/apex_src/tests/yaml_test.md +13 -0
  279. data/ext/apex_ext/apex_src/tests.rb +39 -0
  280. data/ext/apex_ext/apex_src/vendor/cmark-gfm/CMakeLists.txt +48 -0
  281. data/ext/apex_ext/apex_src/vendor/cmark-gfm/COPYING +170 -0
  282. data/ext/apex_ext/apex_src/vendor/cmark-gfm/CheckFileOffsetBits.c +14 -0
  283. data/ext/apex_ext/apex_src/vendor/cmark-gfm/CheckFileOffsetBits.cmake +43 -0
  284. data/ext/apex_ext/apex_src/vendor/cmark-gfm/FindAsan.cmake +74 -0
  285. data/ext/apex_ext/apex_src/vendor/cmark-gfm/Makefile.nmake +38 -0
  286. data/ext/apex_ext/apex_src/vendor/cmark-gfm/README.md +206 -0
  287. data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/CMakeLists.txt +30 -0
  288. data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/cplusplus.cpp +15 -0
  289. data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/cplusplus.h +16 -0
  290. data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/harness.c +111 -0
  291. data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/harness.h +35 -0
  292. data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/main.c +1169 -0
  293. data/ext/apex_ext/apex_src/vendor/cmark-gfm/appveyor.yml +21 -0
  294. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-bq-flat.md +16 -0
  295. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-bq-nested.md +13 -0
  296. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-code.md +11 -0
  297. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-fences.md +14 -0
  298. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-heading.md +9 -0
  299. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-hr.md +10 -0
  300. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-html.md +32 -0
  301. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-lheading.md +8 -0
  302. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-list-flat.md +67 -0
  303. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-list-nested.md +36 -0
  304. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-ref-flat.md +15 -0
  305. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-ref-nested.md +17 -0
  306. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-autolink.md +14 -0
  307. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-backticks.md +3 -0
  308. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-em-flat.md +5 -0
  309. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-em-nested.md +5 -0
  310. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-em-worst.md +5 -0
  311. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-entity.md +11 -0
  312. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-escape.md +15 -0
  313. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-html.md +44 -0
  314. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-links-flat.md +23 -0
  315. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-links-nested.md +13 -0
  316. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-newlines.md +24 -0
  317. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/lorem1.md +13 -0
  318. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/rawtabs.md +18 -0
  319. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/statistics.py +595 -0
  320. data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/stats.py +19 -0
  321. data/ext/apex_ext/apex_src/vendor/cmark-gfm/benchmarks.md +33 -0
  322. data/ext/apex_ext/apex_src/vendor/cmark-gfm/changelog.txt +1245 -0
  323. data/ext/apex_ext/apex_src/vendor/cmark-gfm/data/CaseFolding.txt +1495 -0
  324. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/CMakeLists.txt +119 -0
  325. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/autolink.c +508 -0
  326. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/autolink.h +8 -0
  327. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/cmark-gfm-core-extensions.h +54 -0
  328. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/core-extensions.c +27 -0
  329. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/ext_scanners.c +879 -0
  330. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/ext_scanners.h +24 -0
  331. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/ext_scanners.re +92 -0
  332. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/strikethrough.c +167 -0
  333. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/strikethrough.h +9 -0
  334. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.c +917 -0
  335. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.h +12 -0
  336. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tagfilter.c +60 -0
  337. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tagfilter.h +8 -0
  338. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tasklist.c +156 -0
  339. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tasklist.h +8 -0
  340. data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/CMakeLists.txt +22 -0
  341. data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/README.md +12 -0
  342. data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/fuzz_quadratic.c +91 -0
  343. data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/fuzz_quadratic_brackets.c +110 -0
  344. data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/fuzzloop.sh +28 -0
  345. data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/CMakeLists.txt +10 -0
  346. data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/make_man_page.py +133 -0
  347. data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/man1/cmark-gfm.1 +78 -0
  348. data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/man3/cmark-gfm.3 +1041 -0
  349. data/ext/apex_ext/apex_src/vendor/cmark-gfm/nmake.bat +1 -0
  350. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/CMakeLists.txt +230 -0
  351. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/arena.c +104 -0
  352. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/blocks.c +1622 -0
  353. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/buffer.c +278 -0
  354. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/buffer.h +116 -0
  355. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/case_fold_switch.inc +4327 -0
  356. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/chunk.h +135 -0
  357. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark-gfm-extension_api.h +737 -0
  358. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark-gfm.h +833 -0
  359. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark-gfm_version.h.in +7 -0
  360. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark.c +55 -0
  361. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark_ctype.c +44 -0
  362. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark_ctype.h +33 -0
  363. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/commonmark.c +514 -0
  364. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/config.h.in +76 -0
  365. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/entities.inc +2138 -0
  366. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/footnotes.c +63 -0
  367. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/footnotes.h +27 -0
  368. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini.h +57 -0
  369. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini_href_e.c +100 -0
  370. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini_html_e.c +66 -0
  371. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini_html_u.c +149 -0
  372. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/html.c +502 -0
  373. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/html.h +27 -0
  374. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/inlines.c +1788 -0
  375. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/inlines.h +29 -0
  376. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/iterator.c +159 -0
  377. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/iterator.h +26 -0
  378. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/latex.c +468 -0
  379. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/libcmark-gfm.pc.in +10 -0
  380. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/linked_list.c +37 -0
  381. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/main.c +328 -0
  382. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/man.c +274 -0
  383. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/map.c +129 -0
  384. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/map.h +44 -0
  385. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/node.c +1045 -0
  386. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/node.h +167 -0
  387. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/parser.h +59 -0
  388. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/plaintext.c +218 -0
  389. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/plugin.c +36 -0
  390. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/plugin.h +34 -0
  391. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/references.c +43 -0
  392. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/references.h +26 -0
  393. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/registry.c +63 -0
  394. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/registry.h +24 -0
  395. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/render.c +213 -0
  396. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/render.h +62 -0
  397. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/scanners.c +14056 -0
  398. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/scanners.h +70 -0
  399. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/scanners.re +365 -0
  400. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/syntax_extension.c +149 -0
  401. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/syntax_extension.h +34 -0
  402. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/utf8.c +317 -0
  403. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/utf8.h +35 -0
  404. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/xml.c +182 -0
  405. data/ext/apex_ext/apex_src/vendor/cmark-gfm/suppressions +10 -0
  406. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/CMakeLists.txt +114 -0
  407. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/afl_test_cases/test.md +49 -0
  408. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/cmark-fuzz.c +58 -0
  409. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/cmark.py +105 -0
  410. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/entity_tests.py +67 -0
  411. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions-full-info-string.txt +0 -0
  412. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions-table-prefer-style-attributes.txt +38 -0
  413. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions.txt +920 -0
  414. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/fuzzing_dictionary +67 -0
  415. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/normalize.py +194 -0
  416. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/pathological_tests.py +160 -0
  417. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/regression.txt +375 -0
  418. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/roundtrip_tests.py +50 -0
  419. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/run-cmark-fuzz +4 -0
  420. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/smart_punct.txt +177 -0
  421. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/spec.txt +10212 -0
  422. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/spec_tests.py +152 -0
  423. data/ext/apex_ext/apex_src/vendor/cmark-gfm/toolchain-mingw32.cmake +17 -0
  424. data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/Dockerfile +41 -0
  425. data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/appveyor-build.bat +13 -0
  426. data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/make_entities_inc.py +32 -0
  427. data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/mkcasefold.pl +22 -0
  428. data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/xml2md.xsl +319 -0
  429. data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/xml2md_gfm.xsl +80 -0
  430. data/ext/apex_ext/apex_src/vendor/cmark-gfm/why-cmark-and-not-x.md +104 -0
  431. data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.js +6 -0
  432. data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.py +37 -0
  433. data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.rb +15 -0
  434. data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.rkt +208 -0
  435. data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper_ext.py +109 -0
  436. data/ext/apex_ext/apex_src/vendor/libyaml/CMakeLists.txt +160 -0
  437. data/ext/apex_ext/apex_src/vendor/libyaml/Changes +372 -0
  438. data/ext/apex_ext/apex_src/vendor/libyaml/License +20 -0
  439. data/ext/apex_ext/apex_src/vendor/libyaml/Makefile.am +51 -0
  440. data/ext/apex_ext/apex_src/vendor/libyaml/ReadMe.md +46 -0
  441. data/ext/apex_ext/apex_src/vendor/libyaml/announcement.msg +89 -0
  442. data/ext/apex_ext/apex_src/vendor/libyaml/bootstrap +3 -0
  443. data/ext/apex_ext/apex_src/vendor/libyaml/cmake/config.h.in +4 -0
  444. data/ext/apex_ext/apex_src/vendor/libyaml/configure.ac +73 -0
  445. data/ext/apex_ext/apex_src/vendor/libyaml/doc/doxygen.cfg +222 -0
  446. data/ext/apex_ext/apex_src/vendor/libyaml/docker/README.mkd +17 -0
  447. data/ext/apex_ext/apex_src/vendor/libyaml/docker/alpine-3.7 +26 -0
  448. data/ext/apex_ext/apex_src/vendor/libyaml/docker/fedora-25 +26 -0
  449. data/ext/apex_ext/apex_src/vendor/libyaml/docker/ubuntu-14.04 +29 -0
  450. data/ext/apex_ext/apex_src/vendor/libyaml/docker/ubuntu-16.04 +24 -0
  451. data/ext/apex_ext/apex_src/vendor/libyaml/examples/anchors.yaml +10 -0
  452. data/ext/apex_ext/apex_src/vendor/libyaml/examples/array.yaml +2 -0
  453. data/ext/apex_ext/apex_src/vendor/libyaml/examples/global-tag.yaml +14 -0
  454. data/ext/apex_ext/apex_src/vendor/libyaml/examples/json.yaml +1 -0
  455. data/ext/apex_ext/apex_src/vendor/libyaml/examples/mapping.yaml +2 -0
  456. data/ext/apex_ext/apex_src/vendor/libyaml/examples/numbers.yaml +1 -0
  457. data/ext/apex_ext/apex_src/vendor/libyaml/examples/strings.yaml +7 -0
  458. data/ext/apex_ext/apex_src/vendor/libyaml/examples/tags.yaml +7 -0
  459. data/ext/apex_ext/apex_src/vendor/libyaml/examples/yaml-version.yaml +3 -0
  460. data/ext/apex_ext/apex_src/vendor/libyaml/include/Makefile.am +17 -0
  461. data/ext/apex_ext/apex_src/vendor/libyaml/include/yaml.h +1999 -0
  462. data/ext/apex_ext/apex_src/vendor/libyaml/pkg/ReadMe.md +77 -0
  463. data/ext/apex_ext/apex_src/vendor/libyaml/pkg/docker/Dockerfile +32 -0
  464. data/ext/apex_ext/apex_src/vendor/libyaml/pkg/docker/output/ReadMe +1 -0
  465. data/ext/apex_ext/apex_src/vendor/libyaml/pkg/docker/scripts/libyaml-dist.sh +23 -0
  466. data/ext/apex_ext/apex_src/vendor/libyaml/regression-inputs/clusterfuzz-testcase-minimized-5607885063061504.yml +1 -0
  467. data/ext/apex_ext/apex_src/vendor/libyaml/src/Makefile.am +4 -0
  468. data/ext/apex_ext/apex_src/vendor/libyaml/src/api.c +1393 -0
  469. data/ext/apex_ext/apex_src/vendor/libyaml/src/dumper.c +394 -0
  470. data/ext/apex_ext/apex_src/vendor/libyaml/src/emitter.c +2358 -0
  471. data/ext/apex_ext/apex_src/vendor/libyaml/src/loader.c +544 -0
  472. data/ext/apex_ext/apex_src/vendor/libyaml/src/parser.c +1416 -0
  473. data/ext/apex_ext/apex_src/vendor/libyaml/src/reader.c +469 -0
  474. data/ext/apex_ext/apex_src/vendor/libyaml/src/scanner.c +3598 -0
  475. data/ext/apex_ext/apex_src/vendor/libyaml/src/writer.c +141 -0
  476. data/ext/apex_ext/apex_src/vendor/libyaml/src/yaml_private.h +684 -0
  477. data/ext/apex_ext/apex_src/vendor/libyaml/tests/CMakeLists.txt +27 -0
  478. data/ext/apex_ext/apex_src/vendor/libyaml/tests/Makefile.am +9 -0
  479. data/ext/apex_ext/apex_src/vendor/libyaml/tests/ReadMe.md +63 -0
  480. data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-deconstructor-alt.c +800 -0
  481. data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-deconstructor.c +1127 -0
  482. data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-reformatter-alt.c +217 -0
  483. data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-reformatter.c +202 -0
  484. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-all-tests.sh +29 -0
  485. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-dumper.c +314 -0
  486. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-emitter-test-suite.c +290 -0
  487. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-emitter.c +327 -0
  488. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-loader.c +63 -0
  489. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-parser-test-suite.c +196 -0
  490. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-parser.c +88 -0
  491. data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-scanner.c +63 -0
  492. data/ext/apex_ext/apex_src/vendor/libyaml/tests/test-reader.c +354 -0
  493. data/ext/apex_ext/apex_src/vendor/libyaml/tests/test-version.c +29 -0
  494. data/ext/apex_ext/apex_src/vendor/libyaml/yaml-0.1.pc.in +10 -0
  495. data/ext/apex_ext/apex_src/vendor/libyaml/yamlConfig.cmake.in +16 -0
  496. data/ext/apex_ext/extconf.rb +103 -0
  497. data/lib/apex/configurable.rb +46 -0
  498. data/lib/apex/document.rb +66 -0
  499. data/lib/apex/version.rb +15 -0
  500. data/lib/apex.rb +28 -0
  501. metadata +544 -0
@@ -0,0 +1,1297 @@
1
+ /**
2
+ * Relaxed Tables Extension for Apex
3
+ * Implementation
4
+ *
5
+ * Detects tables without separator rows and inserts separator rows
6
+ * so the existing table parser can handle them as data-only tables.
7
+ */
8
+
9
+ #include "relaxed_tables.h"
10
+ #include <string.h>
11
+ #include <stdlib.h>
12
+ #include <stdbool.h>
13
+ #include <ctype.h>
14
+
15
+ /**
16
+ * Count the number of columns in a table row (by counting pipes)
17
+ * Returns -1 if the line doesn't contain a pipe
18
+ * Number of columns = number of pipe-separated cells
19
+ * For GFM tables: | one | two | has 2 columns, one | two has 2 columns
20
+ */
21
+ static int count_columns(const char *line, size_t len) {
22
+ if (!line || len == 0) return -1;
23
+
24
+ bool has_pipe = false;
25
+ int pipe_count = 0;
26
+
27
+ /* Skip leading whitespace */
28
+ size_t start = 0;
29
+ while (start < len && (line[start] == ' ' || line[start] == '\t')) {
30
+ start++;
31
+ }
32
+
33
+ bool starts_with_pipe = (start < len && line[start] == '|');
34
+
35
+ /* Count pipes */
36
+ for (size_t i = start; i < len; i++) {
37
+ if (line[i] == '|') {
38
+ has_pipe = true;
39
+ pipe_count++;
40
+ if (i == start) {
41
+ starts_with_pipe = true;
42
+ }
43
+ /* Check if this is the last non-whitespace character */
44
+ /* Note: ends_with_pipe was set but never used, removed to fix warning */
45
+ }
46
+ }
47
+
48
+ if (!has_pipe) return -1;
49
+
50
+ /* Calculate number of columns:
51
+ * - If line starts with | and ends with |: columns = pipe_count - 1
52
+ * - If line starts with | but doesn't end with |: columns = pipe_count
53
+ * - If line doesn't start with | but ends with |: columns = pipe_count
54
+ * - If line doesn't start or end with |: columns = pipe_count + 1
55
+ *
56
+ * Actually, simpler: number of columns = number of pipe-separated segments
57
+ * | one | two | = 3 segments (empty, one, two, empty) but 2 data columns
58
+ * one | two = 2 segments = 2 columns
59
+ * | one | two = 3 segments (empty, one, two) but effectively 2 columns
60
+ *
61
+ * For GFM, we want the number of data columns, which is typically:
62
+ * - If starts with |: pipe_count - 1 (leading pipe creates empty first cell)
63
+ * - If doesn't start with |: pipe_count + 1
64
+ *
65
+ * But actually, for table parsing, we need the separator to match the structure.
66
+ * Let's use: if starts with |, columns = pipe_count - 1, else columns = pipe_count + 1
67
+ */
68
+ if (starts_with_pipe) {
69
+ /* Leading pipe: number of columns = number of pipes - 1 */
70
+ /* | one | two | has 3 pipes, 2 columns */
71
+ return pipe_count - 1;
72
+ } else {
73
+ /* No leading pipe: number of columns = number of pipes + 1 */
74
+ /* one | two has 1 pipe, 2 columns */
75
+ return pipe_count + 1;
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Check if a line is blank (empty or only whitespace)
81
+ */
82
+ static bool is_blank_line(const char *line, size_t len) {
83
+ if (!line || len == 0) return true;
84
+
85
+ for (size_t i = 0; i < len; i++) {
86
+ if (!isspace((unsigned char)line[i])) {
87
+ return false;
88
+ }
89
+ }
90
+
91
+ return true;
92
+ }
93
+
94
+ /**
95
+ * Check if a line is a horizontal rule (--- on a line by itself)
96
+ */
97
+ static bool is_horizontal_rule(const char *line, size_t len) {
98
+ if (!line || len == 0) return false;
99
+
100
+ /* Skip leading whitespace */
101
+ size_t start = 0;
102
+ while (start < len && (line[start] == ' ' || line[start] == '\t')) {
103
+ start++;
104
+ }
105
+
106
+ /* Check if it's all dashes (at least 3) */
107
+ size_t dash_count = 0;
108
+ for (size_t i = start; i < len; i++) {
109
+ if (line[i] == '-') {
110
+ dash_count++;
111
+ } else if (line[i] != ' ' && line[i] != '\t' && line[i] != '\n' && line[i] != '\r') {
112
+ return false; /* Contains non-dash, non-whitespace character */
113
+ }
114
+ }
115
+
116
+ /* Must have at least 3 dashes and no pipes */
117
+ return dash_count >= 3;
118
+ }
119
+
120
+ /**
121
+ * Check if a line is a table separator row (contains |, -, :, spaces only)
122
+ * Must have both dash and pipe to be a separator row
123
+ */
124
+ static bool is_separator_row(const char *line, size_t len) {
125
+ if (!line || len == 0) return false;
126
+
127
+ /* Horizontal rules are not table separators */
128
+ if (is_horizontal_rule(line, len)) {
129
+ return false;
130
+ }
131
+
132
+ bool has_dash = false;
133
+ bool has_pipe = false;
134
+
135
+ for (size_t i = 0; i < len; i++) {
136
+ unsigned char c = (unsigned char)line[i];
137
+ if (c == '-') {
138
+ has_dash = true;
139
+ } else if (c == '|') {
140
+ has_pipe = true;
141
+ } else if (c != ' ' && c != '\t' && c != ':' && c != '+') {
142
+ /* Contains a character that's not allowed in separator rows */
143
+ return false;
144
+ }
145
+ }
146
+
147
+ /* Separator row must have both dash and pipe */
148
+ return has_dash && has_pipe;
149
+ }
150
+
151
+ /**
152
+ * Generate a separator row for a given number of columns
153
+ * Format: |---|---| (no spaces to avoid smart typography conversion)
154
+ * @param num_columns Number of columns
155
+ * @param starts_with_pipe If true, generate separator starting with | to match row format
156
+ */
157
+ static char *generate_separator_row(int num_columns, bool starts_with_pipe) {
158
+ if (num_columns < 1) return NULL;
159
+
160
+ /* Generate separator matching the row format */
161
+ /* For rows with leading pipes: "| --- | --- |" (with spaces) */
162
+ /* For rows without: "|---|---|" (no spaces) */
163
+ size_t len;
164
+ if (starts_with_pipe) {
165
+ /* "| " + num_columns * "--- | " + "\n" + null */
166
+ len = 2 + num_columns * 6 + 1 + 1;
167
+ } else {
168
+ /* "|" + num_columns * "---|" + "\n" + null */
169
+ len = 1 + num_columns * 4 + 1 + 1;
170
+ }
171
+ char *sep = malloc(len);
172
+ if (!sep) return NULL;
173
+
174
+ char *p = sep;
175
+ if (starts_with_pipe) {
176
+ *p++ = '|';
177
+ *p++ = ' ';
178
+ }
179
+
180
+ for (int i = 0; i < num_columns; i++) {
181
+ *p++ = '-';
182
+ *p++ = '-';
183
+ *p++ = '-';
184
+ if (starts_with_pipe) {
185
+ *p++ = ' ';
186
+ *p++ = '|';
187
+ if (i < num_columns - 1) {
188
+ *p++ = ' '; /* Space after pipe for all but last column */
189
+ }
190
+ } else {
191
+ *p++ = '|';
192
+ }
193
+ }
194
+
195
+ *p++ = '\n';
196
+ *p = '\0';
197
+
198
+ return sep;
199
+ }
200
+
201
+ /**
202
+ * Check if a line looks like a table row (contains pipes and non-separator content)
203
+ */
204
+ static bool is_table_row(const char *line, size_t len) {
205
+ if (!line || len == 0) return false;
206
+
207
+ /* Must contain a pipe */
208
+ bool has_pipe = false;
209
+ bool has_content = false;
210
+
211
+ for (size_t i = 0; i < len; i++) {
212
+ unsigned char c = (unsigned char)line[i];
213
+ if (c == '|') {
214
+ has_pipe = true;
215
+ } else if (!isspace(c) && c != '-') {
216
+ /* Has content that's not just dashes */
217
+ has_content = true;
218
+ }
219
+ }
220
+
221
+ /* Must have both pipe and non-dash content */
222
+ return has_pipe && has_content;
223
+ }
224
+
225
+ /**
226
+ * Generate a dummy header row (empty cells) for a given number of columns
227
+ * This will be removed in post-processing
228
+ * @param num_columns Number of columns
229
+ * @param starts_with_pipe If true, generate header starting with | to match separator format
230
+ */
231
+ static char *generate_dummy_header_row(int num_columns, bool starts_with_pipe) {
232
+ if (num_columns < 1) return NULL;
233
+
234
+ /* Calculate size: need space for pipes and spaces */
235
+ size_t len;
236
+ if (starts_with_pipe) {
237
+ /* "| " + num_columns * " | " + "\n" + null */
238
+ len = 2 + num_columns * 4 + 1 + 1;
239
+ } else {
240
+ /* num_columns * " |" + "\n" + null */
241
+ len = num_columns * 3 + 1 + 1;
242
+ }
243
+
244
+ char *header = malloc(len);
245
+ if (!header) return NULL;
246
+
247
+ char *p = header;
248
+ if (starts_with_pipe) {
249
+ *p++ = '|';
250
+ *p++ = ' ';
251
+ }
252
+
253
+ for (int i = 0; i < num_columns; i++) {
254
+ *p++ = ' ';
255
+ *p++ = '|';
256
+ if (i < num_columns - 1 || !starts_with_pipe) {
257
+ *p++ = ' ';
258
+ }
259
+ }
260
+
261
+ *p++ = '\n';
262
+ *p = '\0';
263
+
264
+ return header;
265
+ }
266
+
267
+ /**
268
+ * Process relaxed tables - detect tables without separator rows and insert them
269
+ */
270
+ static char *apex_process_relaxed_tables_impl(const char *text,
271
+ void (*progress_callback)(const char *stage, int percent, void *user_data),
272
+ void *progress_user_data) {
273
+ (void)progress_callback;
274
+ (void)progress_user_data;
275
+
276
+ if (!text) return NULL;
277
+
278
+ size_t text_len = strlen(text);
279
+ if (text_len == 0) return NULL;
280
+
281
+ /* Check if input ends with a newline */
282
+ bool input_ends_with_newline = (text_len > 0 && text[text_len - 1] == '\n');
283
+
284
+ /* Allocate output buffer (may grow, but start with 2x input size) */
285
+ size_t output_capacity = text_len * 2;
286
+ char *output = malloc(output_capacity);
287
+ if (!output) return NULL;
288
+
289
+ const char *read = text;
290
+ char *write = output;
291
+ size_t remaining = output_capacity;
292
+ size_t output_len = 0;
293
+
294
+ /* Track potential table rows */
295
+ typedef struct {
296
+ const char *start;
297
+ size_t len;
298
+ int columns;
299
+ bool starts_with_pipe;
300
+ } table_row;
301
+
302
+ table_row *rows = NULL;
303
+ size_t rows_capacity = 0;
304
+ size_t rows_count = 0;
305
+
306
+ /* Track if we made any changes to avoid expensive strcmp */
307
+ bool made_changes = false;
308
+
309
+ /* Process line by line */
310
+ while (*read) {
311
+ const char *line_start = read;
312
+ const char *line_end = strchr(read, '\n');
313
+ if (!line_end) {
314
+ line_end = read + strlen(read);
315
+ }
316
+
317
+ size_t line_len = line_end - line_start;
318
+ bool has_newline = (*line_end == '\n');
319
+
320
+ /* Check if this is a blank line */
321
+ if (is_blank_line(line_start, line_len)) {
322
+ /* Blank line: if we have accumulated table rows, process them */
323
+ if (rows_count >= 2) {
324
+ /* We have a relaxed table - insert separator after first row */
325
+ /* First, write all rows except the last one */
326
+ for (size_t i = 0; i < rows_count; i++) {
327
+ /* Write the row */
328
+ if (rows[i].len < remaining) {
329
+ memcpy(write, rows[i].start, rows[i].len);
330
+ write += rows[i].len;
331
+ remaining -= rows[i].len;
332
+ output_len += rows[i].len;
333
+
334
+ /* Write newline */
335
+ if (has_newline && remaining > 0) {
336
+ *write++ = '\n';
337
+ remaining--;
338
+ output_len++;
339
+ }
340
+ } else {
341
+ /* Need to grow buffer */
342
+ size_t new_capacity = output_capacity * 2;
343
+ char *new_output = realloc(output, new_capacity);
344
+ if (!new_output) {
345
+ free(output);
346
+ free(rows);
347
+ return NULL;
348
+ }
349
+ write = new_output + output_len;
350
+ output = new_output;
351
+ remaining = new_capacity - output_len;
352
+ output_capacity = new_capacity;
353
+
354
+ memcpy(write, rows[i].start, rows[i].len);
355
+ write += rows[i].len;
356
+ remaining -= rows[i].len;
357
+ output_len += rows[i].len;
358
+
359
+ if (has_newline && remaining > 0) {
360
+ *write++ = '\n';
361
+ remaining--;
362
+ output_len++;
363
+ }
364
+ }
365
+
366
+ /* After first row, insert separator */
367
+ if (i == 0) {
368
+ made_changes = true; /* We're inserting a separator, so output will differ */
369
+ char *sep = generate_separator_row(rows[0].columns, rows[0].starts_with_pipe);
370
+ if (sep) {
371
+ size_t sep_len = strlen(sep);
372
+ if (sep_len < remaining) {
373
+ memcpy(write, sep, sep_len);
374
+ write += sep_len;
375
+ remaining -= sep_len;
376
+ output_len += sep_len;
377
+ } else {
378
+ /* Need to grow buffer */
379
+ size_t new_capacity = output_capacity * 2;
380
+ char *new_output = realloc(output, new_capacity);
381
+ if (!new_output) {
382
+ free(sep);
383
+ free(output);
384
+ free(rows);
385
+ return NULL;
386
+ }
387
+ write = new_output + output_len;
388
+ output = new_output;
389
+ remaining = new_capacity - output_len;
390
+ output_capacity = new_capacity;
391
+
392
+ memcpy(write, sep, sep_len);
393
+ write += sep_len;
394
+ remaining -= sep_len;
395
+ output_len += sep_len;
396
+ }
397
+ free(sep);
398
+ }
399
+ }
400
+ }
401
+
402
+ /* Reset rows */
403
+ rows_count = 0;
404
+
405
+ /* After outputting table, also write the blank line */
406
+ if (remaining > 0) {
407
+ *write++ = '\n';
408
+ remaining--;
409
+ output_len++;
410
+ }
411
+ } else {
412
+ /* No table accumulated, just write the blank line */
413
+ if (line_len < remaining) {
414
+ memcpy(write, line_start, line_len);
415
+ write += line_len;
416
+ remaining -= line_len;
417
+ output_len += line_len;
418
+
419
+ if (has_newline && remaining > 0) {
420
+ *write++ = '\n';
421
+ remaining--;
422
+ output_len++;
423
+ }
424
+ } else {
425
+ /* Need to grow buffer */
426
+ size_t new_capacity = output_capacity * 2;
427
+ char *new_output = realloc(output, new_capacity);
428
+ if (!new_output) {
429
+ free(output);
430
+ free(rows);
431
+ return NULL;
432
+ }
433
+ write = new_output + output_len;
434
+ output = new_output;
435
+ remaining = new_capacity - output_len;
436
+ output_capacity = new_capacity;
437
+
438
+ memcpy(write, line_start, line_len);
439
+ write += line_len;
440
+ remaining -= line_len;
441
+ output_len += line_len;
442
+
443
+ if (has_newline && remaining > 0) {
444
+ *write++ = '\n';
445
+ remaining--;
446
+ output_len++;
447
+ }
448
+ }
449
+ }
450
+
451
+ /* Move to next line */
452
+ read = line_end;
453
+ if (has_newline) read++;
454
+ continue;
455
+ }
456
+
457
+ /* Check if this is a separator row */
458
+ if (is_separator_row(line_start, line_len)) {
459
+ /* Separator row: if we have accumulated rows, write them as-is */
460
+ if (rows_count > 0) {
461
+ for (size_t i = 0; i < rows_count; i++) {
462
+ if (rows[i].len < remaining) {
463
+ memcpy(write, rows[i].start, rows[i].len);
464
+ write += rows[i].len;
465
+ remaining -= rows[i].len;
466
+ output_len += rows[i].len;
467
+
468
+ if (has_newline && remaining > 0) {
469
+ *write++ = '\n';
470
+ remaining--;
471
+ output_len++;
472
+ }
473
+ } else {
474
+ /* Need to grow buffer */
475
+ size_t new_capacity = output_capacity * 2;
476
+ char *new_output = realloc(output, new_capacity);
477
+ if (!new_output) {
478
+ free(output);
479
+ free(rows);
480
+ return NULL;
481
+ }
482
+ write = new_output + output_len;
483
+ output = new_output;
484
+ remaining = new_capacity - output_len;
485
+ output_capacity = new_capacity;
486
+
487
+ memcpy(write, rows[i].start, rows[i].len);
488
+ write += rows[i].len;
489
+ remaining -= rows[i].len;
490
+ output_len += rows[i].len;
491
+
492
+ if (has_newline && remaining > 0) {
493
+ *write++ = '\n';
494
+ remaining--;
495
+ output_len++;
496
+ }
497
+ }
498
+ }
499
+ rows_count = 0;
500
+ }
501
+
502
+ /* Write the separator row */
503
+ if (line_len < remaining) {
504
+ memcpy(write, line_start, line_len);
505
+ write += line_len;
506
+ remaining -= line_len;
507
+ output_len += line_len;
508
+
509
+ if (has_newline && remaining > 0) {
510
+ *write++ = '\n';
511
+ remaining--;
512
+ output_len++;
513
+ }
514
+ } else {
515
+ /* Need to grow buffer */
516
+ size_t new_capacity = output_capacity * 2;
517
+ char *new_output = realloc(output, new_capacity);
518
+ if (!new_output) {
519
+ free(output);
520
+ free(rows);
521
+ return NULL;
522
+ }
523
+ write = new_output + output_len;
524
+ output = new_output;
525
+ remaining = new_capacity - output_len;
526
+ output_capacity = new_capacity;
527
+
528
+ memcpy(write, line_start, line_len);
529
+ write += line_len;
530
+ remaining -= line_len;
531
+ output_len += line_len;
532
+
533
+ if (has_newline && remaining > 0) {
534
+ *write++ = '\n';
535
+ remaining--;
536
+ output_len++;
537
+ }
538
+ }
539
+
540
+ read = line_end;
541
+ if (has_newline) read++;
542
+ continue;
543
+ }
544
+
545
+ /* Check if this is a horizontal rule - skip it entirely */
546
+ if (is_horizontal_rule(line_start, line_len)) {
547
+ /* Write horizontal rule as-is and reset accumulated rows */
548
+ if (rows_count > 0) {
549
+ /* Write accumulated rows first */
550
+ for (size_t i = 0; i < rows_count; i++) {
551
+ if (rows[i].len < remaining) {
552
+ memcpy(write, rows[i].start, rows[i].len);
553
+ write += rows[i].len;
554
+ remaining -= rows[i].len;
555
+ output_len += rows[i].len;
556
+
557
+ if (has_newline && remaining > 0) {
558
+ *write++ = '\n';
559
+ remaining--;
560
+ output_len++;
561
+ }
562
+ } else {
563
+ size_t new_capacity = output_capacity * 2;
564
+ char *new_output = realloc(output, new_capacity);
565
+ if (!new_output) {
566
+ free(output);
567
+ free(rows);
568
+ return NULL;
569
+ }
570
+ write = new_output + output_len;
571
+ output = new_output;
572
+ remaining = new_capacity - output_len;
573
+ output_capacity = new_capacity;
574
+
575
+ memcpy(write, rows[i].start, rows[i].len);
576
+ write += rows[i].len;
577
+ remaining -= rows[i].len;
578
+ output_len += rows[i].len;
579
+
580
+ if (has_newline && remaining > 0) {
581
+ *write++ = '\n';
582
+ remaining--;
583
+ output_len++;
584
+ }
585
+ }
586
+ }
587
+ rows_count = 0;
588
+ }
589
+
590
+ /* Write horizontal rule as-is */
591
+ if (line_len < remaining) {
592
+ memcpy(write, line_start, line_len);
593
+ write += line_len;
594
+ remaining -= line_len;
595
+ output_len += line_len;
596
+
597
+ if (has_newline && remaining > 0) {
598
+ *write++ = '\n';
599
+ remaining--;
600
+ output_len++;
601
+ }
602
+ } else {
603
+ size_t new_capacity = output_capacity * 2;
604
+ char *new_output = realloc(output, new_capacity);
605
+ if (!new_output) {
606
+ free(output);
607
+ free(rows);
608
+ return NULL;
609
+ }
610
+ write = new_output + output_len;
611
+ output = new_output;
612
+ remaining = new_capacity - output_len;
613
+ output_capacity = new_capacity;
614
+
615
+ memcpy(write, line_start, line_len);
616
+ write += line_len;
617
+ remaining -= line_len;
618
+ output_len += line_len;
619
+
620
+ if (has_newline && remaining > 0) {
621
+ *write++ = '\n';
622
+ remaining--;
623
+ output_len++;
624
+ }
625
+ }
626
+
627
+ read = line_end;
628
+ if (has_newline) read++;
629
+ continue;
630
+ }
631
+
632
+ /* Check if this line contains a pipe (potential table row) */
633
+ const char *p = line_start;
634
+ while (p < line_end && (*p == ' ' || *p == '\t')) {
635
+ p++;
636
+ }
637
+ bool starts_with_pipe = (p < line_end && *p == '|');
638
+
639
+ /* Check if this is a separator row - if so, skip relaxed table processing for previous rows */
640
+ if (is_separator_row(line_start, line_len)) {
641
+ /* Separator row found - if we have accumulated rows, they're already a valid table */
642
+ /* Write them as-is and reset */
643
+ if (rows_count > 0) {
644
+ for (size_t i = 0; i < rows_count; i++) {
645
+ if (rows[i].len < remaining) {
646
+ memcpy(write, rows[i].start, rows[i].len);
647
+ write += rows[i].len;
648
+ remaining -= rows[i].len;
649
+ output_len += rows[i].len;
650
+
651
+ if (has_newline && remaining > 0) {
652
+ *write++ = '\n';
653
+ remaining--;
654
+ output_len++;
655
+ }
656
+ } else {
657
+ size_t new_capacity = output_capacity * 2;
658
+ char *new_output = realloc(output, new_capacity);
659
+ if (!new_output) {
660
+ free(output);
661
+ free(rows);
662
+ return NULL;
663
+ }
664
+ write = new_output + output_len;
665
+ output = new_output;
666
+ remaining = new_capacity - output_len;
667
+ output_capacity = new_capacity;
668
+
669
+ memcpy(write, rows[i].start, rows[i].len);
670
+ write += rows[i].len;
671
+ remaining -= rows[i].len;
672
+ output_len += rows[i].len;
673
+
674
+ if (has_newline && remaining > 0) {
675
+ *write++ = '\n';
676
+ remaining--;
677
+ output_len++;
678
+ }
679
+ }
680
+ }
681
+ rows_count = 0;
682
+ }
683
+
684
+ /* Write the separator row */
685
+ if (line_len < remaining) {
686
+ memcpy(write, line_start, line_len);
687
+ write += line_len;
688
+ remaining -= line_len;
689
+ output_len += line_len;
690
+
691
+ if (has_newline && remaining > 0) {
692
+ *write++ = '\n';
693
+ remaining--;
694
+ output_len++;
695
+ }
696
+ } else {
697
+ size_t new_capacity = output_capacity * 2;
698
+ char *new_output = realloc(output, new_capacity);
699
+ if (!new_output) {
700
+ free(output);
701
+ free(rows);
702
+ return NULL;
703
+ }
704
+ write = new_output + output_len;
705
+ output = new_output;
706
+ remaining = new_capacity - output_len;
707
+ output_capacity = new_capacity;
708
+
709
+ memcpy(write, line_start, line_len);
710
+ write += line_len;
711
+ remaining -= line_len;
712
+ output_len += line_len;
713
+
714
+ if (has_newline && remaining > 0) {
715
+ *write++ = '\n';
716
+ remaining--;
717
+ output_len++;
718
+ }
719
+ }
720
+
721
+ read = line_end;
722
+ if (has_newline) read++;
723
+ continue;
724
+ }
725
+
726
+ /* Process rows with or without leading pipes - both need separators if missing */
727
+ int columns = count_columns(line_start, line_len);
728
+ if (columns > 0) {
729
+ /* Potential table row - add to accumulator */
730
+ if (rows_count == 0) {
731
+ /* First row - allocate array */
732
+ rows_capacity = 16;
733
+ rows = malloc(sizeof(table_row) * rows_capacity);
734
+ if (!rows) {
735
+ free(output);
736
+ return NULL;
737
+ }
738
+ } else if (rows_count >= rows_capacity) {
739
+ /* Grow array */
740
+ rows_capacity *= 2;
741
+ table_row *new_rows = realloc(rows, sizeof(table_row) * rows_capacity);
742
+ if (!new_rows) {
743
+ free(output);
744
+ free(rows);
745
+ return NULL;
746
+ }
747
+ rows = new_rows;
748
+ }
749
+
750
+ /* Check if columns match previous rows */
751
+ if (rows_count > 0 && rows[0].columns != columns) {
752
+ /* Column count mismatch - write accumulated rows and start fresh */
753
+ for (size_t i = 0; i < rows_count; i++) {
754
+ if (rows[i].len < remaining) {
755
+ memcpy(write, rows[i].start, rows[i].len);
756
+ write += rows[i].len;
757
+ remaining -= rows[i].len;
758
+ output_len += rows[i].len;
759
+
760
+ if (has_newline && remaining > 0) {
761
+ *write++ = '\n';
762
+ remaining--;
763
+ output_len++;
764
+ }
765
+ } else {
766
+ /* Need to grow buffer */
767
+ size_t new_capacity = output_capacity * 2;
768
+ char *new_output = realloc(output, new_capacity);
769
+ if (!new_output) {
770
+ free(output);
771
+ free(rows);
772
+ return NULL;
773
+ }
774
+ write = new_output + output_len;
775
+ output = new_output;
776
+ remaining = new_capacity - output_len;
777
+ output_capacity = new_capacity;
778
+
779
+ memcpy(write, rows[i].start, rows[i].len);
780
+ write += rows[i].len;
781
+ remaining -= rows[i].len;
782
+ output_len += rows[i].len;
783
+
784
+ if (has_newline && remaining > 0) {
785
+ *write++ = '\n';
786
+ remaining--;
787
+ output_len++;
788
+ }
789
+ }
790
+ }
791
+ rows_count = 0;
792
+ }
793
+
794
+ /* Add this row to accumulator */
795
+ rows[rows_count].start = line_start;
796
+ rows[rows_count].len = line_len;
797
+ rows[rows_count].columns = columns;
798
+ rows[rows_count].starts_with_pipe = starts_with_pipe;
799
+ rows_count++;
800
+
801
+ /* Don't write yet - wait for blank line or separator */
802
+ read = line_end;
803
+ if (has_newline) read++;
804
+ continue;
805
+ }
806
+
807
+ /* Not a table row - if we have accumulated rows, write them first */
808
+ if (rows_count >= 2) {
809
+ /* We have a relaxed table - insert separator after first row */
810
+ for (size_t i = 0; i < rows_count; i++) {
811
+ if (rows[i].len < remaining) {
812
+ memcpy(write, rows[i].start, rows[i].len);
813
+ write += rows[i].len;
814
+ remaining -= rows[i].len;
815
+ output_len += rows[i].len;
816
+
817
+ if (has_newline && remaining > 0) {
818
+ *write++ = '\n';
819
+ remaining--;
820
+ output_len++;
821
+ }
822
+ } else {
823
+ /* Need to grow buffer */
824
+ size_t new_capacity = output_capacity * 2;
825
+ char *new_output = realloc(output, new_capacity);
826
+ if (!new_output) {
827
+ free(output);
828
+ free(rows);
829
+ return NULL;
830
+ }
831
+ write = new_output + output_len;
832
+ output = new_output;
833
+ remaining = new_capacity - output_len;
834
+ output_capacity = new_capacity;
835
+
836
+ memcpy(write, rows[i].start, rows[i].len);
837
+ write += rows[i].len;
838
+ remaining -= rows[i].len;
839
+ output_len += rows[i].len;
840
+
841
+ if (has_newline && remaining > 0) {
842
+ *write++ = '\n';
843
+ remaining--;
844
+ output_len++;
845
+ }
846
+ }
847
+
848
+ /* After first row, insert separator */
849
+ if (i == 0) {
850
+ made_changes = true; /* We're inserting a separator, so output will differ */
851
+ char *sep = generate_separator_row(rows[0].columns, rows[0].starts_with_pipe);
852
+ if (sep) {
853
+ size_t sep_len = strlen(sep);
854
+ if (sep_len < remaining) {
855
+ memcpy(write, sep, sep_len);
856
+ write += sep_len;
857
+ remaining -= sep_len;
858
+ output_len += sep_len;
859
+ } else {
860
+ /* Need to grow buffer */
861
+ size_t new_capacity = output_capacity * 2;
862
+ char *new_output = realloc(output, new_capacity);
863
+ if (!new_output) {
864
+ free(sep);
865
+ free(output);
866
+ free(rows);
867
+ return NULL;
868
+ }
869
+ write = new_output + output_len;
870
+ output = new_output;
871
+ remaining = new_capacity - output_len;
872
+ output_capacity = new_capacity;
873
+
874
+ memcpy(write, sep, sep_len);
875
+ write += sep_len;
876
+ remaining -= sep_len;
877
+ output_len += sep_len;
878
+ }
879
+ free(sep);
880
+ }
881
+ }
882
+ }
883
+ rows_count = 0;
884
+ } else if (rows_count > 0) {
885
+ /* Only one row - not a table, write it as-is */
886
+ if (rows[0].len < remaining) {
887
+ memcpy(write, rows[0].start, rows[0].len);
888
+ write += rows[0].len;
889
+ remaining -= rows[0].len;
890
+ output_len += rows[0].len;
891
+
892
+ if (has_newline && remaining > 0) {
893
+ *write++ = '\n';
894
+ remaining--;
895
+ output_len++;
896
+ }
897
+ } else {
898
+ /* Need to grow buffer */
899
+ size_t new_capacity = output_capacity * 2;
900
+ char *new_output = realloc(output, new_capacity);
901
+ if (!new_output) {
902
+ free(output);
903
+ free(rows);
904
+ return NULL;
905
+ }
906
+ write = new_output + output_len;
907
+ output = new_output;
908
+ remaining = new_capacity - output_len;
909
+ output_capacity = new_capacity;
910
+
911
+ memcpy(write, rows[0].start, rows[0].len);
912
+ write += rows[0].len;
913
+ remaining -= rows[0].len;
914
+ output_len += rows[0].len;
915
+
916
+ if (has_newline && remaining > 0) {
917
+ *write++ = '\n';
918
+ remaining--;
919
+ output_len++;
920
+ }
921
+ }
922
+ rows_count = 0;
923
+ }
924
+
925
+ /* Write this line as-is */
926
+ if (line_len < remaining) {
927
+ memcpy(write, line_start, line_len);
928
+ write += line_len;
929
+ remaining -= line_len;
930
+ output_len += line_len;
931
+
932
+ if (has_newline && remaining > 0) {
933
+ *write++ = '\n';
934
+ remaining--;
935
+ output_len++;
936
+ }
937
+ } else {
938
+ /* Need to grow buffer */
939
+ size_t new_capacity = output_capacity * 2;
940
+ char *new_output = realloc(output, new_capacity);
941
+ if (!new_output) {
942
+ free(output);
943
+ free(rows);
944
+ return NULL;
945
+ }
946
+ write = new_output + output_len;
947
+ output = new_output;
948
+ remaining = new_capacity - output_len;
949
+ output_capacity = new_capacity;
950
+
951
+ memcpy(write, line_start, line_len);
952
+ write += line_len;
953
+ remaining -= line_len;
954
+ output_len += line_len;
955
+
956
+ if (has_newline && remaining > 0) {
957
+ *write++ = '\n';
958
+ remaining--;
959
+ output_len++;
960
+ }
961
+ }
962
+
963
+ read = line_end;
964
+ if (has_newline) read++;
965
+ }
966
+
967
+ /* Handle any remaining accumulated rows at end of file */
968
+ if (rows_count >= 2) {
969
+ /* We have a relaxed table - insert separator after first row */
970
+ for (size_t i = 0; i < rows_count; i++) {
971
+ if (rows[i].len < remaining) {
972
+ memcpy(write, rows[i].start, rows[i].len);
973
+ write += rows[i].len;
974
+ remaining -= rows[i].len;
975
+ output_len += rows[i].len;
976
+
977
+ *write++ = '\n';
978
+ remaining--;
979
+ output_len++;
980
+ } else {
981
+ /* Need to grow buffer */
982
+ size_t new_capacity = output_capacity * 2;
983
+ char *new_output = realloc(output, new_capacity);
984
+ if (!new_output) {
985
+ free(output);
986
+ free(rows);
987
+ return NULL;
988
+ }
989
+ write = new_output + output_len;
990
+ output = new_output;
991
+ remaining = new_capacity - output_len;
992
+ output_capacity = new_capacity;
993
+
994
+ memcpy(write, rows[i].start, rows[i].len);
995
+ write += rows[i].len;
996
+ remaining -= rows[i].len;
997
+ output_len += rows[i].len;
998
+
999
+ *write++ = '\n';
1000
+ remaining--;
1001
+ output_len++;
1002
+ }
1003
+
1004
+ /* After first row, insert separator */
1005
+ if (i == 0) {
1006
+ char *sep = generate_separator_row(rows[0].columns, rows[0].starts_with_pipe);
1007
+ if (sep) {
1008
+ size_t sep_len = strlen(sep);
1009
+ if (sep_len < remaining) {
1010
+ memcpy(write, sep, sep_len);
1011
+ write += sep_len;
1012
+ remaining -= sep_len;
1013
+ output_len += sep_len;
1014
+ } else {
1015
+ /* Need to grow buffer */
1016
+ size_t new_capacity = output_capacity * 2;
1017
+ char *new_output = realloc(output, new_capacity);
1018
+ if (!new_output) {
1019
+ free(sep);
1020
+ free(output);
1021
+ free(rows);
1022
+ return NULL;
1023
+ }
1024
+ write = new_output + output_len;
1025
+ output = new_output;
1026
+ remaining = new_capacity - output_len;
1027
+ output_capacity = new_capacity;
1028
+
1029
+ memcpy(write, sep, sep_len);
1030
+ write += sep_len;
1031
+ remaining -= sep_len;
1032
+ output_len += sep_len;
1033
+ }
1034
+ free(sep);
1035
+ }
1036
+ }
1037
+ }
1038
+ } else if (rows_count == 1) {
1039
+ /* Only one row - not a table, write it as-is */
1040
+ if (rows[0].len < remaining) {
1041
+ memcpy(write, rows[0].start, rows[0].len);
1042
+ write += rows[0].len;
1043
+ remaining -= rows[0].len;
1044
+ output_len += rows[0].len;
1045
+
1046
+ /* Only add newline if input ended with one */
1047
+ if (input_ends_with_newline && remaining > 0) {
1048
+ *write++ = '\n';
1049
+ remaining--;
1050
+ output_len++;
1051
+ }
1052
+ } else {
1053
+ /* Need to grow buffer */
1054
+ size_t new_capacity = output_capacity * 2;
1055
+ char *new_output = realloc(output, new_capacity);
1056
+ if (!new_output) {
1057
+ free(output);
1058
+ free(rows);
1059
+ return NULL;
1060
+ }
1061
+ write = new_output + output_len;
1062
+ output = new_output;
1063
+ remaining = new_capacity - output_len;
1064
+ output_capacity = new_capacity;
1065
+
1066
+ memcpy(write, rows[0].start, rows[0].len);
1067
+ write += rows[0].len;
1068
+ remaining -= rows[0].len;
1069
+ output_len += rows[0].len;
1070
+
1071
+ /* Only add newline if input ended with one */
1072
+ if (input_ends_with_newline && remaining > 0) {
1073
+ *write++ = '\n';
1074
+ remaining--;
1075
+ output_len++;
1076
+ }
1077
+ }
1078
+ }
1079
+
1080
+ free(rows);
1081
+
1082
+ /* Null-terminate */
1083
+ if (remaining > 0) {
1084
+ *write = '\0';
1085
+ } else {
1086
+ /* Need one more byte */
1087
+ size_t new_capacity = output_capacity + 1;
1088
+ char *new_output = realloc(output, new_capacity);
1089
+ if (!new_output) {
1090
+ free(output);
1091
+ return NULL;
1092
+ }
1093
+ new_output[output_len] = '\0';
1094
+ output = new_output;
1095
+ }
1096
+
1097
+ /* Check if we made any changes */
1098
+ /* Fast path: if we made no changes and lengths match, skip expensive strcmp */
1099
+ if (!made_changes && text_len == output_len) {
1100
+ free(output);
1101
+ return NULL; /* No changes */
1102
+ }
1103
+
1104
+ /* If we made changes, output definitely differs, return it */
1105
+ /* If lengths differ, output definitely differs, return it */
1106
+ /* Only do strcmp if we're not sure (shouldn't happen with proper made_changes tracking) */
1107
+ if (text_len == output_len && strcmp(text, output) == 0) {
1108
+ free(output);
1109
+ return NULL; /* No changes */
1110
+ }
1111
+
1112
+ return output;
1113
+ }
1114
+
1115
+ /**
1116
+ * Process headerless tables - detect separator rows without header rows and insert dummy headers
1117
+ * This allows alignment to be applied to tables that start with a separator row
1118
+ */
1119
+ char *apex_process_headerless_tables(const char *text) {
1120
+ if (!text) return NULL;
1121
+
1122
+ size_t text_len = strlen(text);
1123
+ if (text_len == 0) return NULL;
1124
+
1125
+ /* Allocate output buffer */
1126
+ size_t output_capacity = text_len * 2;
1127
+ char *output = malloc(output_capacity);
1128
+ if (!output) return NULL;
1129
+
1130
+ const char *read = text;
1131
+ char *write = output;
1132
+ size_t remaining = output_capacity;
1133
+ size_t output_len = 0;
1134
+
1135
+ /* Track previous line for context */
1136
+ bool prev_line_is_table_row = false;
1137
+
1138
+ /* Track if we made any changes to avoid expensive strcmp */
1139
+ bool made_changes = false;
1140
+
1141
+ /* Process line by line */
1142
+ while (*read) {
1143
+ const char *line_start = read;
1144
+ const char *line_end = strchr(read, '\n');
1145
+ if (!line_end) {
1146
+ line_end = read + strlen(read);
1147
+ }
1148
+
1149
+ size_t line_len = line_end - line_start;
1150
+ bool has_newline = (*line_end == '\n');
1151
+
1152
+ /* Skip to next line for next iteration */
1153
+ const char *next_line_start = has_newline ? line_end + 1 : line_end;
1154
+
1155
+ /* Check if this is a separator or table row */
1156
+ bool is_separator = is_separator_row(line_start, line_len);
1157
+ bool is_table = is_table_row(line_start, line_len);
1158
+
1159
+ /* Check if we have a separator row that's not part of a valid table:
1160
+ * - Previous line is NOT a table row (so separator has no header)
1161
+ * - This line IS a separator row
1162
+ * - Next line IS a table row (so separator is followed by data)
1163
+ */
1164
+ if (is_separator && !prev_line_is_table_row) {
1165
+ /* Look ahead to see if next non-blank line is a table row */
1166
+ const char *look_ahead = next_line_start;
1167
+ bool found_table_row = false;
1168
+
1169
+ while (*look_ahead) {
1170
+ const char *next_line_end = strchr(look_ahead, '\n');
1171
+ if (!next_line_end) {
1172
+ next_line_end = look_ahead + strlen(look_ahead);
1173
+ }
1174
+
1175
+ size_t next_line_len = next_line_end - look_ahead;
1176
+
1177
+ if (!is_blank_line(look_ahead, next_line_len)) {
1178
+ /* Found next non-blank line */
1179
+ if (is_table_row(look_ahead, next_line_len)) {
1180
+ found_table_row = true;
1181
+ }
1182
+ break;
1183
+ }
1184
+
1185
+ look_ahead = (*next_line_end == '\n') ? next_line_end + 1 : next_line_end;
1186
+ if (look_ahead >= text + text_len) break;
1187
+ }
1188
+
1189
+ if (found_table_row) {
1190
+ /* We need to insert a dummy header row before the separator */
1191
+ int num_columns = count_columns(line_start, line_len);
1192
+ if (num_columns > 0) {
1193
+ /* Check if separator starts with pipe to match format */
1194
+ size_t start = 0;
1195
+ while (start < line_len && (line_start[start] == ' ' || line_start[start] == '\t')) {
1196
+ start++;
1197
+ }
1198
+ bool starts_with_pipe = (start < line_len && line_start[start] == '|');
1199
+ char *dummy_header = generate_dummy_header_row(num_columns, starts_with_pipe);
1200
+
1201
+ if (dummy_header) {
1202
+ made_changes = true; /* We're inserting a header, so output will differ */
1203
+ size_t header_len = strlen(dummy_header);
1204
+
1205
+ /* Ensure we have space for header + original line */
1206
+ while (output_len + header_len + line_len + 10 > output_capacity) {
1207
+ output_capacity *= 2;
1208
+ char *new_output = realloc(output, output_capacity);
1209
+ if (!new_output) {
1210
+ free(dummy_header);
1211
+ free(output);
1212
+ return NULL;
1213
+ }
1214
+ write = new_output + output_len;
1215
+ output = new_output;
1216
+ remaining = output_capacity - output_len;
1217
+ }
1218
+
1219
+ /* Write dummy header */
1220
+ memcpy(write, dummy_header, header_len);
1221
+ write += header_len;
1222
+ output_len += header_len;
1223
+ remaining -= header_len;
1224
+
1225
+ free(dummy_header);
1226
+ }
1227
+ }
1228
+ }
1229
+ }
1230
+
1231
+ /* Copy the current line to output */
1232
+ if (line_len + 1 > remaining) {
1233
+ output_capacity *= 2;
1234
+ char *new_output = realloc(output, output_capacity);
1235
+ if (!new_output) {
1236
+ free(output);
1237
+ return NULL;
1238
+ }
1239
+ write = new_output + output_len;
1240
+ output = new_output;
1241
+ remaining = output_capacity - output_len;
1242
+ }
1243
+
1244
+ memcpy(write, line_start, line_len);
1245
+ write += line_len;
1246
+ output_len += line_len;
1247
+ remaining -= line_len;
1248
+
1249
+ if (has_newline) {
1250
+ *write++ = '\n';
1251
+ output_len++;
1252
+ remaining--;
1253
+ }
1254
+
1255
+ /* Update tracking for next iteration */
1256
+ prev_line_is_table_row = is_table && !is_separator;
1257
+
1258
+ /* Move to next line */
1259
+ read = next_line_start;
1260
+ }
1261
+
1262
+ /* Null terminate */
1263
+ if (remaining > 0) {
1264
+ *write = '\0';
1265
+ } else {
1266
+ free(output);
1267
+ return NULL;
1268
+ }
1269
+
1270
+ /* If nothing changed, return NULL to allow caller to use original */
1271
+ /* Fast path: if we made no changes and lengths match, skip expensive strcmp */
1272
+ if (!made_changes && text_len == output_len) {
1273
+ free(output);
1274
+ return NULL;
1275
+ }
1276
+
1277
+ /* If we made changes, output definitely differs, return it */
1278
+ /* If lengths differ, output definitely differs, return it */
1279
+ /* Only do strcmp if we're not sure (shouldn't happen with proper made_changes tracking) */
1280
+ if (text_len == output_len && strcmp(text, output) == 0) {
1281
+ free(output);
1282
+ return NULL;
1283
+ }
1284
+
1285
+ return output;
1286
+ }
1287
+
1288
+ /* Public API - calls internal implementation */
1289
+ char *apex_process_relaxed_tables(const char *text) {
1290
+ return apex_process_relaxed_tables_impl(text, NULL, NULL);
1291
+ }
1292
+
1293
+ char *apex_process_relaxed_tables_with_progress(const char *text,
1294
+ void (*progress_callback)(const char *stage, int percent, void *user_data),
1295
+ void *progress_user_data) {
1296
+ return apex_process_relaxed_tables_impl(text, progress_callback, progress_user_data);
1297
+ }