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.
- checksums.yaml +7 -0
- data/README.md +119 -0
- data/apex-ruby.gemspec +31 -0
- data/ext/apex_ext/apex_ext.c +215 -0
- data/ext/apex_ext/apex_src/BENCHMARK.md +32 -0
- data/ext/apex_ext/apex_src/BENCHMARK_COMPARISON.md +67 -0
- data/ext/apex_ext/apex_src/CHANGELOG.md +2454 -0
- data/ext/apex_ext/apex_src/CMakeLists.txt +454 -0
- data/ext/apex_ext/apex_src/Dockerfile.linux-build +15 -0
- data/ext/apex_ext/apex_src/Formula/apex.rb +38 -0
- data/ext/apex_ext/apex_src/Info.plist.in +27 -0
- data/ext/apex_ext/apex_src/LICENSE +21 -0
- data/ext/apex_ext/apex_src/Package.swift +160 -0
- data/ext/apex_ext/apex_src/PackageSupport/README.md +17 -0
- data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/cmark-gfm_export.h +20 -0
- data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/cmark-gfm_version.h +14 -0
- data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/cmark_gfm_spm_stub.c +4 -0
- data/ext/apex_ext/apex_src/PackageSupport/cmark-gfm/config.h +41 -0
- data/ext/apex_ext/apex_src/README.md +452 -0
- data/ext/apex_ext/apex_src/VERSION +1 -0
- data/ext/apex_ext/apex_src/apex-header-2-rb@2x.webp +0 -0
- data/ext/apex_ext/apex_src/apex-plugins.json.example +20 -0
- data/ext/apex_ext/apex_src/apex.pc.in +11 -0
- data/ext/apex_ext/apex_src/cli/main.c +2720 -0
- data/ext/apex_ext/apex_src/debug_test.sh +22 -0
- data/ext/apex_ext/apex_src/docs/API_REFERENCE.md +451 -0
- data/ext/apex_ext/apex_src/docs/ARCHITECTURE.md +166 -0
- data/ext/apex_ext/apex_src/docs/CMARK_INTEGRATION.md +220 -0
- data/ext/apex_ext/apex_src/docs/CRITICMARKUP.md +501 -0
- data/ext/apex_ext/apex_src/docs/DEBUGGING.md +73 -0
- data/ext/apex_ext/apex_src/docs/FINAL_STATUS.md +391 -0
- data/ext/apex_ext/apex_src/docs/FINAL_STATUS_UPDATE.md +237 -0
- data/ext/apex_ext/apex_src/docs/FUTURE_FEATURES.md +456 -0
- data/ext/apex_ext/apex_src/docs/IAL_FEATURES.md +210 -0
- data/ext/apex_ext/apex_src/docs/IAL_STATUS.md +344 -0
- data/ext/apex_ext/apex_src/docs/INTEGRATION_EXAMPLE.m +144 -0
- data/ext/apex_ext/apex_src/docs/LIMITATIONS_RESOLVED.md +278 -0
- data/ext/apex_ext/apex_src/docs/OUTPUT_MODES.md +321 -0
- data/ext/apex_ext/apex_src/docs/PROGRESS.md +167 -0
- data/ext/apex_ext/apex_src/docs/STANDALONE_FEATURE.md +174 -0
- data/ext/apex_ext/apex_src/docs/TABLE_SPANS_STATUS.md +243 -0
- data/ext/apex_ext/apex_src/docs/TEST_COVERAGE.md +316 -0
- data/ext/apex_ext/apex_src/docs/USER_GUIDE.md +803 -0
- data/ext/apex_ext/apex_src/docs/WIKI_LINKS_ISSUE.md +91 -0
- data/ext/apex_ext/apex_src/documentation/README.md +160 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex Command Line Options.cheatsheet.txt +365 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Info.plist +24 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/C-API.html +1737 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Citations.html +1420 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Command-Line-Options.html +3574 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Configuration.html +1603 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Credits.html +910 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Examples.html +1168 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Getting-Started.html +1003 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Header-IDs.html +1308 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Home.html +1078 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Inline-Attribute-Lists.html +1622 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Installation.html +1168 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Limitations-and-Roadmap.html +1698 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Metadata-Transforms.html +1531 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Modes.html +1980 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Multi-File-Documents.html +1368 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Pandoc-Integration.html +1151 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Plugins.html +2861 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Syntax.html +3981 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Troubleshooting.html +1454 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Usage.html +1200 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Xcode-Integration.html +2066 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/docSet.dsidx +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/optimizedIndex.dsidx +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/tempOptimizedIndex.dsidx +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Info.plist +22 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Bold.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Bold_Italic.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Extrabold.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Extrabold_Italic.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Italic.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Semibold.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/cheatset_resources/Open_Sans_Semibold_Italic.woff +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/index.html +914 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/Documents/style.css +399 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/docSet.dsidx +0 -0
- data/ext/apex_ext/apex_src/documentation/docsets/ApexCLI.docset/Contents/Resources/optimizedIndex.dsidx +0 -0
- data/ext/apex_ext/apex_src/documentation/generate_app_docs.rb +772 -0
- data/ext/apex_ext/apex_src/documentation/generate_app_docs_ai.rb +678 -0
- data/ext/apex_ext/apex_src/documentation/generate_docset.rb +873 -0
- data/ext/apex_ext/apex_src/documentation/generate_single_html.rb +733 -0
- data/ext/apex_ext/apex_src/documentation/html/apex-docs.html +17073 -0
- data/ext/apex_ext/apex_src/documentation/shared_scripts.js +64 -0
- data/ext/apex_ext/apex_src/documentation/shared_styles.css +646 -0
- data/ext/apex_ext/apex_src/documentation/transform_for_app.example.md +260 -0
- data/ext/apex_ext/apex_src/examples/bracketed_spans_demo.md +119 -0
- data/ext/apex_ext/apex_src/examples/emoji_span_plugin.yml +11 -0
- data/ext/apex_ext/apex_src/examples/example.html +53 -0
- data/ext/apex_ext/apex_src/examples/example.md +85 -0
- data/ext/apex_ext/apex_src/examples/fenced_divs_demo.md +158 -0
- data/ext/apex_ext/apex_src/examples/kbd.md +8 -0
- data/ext/apex_ext/apex_src/examples/kbd_plugin.rb +250 -0
- data/ext/apex_ext/apex_src/examples/kbd_plugin.yml +9 -0
- data/ext/apex_ext/apex_src/icon/apexicon-outline-black.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon-outline-black@2x.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon-outline-mark.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon-outline-mark@2x.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon-outline-white.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon-outline-white@2x.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon.png +0 -0
- data/ext/apex_ext/apex_src/icon/apexicon@2x.png +0 -0
- data/ext/apex_ext/apex_src/include/apex/apex.h +247 -0
- data/ext/apex_ext/apex_src/include/apex/buffer.h +93 -0
- data/ext/apex_ext/apex_src/include/apex/module.modulemap +16 -0
- data/ext/apex_ext/apex_src/include/apex/parser.h +150 -0
- data/ext/apex_ext/apex_src/include/apex/renderer.h +39 -0
- data/ext/apex_ext/apex_src/man/apex-config.5 +374 -0
- data/ext/apex_ext/apex_src/man/apex-config.5.md +260 -0
- data/ext/apex_ext/apex_src/man/apex-plugins.7 +456 -0
- data/ext/apex_ext/apex_src/man/apex-plugins.7.md +365 -0
- data/ext/apex_ext/apex_src/man/apex.1 +828 -0
- data/ext/apex_ext/apex_src/man/apex.1.md +643 -0
- data/ext/apex_ext/apex_src/man/apex.1.new +338 -0
- data/ext/apex_ext/apex_src/objc/Apex.swift +237 -0
- data/ext/apex_ext/apex_src/objc/NSString+Apex.h +117 -0
- data/ext/apex_ext/apex_src/objc/NSString+Apex.m +332 -0
- data/ext/apex_ext/apex_src/src/_README.md +358 -0
- data/ext/apex_ext/apex_src/src/apex.c +6326 -0
- data/ext/apex_ext/apex_src/src/buffer.c +93 -0
- data/ext/apex_ext/apex_src/src/extensions/abbreviations.c +362 -0
- data/ext/apex_ext/apex_src/src/extensions/abbreviations.h +45 -0
- data/ext/apex_ext/apex_src/src/extensions/advanced_footnotes.c +184 -0
- data/ext/apex_ext/apex_src/src/extensions/advanced_footnotes.h +50 -0
- data/ext/apex_ext/apex_src/src/extensions/advanced_tables.c +1897 -0
- data/ext/apex_ext/apex_src/src/extensions/advanced_tables.h +42 -0
- data/ext/apex_ext/apex_src/src/extensions/callouts.c +215 -0
- data/ext/apex_ext/apex_src/src/extensions/callouts.h +53 -0
- data/ext/apex_ext/apex_src/src/extensions/citations.c +2042 -0
- data/ext/apex_ext/apex_src/src/extensions/citations.h +163 -0
- data/ext/apex_ext/apex_src/src/extensions/critic.c +329 -0
- data/ext/apex_ext/apex_src/src/extensions/critic.h +48 -0
- data/ext/apex_ext/apex_src/src/extensions/definition_list.c +1670 -0
- data/ext/apex_ext/apex_src/src/extensions/definition_list.h +42 -0
- data/ext/apex_ext/apex_src/src/extensions/emoji.c +710 -0
- data/ext/apex_ext/apex_src/src/extensions/emoji.h +38 -0
- data/ext/apex_ext/apex_src/src/extensions/emoji_data.h +942 -0
- data/ext/apex_ext/apex_src/src/extensions/fenced_divs.c +925 -0
- data/ext/apex_ext/apex_src/src/extensions/fenced_divs.h +43 -0
- data/ext/apex_ext/apex_src/src/extensions/github-emoji.txt +869 -0
- data/ext/apex_ext/apex_src/src/extensions/grid_tables.c +1121 -0
- data/ext/apex_ext/apex_src/src/extensions/grid_tables.h +33 -0
- data/ext/apex_ext/apex_src/src/extensions/header_ids.c +626 -0
- data/ext/apex_ext/apex_src/src/extensions/header_ids.h +60 -0
- data/ext/apex_ext/apex_src/src/extensions/highlight.c +135 -0
- data/ext/apex_ext/apex_src/src/extensions/highlight.h +16 -0
- data/ext/apex_ext/apex_src/src/extensions/html_markdown.c +408 -0
- data/ext/apex_ext/apex_src/src/extensions/html_markdown.h +42 -0
- data/ext/apex_ext/apex_src/src/extensions/ial.c +4084 -0
- data/ext/apex_ext/apex_src/src/extensions/ial.h +145 -0
- data/ext/apex_ext/apex_src/src/extensions/includes.c +1536 -0
- data/ext/apex_ext/apex_src/src/extensions/includes.h +54 -0
- data/ext/apex_ext/apex_src/src/extensions/index.c +967 -0
- data/ext/apex_ext/apex_src/src/extensions/index.h +90 -0
- data/ext/apex_ext/apex_src/src/extensions/inline_footnotes.c +205 -0
- data/ext/apex_ext/apex_src/src/extensions/inline_footnotes.h +34 -0
- data/ext/apex_ext/apex_src/src/extensions/inline_tables.c +332 -0
- data/ext/apex_ext/apex_src/src/extensions/inline_tables.h +13 -0
- data/ext/apex_ext/apex_src/src/extensions/insert.c +248 -0
- data/ext/apex_ext/apex_src/src/extensions/insert.h +18 -0
- data/ext/apex_ext/apex_src/src/extensions/math.c +279 -0
- data/ext/apex_ext/apex_src/src/extensions/math.h +32 -0
- data/ext/apex_ext/apex_src/src/extensions/metadata.c +3046 -0
- data/ext/apex_ext/apex_src/src/extensions/metadata.h +125 -0
- data/ext/apex_ext/apex_src/src/extensions/relaxed_tables.c +1297 -0
- data/ext/apex_ext/apex_src/src/extensions/relaxed_tables.h +39 -0
- data/ext/apex_ext/apex_src/src/extensions/special_markers.c +194 -0
- data/ext/apex_ext/apex_src/src/extensions/special_markers.h +29 -0
- data/ext/apex_ext/apex_src/src/extensions/sup_sub.c +405 -0
- data/ext/apex_ext/apex_src/src/extensions/sup_sub.h +16 -0
- data/ext/apex_ext/apex_src/src/extensions/syntax_highlight.c +468 -0
- data/ext/apex_ext/apex_src/src/extensions/syntax_highlight.h +44 -0
- data/ext/apex_ext/apex_src/src/extensions/table_html_postprocess.c +2679 -0
- data/ext/apex_ext/apex_src/src/extensions/table_html_postprocess.h +23 -0
- data/ext/apex_ext/apex_src/src/extensions/toc.c +255 -0
- data/ext/apex_ext/apex_src/src/extensions/toc.h +34 -0
- data/ext/apex_ext/apex_src/src/extensions/wiki_links.c +624 -0
- data/ext/apex_ext/apex_src/src/extensions/wiki_links.h +58 -0
- data/ext/apex_ext/apex_src/src/html_renderer.c +2762 -0
- data/ext/apex_ext/apex_src/src/html_renderer.h +126 -0
- data/ext/apex_ext/apex_src/src/parser.c +227 -0
- data/ext/apex_ext/apex_src/src/plugins.c +895 -0
- data/ext/apex_ext/apex_src/src/plugins.h +39 -0
- data/ext/apex_ext/apex_src/src/plugins_env.c +187 -0
- data/ext/apex_ext/apex_src/src/plugins_remote.c +263 -0
- data/ext/apex_ext/apex_src/src/pretty_html.c +358 -0
- data/ext/apex_ext/apex_src/src/renderer.c +241 -0
- data/ext/apex_ext/apex_src/src/utf8.c +56 -0
- data/ext/apex_ext/apex_src/test-linux-build.sh +20 -0
- data/ext/apex_ext/apex_src/test.html +103 -0
- data/ext/apex_ext/apex_src/test_coverage.sh +121 -0
- data/ext/apex_ext/apex_src/test_ial_fenced.md +6 -0
- data/ext/apex_ext/apex_src/test_math_norm.py +79 -0
- data/ext/apex_ext/apex_src/test_pandoc_output.html +48 -0
- data/ext/apex_ext/apex_src/test_spm.sh +107 -0
- data/ext/apex_ext/apex_src/tests/ApexSPMTest/main.swift +50 -0
- data/ext/apex_ext/apex_src/tests/BENCHMARK_RESULTS.md +229 -0
- data/ext/apex_ext/apex_src/tests/CMakeLists.txt +24 -0
- data/ext/apex_ext/apex_src/tests/README.md +146 -0
- data/ext/apex_ext/apex_src/tests/benchmark.sh +113 -0
- data/ext/apex_ext/apex_src/tests/benchmark_comparison.sh +166 -0
- data/ext/apex_ext/apex_src/tests/compare_header_ids.sh +31 -0
- data/ext/apex_ext/apex_src/tests/fixtures/basic/headers.md +25 -0
- data/ext/apex_ext/apex_src/tests/fixtures/basic/list-interruption.md +24 -0
- data/ext/apex_ext/apex_src/tests/fixtures/basic/misc_markup.md +33 -0
- data/ext/apex_ext/apex_src/tests/fixtures/basic/test_basic.md +26 -0
- data/ext/apex_ext/apex_src/tests/fixtures/code/code-blocks.md +260 -0
- data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/SUMMARY.md +6 -0
- data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/chapter1.md +7 -0
- data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/index.txt +9 -0
- data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/intro.md +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/combine_summary/section1_1.md +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/comprehensive_test.md +620 -0
- data/ext/apex_ext/apex_src/tests/fixtures/debug_ref_image_ial.md +3 -0
- data/ext/apex_ext/apex_src/tests/fixtures/demos/ial.md +11 -0
- data/ext/apex_ext/apex_src/tests/fixtures/demos/ial_demo.md +177 -0
- data/ext/apex_ext/apex_src/tests/fixtures/extensions/emoji-autocorrect.md +94 -0
- data/ext/apex_ext/apex_src/tests/fixtures/extensions/emoji_test.md +3 -0
- data/ext/apex_ext/apex_src/tests/fixtures/extensions/kbd_test.md +3 -0
- data/ext/apex_ext/apex_src/tests/fixtures/ial/bracketed_spans_test.md +74 -0
- data/ext/apex_ext/apex_src/tests/fixtures/images/image_and_encoding_test.md +27 -0
- data/ext/apex_ext/apex_src/tests/fixtures/images/multimarkdown_image_attributes_test.md +60 -0
- data/ext/apex_ext/apex_src/tests/fixtures/images/pandoc_ial_image_test.md +27 -0
- data/ext/apex_ext/apex_src/tests/fixtures/images/width_height_conversion_test.md +94 -0
- data/ext/apex_ext/apex_src/tests/fixtures/img-in-div.md +16 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/code.py +4 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/data.csv +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/data.tsv +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/image.png +2 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/metadata_options.yml +11 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/nested.md +8 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/raw.html +4 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/simple.md +7 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/test_image.png +0 -0
- data/ext/apex_ext/apex_src/tests/fixtures/large_doc.md +1094 -0
- data/ext/apex_ext/apex_src/tests/fixtures/metadata_options.yml +11 -0
- data/ext/apex_ext/apex_src/tests/fixtures/output/gfm_header_id_test.md +96 -0
- data/ext/apex_ext/apex_src/tests/fixtures/output/test_citations.md +43 -0
- data/ext/apex_ext/apex_src/tests/fixtures/output/test_def_list_links.md +12 -0
- data/ext/apex_ext/apex_src/tests/fixtures/output/test_index_mmark.md +53 -0
- data/ext/apex_ext/apex_src/tests/fixtures/output/test_index_textindex.md +37 -0
- data/ext/apex_ext/apex_src/tests/fixtures/tables/advanced_tables_test.md +93 -0
- data/ext/apex_ext/apex_src/tests/fixtures/tables/inline_tables_test.md +38 -0
- data/ext/apex_ext/apex_src/tests/fixtures/tables/relaxed-table.md +12 -0
- data/ext/apex_ext/apex_src/tests/fixtures/tables/table_cr_line_endings.md +15 -0
- data/ext/apex_ext/apex_src/tests/fixtures/tables/table_no_trailing_newline.md +15 -0
- data/ext/apex_ext/apex_src/tests/generate_gfm_ids.sh +105 -0
- data/ext/apex_ext/apex_src/tests/generate_ial_demo.sh +143 -0
- data/ext/apex_ext/apex_src/tests/gfm_id_comparison_summary.md +96 -0
- data/ext/apex_ext/apex_src/tests/gh_api_test.md +6 -0
- data/ext/apex_ext/apex_src/tests/ial_demo.html +186 -0
- data/ext/apex_ext/apex_src/tests/include_code.py +19 -0
- data/ext/apex_ext/apex_src/tests/include_snippet.md +15 -0
- data/ext/apex_ext/apex_src/tests/multi_file_cli_test.sh +64 -0
- data/ext/apex_ext/apex_src/tests/sample_data.csv +7 -0
- data/ext/apex_ext/apex_src/tests/table_escaped_ltlt.md +4 -0
- data/ext/apex_ext/apex_src/tests/test_basic.c +74 -0
- data/ext/apex_ext/apex_src/tests/test_extensions.c +2116 -0
- data/ext/apex_ext/apex_src/tests/test_helpers.c +183 -0
- data/ext/apex_ext/apex_src/tests/test_helpers.h +91 -0
- data/ext/apex_ext/apex_src/tests/test_ial.c +282 -0
- data/ext/apex_ext/apex_src/tests/test_links.c +418 -0
- data/ext/apex_ext/apex_src/tests/test_marked_integration.c +265 -0
- data/ext/apex_ext/apex_src/tests/test_metadata.c +908 -0
- data/ext/apex_ext/apex_src/tests/test_output.c +1118 -0
- data/ext/apex_ext/apex_src/tests/test_plugins.c +219 -0
- data/ext/apex_ext/apex_src/tests/test_refs.bib +31 -0
- data/ext/apex_ext/apex_src/tests/test_runner.c +244 -0
- data/ext/apex_ext/apex_src/tests/test_syntax_highlight.c +198 -0
- data/ext/apex_ext/apex_src/tests/test_tables.c +862 -0
- data/ext/apex_ext/apex_src/tests/update_benchmarks.sh +9 -0
- data/ext/apex_ext/apex_src/tests/yaml_test.md +13 -0
- data/ext/apex_ext/apex_src/tests.rb +39 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/CMakeLists.txt +48 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/COPYING +170 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/CheckFileOffsetBits.c +14 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/CheckFileOffsetBits.cmake +43 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/FindAsan.cmake +74 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/Makefile.nmake +38 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/README.md +206 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/CMakeLists.txt +30 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/cplusplus.cpp +15 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/cplusplus.h +16 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/harness.c +111 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/harness.h +35 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/api_test/main.c +1169 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/appveyor.yml +21 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-bq-flat.md +16 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-bq-nested.md +13 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-code.md +11 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-fences.md +14 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-heading.md +9 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-hr.md +10 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-html.md +32 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-lheading.md +8 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-list-flat.md +67 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-list-nested.md +36 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-ref-flat.md +15 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/block-ref-nested.md +17 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-autolink.md +14 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-backticks.md +3 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-em-flat.md +5 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-em-nested.md +5 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-em-worst.md +5 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-entity.md +11 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-escape.md +15 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-html.md +44 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-links-flat.md +23 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-links-nested.md +13 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/inline-newlines.md +24 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/lorem1.md +13 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/samples/rawtabs.md +18 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/statistics.py +595 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/bench/stats.py +19 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/benchmarks.md +33 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/changelog.txt +1245 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/data/CaseFolding.txt +1495 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/CMakeLists.txt +119 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/autolink.c +508 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/autolink.h +8 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/cmark-gfm-core-extensions.h +54 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/core-extensions.c +27 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/ext_scanners.c +879 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/ext_scanners.h +24 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/ext_scanners.re +92 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/strikethrough.c +167 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/strikethrough.h +9 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.c +917 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.h +12 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tagfilter.c +60 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tagfilter.h +8 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tasklist.c +156 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/tasklist.h +8 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/CMakeLists.txt +22 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/README.md +12 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/fuzz_quadratic.c +91 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/fuzz_quadratic_brackets.c +110 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/fuzz/fuzzloop.sh +28 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/CMakeLists.txt +10 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/make_man_page.py +133 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/man1/cmark-gfm.1 +78 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/man/man3/cmark-gfm.3 +1041 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/nmake.bat +1 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/CMakeLists.txt +230 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/arena.c +104 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/blocks.c +1622 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/buffer.c +278 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/buffer.h +116 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/case_fold_switch.inc +4327 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/chunk.h +135 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark-gfm-extension_api.h +737 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark-gfm.h +833 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark-gfm_version.h.in +7 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark.c +55 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark_ctype.c +44 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/cmark_ctype.h +33 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/commonmark.c +514 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/config.h.in +76 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/entities.inc +2138 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/footnotes.c +63 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/footnotes.h +27 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini.h +57 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini_href_e.c +100 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini_html_e.c +66 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/houdini_html_u.c +149 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/html.c +502 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/html.h +27 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/inlines.c +1788 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/inlines.h +29 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/iterator.c +159 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/iterator.h +26 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/latex.c +468 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/libcmark-gfm.pc.in +10 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/linked_list.c +37 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/main.c +328 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/man.c +274 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/map.c +129 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/map.h +44 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/node.c +1045 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/node.h +167 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/parser.h +59 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/plaintext.c +218 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/plugin.c +36 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/plugin.h +34 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/references.c +43 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/references.h +26 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/registry.c +63 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/registry.h +24 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/render.c +213 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/render.h +62 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/scanners.c +14056 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/scanners.h +70 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/scanners.re +365 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/syntax_extension.c +149 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/syntax_extension.h +34 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/utf8.c +317 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/utf8.h +35 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/xml.c +182 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/suppressions +10 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/CMakeLists.txt +114 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/afl_test_cases/test.md +49 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/cmark-fuzz.c +58 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/cmark.py +105 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/entity_tests.py +67 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions-full-info-string.txt +0 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions-table-prefer-style-attributes.txt +38 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions.txt +920 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/fuzzing_dictionary +67 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/normalize.py +194 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/pathological_tests.py +160 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/regression.txt +375 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/roundtrip_tests.py +50 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/run-cmark-fuzz +4 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/smart_punct.txt +177 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/spec.txt +10212 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/spec_tests.py +152 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/toolchain-mingw32.cmake +17 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/Dockerfile +41 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/appveyor-build.bat +13 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/make_entities_inc.py +32 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/mkcasefold.pl +22 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/xml2md.xsl +319 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/tools/xml2md_gfm.xsl +80 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/why-cmark-and-not-x.md +104 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.js +6 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.py +37 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.rb +15 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper.rkt +208 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/wrappers/wrapper_ext.py +109 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/CMakeLists.txt +160 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/Changes +372 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/License +20 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/Makefile.am +51 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/ReadMe.md +46 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/announcement.msg +89 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/bootstrap +3 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/cmake/config.h.in +4 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/configure.ac +73 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/doc/doxygen.cfg +222 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/docker/README.mkd +17 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/docker/alpine-3.7 +26 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/docker/fedora-25 +26 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/docker/ubuntu-14.04 +29 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/docker/ubuntu-16.04 +24 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/anchors.yaml +10 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/array.yaml +2 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/global-tag.yaml +14 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/json.yaml +1 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/mapping.yaml +2 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/numbers.yaml +1 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/strings.yaml +7 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/tags.yaml +7 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/examples/yaml-version.yaml +3 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/include/Makefile.am +17 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/include/yaml.h +1999 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/pkg/ReadMe.md +77 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/pkg/docker/Dockerfile +32 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/pkg/docker/output/ReadMe +1 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/pkg/docker/scripts/libyaml-dist.sh +23 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/regression-inputs/clusterfuzz-testcase-minimized-5607885063061504.yml +1 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/Makefile.am +4 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/api.c +1393 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/dumper.c +394 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/emitter.c +2358 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/loader.c +544 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/parser.c +1416 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/reader.c +469 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/scanner.c +3598 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/writer.c +141 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/src/yaml_private.h +684 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/CMakeLists.txt +27 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/Makefile.am +9 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/ReadMe.md +63 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-deconstructor-alt.c +800 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-deconstructor.c +1127 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-reformatter-alt.c +217 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/example-reformatter.c +202 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-all-tests.sh +29 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-dumper.c +314 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-emitter-test-suite.c +290 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-emitter.c +327 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-loader.c +63 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-parser-test-suite.c +196 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-parser.c +88 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/run-scanner.c +63 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/test-reader.c +354 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/tests/test-version.c +29 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/yaml-0.1.pc.in +10 -0
- data/ext/apex_ext/apex_src/vendor/libyaml/yamlConfig.cmake.in +16 -0
- data/ext/apex_ext/extconf.rb +103 -0
- data/lib/apex/configurable.rb +46 -0
- data/lib/apex/document.rb +66 -0
- data/lib/apex/version.rb +15 -0
- data/lib/apex.rb +28 -0
- metadata +544 -0
|
@@ -0,0 +1,1121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Grid Tables Extension for Apex
|
|
3
|
+
* Implementation
|
|
4
|
+
*
|
|
5
|
+
* Preprocessing extension that converts Pandoc grid table syntax to
|
|
6
|
+
* pipe table format before the regular cmark parser runs.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
#include "grid_tables.h"
|
|
10
|
+
#include <string.h>
|
|
11
|
+
#include <stdlib.h>
|
|
12
|
+
#include <stdbool.h>
|
|
13
|
+
#include <ctype.h>
|
|
14
|
+
#include <stdio.h>
|
|
15
|
+
|
|
16
|
+
#define MAX_COLUMNS 64
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Check if a line starts with '+' (after whitespace)
|
|
20
|
+
* This indicates a potential grid table
|
|
21
|
+
*/
|
|
22
|
+
static bool is_grid_table_start(const char *line) {
|
|
23
|
+
if (!line) return false;
|
|
24
|
+
|
|
25
|
+
/* Skip whitespace */
|
|
26
|
+
while (*line == ' ' || *line == '\t') {
|
|
27
|
+
line++;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return *line == '+';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Check if a line is a grid table separator (starts with + followed by - or =)
|
|
35
|
+
* A separator row contains only +, -, =, :, spaces
|
|
36
|
+
* It should NOT contain | characters (pipes indicate cell boundaries, not separators)
|
|
37
|
+
*
|
|
38
|
+
* IMPORTANT: This function checks if a line is a TABLE-LEVEL separator (separating rows).
|
|
39
|
+
* Nested separators within cells (like +-------+ within | Cell +-------+ |) are NOT
|
|
40
|
+
* table separators - they're just part of the cell content.
|
|
41
|
+
*/
|
|
42
|
+
static bool is_grid_table_separator(const char *line) {
|
|
43
|
+
if (!line) return false;
|
|
44
|
+
|
|
45
|
+
/* Skip whitespace */
|
|
46
|
+
const char *p = line;
|
|
47
|
+
while (*p == ' ' || *p == '\t') {
|
|
48
|
+
p++;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (*p != '+') return false;
|
|
52
|
+
p++;
|
|
53
|
+
|
|
54
|
+
/* Check for pattern: +---+ or +===+ */
|
|
55
|
+
/* A separator should only contain +, -, =, :, and spaces - NO pipes */
|
|
56
|
+
/* Note: === may have been converted to <mark> tags by earlier preprocessing,
|
|
57
|
+
* so we need to handle that case too */
|
|
58
|
+
bool has_dash_or_equal = false;
|
|
59
|
+
bool in_mark_tag = false;
|
|
60
|
+
int mark_tag_depth = 0;
|
|
61
|
+
|
|
62
|
+
while (*p && *p != '\n' && *p != '\r') {
|
|
63
|
+
if (*p == '|') {
|
|
64
|
+
/* Pipes indicate this is a content row, not a separator */
|
|
65
|
+
/* However, nested separators within cells might have pipes around them,
|
|
66
|
+
* so we need to check if this is a full-line separator or nested */
|
|
67
|
+
/* If we see a pipe, this is NOT a table-level separator */
|
|
68
|
+
return false;
|
|
69
|
+
} else if (*p == '<' && strncmp(p, "<mark>", 6) == 0) {
|
|
70
|
+
/* Handle <mark> tag (converted from ===) */
|
|
71
|
+
in_mark_tag = true;
|
|
72
|
+
mark_tag_depth++;
|
|
73
|
+
p += 6;
|
|
74
|
+
continue;
|
|
75
|
+
} else if (*p == '<' && strncmp(p, "</mark>", 7) == 0) {
|
|
76
|
+
/* Handle </mark> tag */
|
|
77
|
+
in_mark_tag = false;
|
|
78
|
+
mark_tag_depth--;
|
|
79
|
+
if (mark_tag_depth == 0) {
|
|
80
|
+
has_dash_or_equal = true; /* Treat <mark> as equivalent to = */
|
|
81
|
+
}
|
|
82
|
+
p += 7;
|
|
83
|
+
continue;
|
|
84
|
+
} else if (in_mark_tag) {
|
|
85
|
+
/* Inside <mark> tag, skip content */
|
|
86
|
+
p++;
|
|
87
|
+
continue;
|
|
88
|
+
} else if (*p == '-' || *p == '=') {
|
|
89
|
+
has_dash_or_equal = true;
|
|
90
|
+
} else if (*p != ':' && *p != '+' && *p != ' ' && *p != '\t') {
|
|
91
|
+
/* Contains other characters - not a separator */
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
p++;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return has_dash_or_equal;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Check if a line is a header separator (contains = characters)
|
|
102
|
+
*/
|
|
103
|
+
static bool is_header_separator(const char *line) {
|
|
104
|
+
if (!line) return false;
|
|
105
|
+
|
|
106
|
+
/* Skip whitespace */
|
|
107
|
+
const char *p = line;
|
|
108
|
+
while (*p == ' ' || *p == '\t') {
|
|
109
|
+
p++;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (*p != '+') return false;
|
|
113
|
+
|
|
114
|
+
/* Check if line contains '=' characters (header separator) */
|
|
115
|
+
/* Note: === may have been converted to <mark> tags by earlier preprocessing */
|
|
116
|
+
while (*p && *p != '\n' && *p != '\r') {
|
|
117
|
+
if (*p == '<' && strncmp(p, "<mark>", 6) == 0) {
|
|
118
|
+
/* Handle <mark> tag (converted from ===) - treat as = */
|
|
119
|
+
return true;
|
|
120
|
+
} else if (*p == '=') {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
p++;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Parse alignment from a separator line
|
|
131
|
+
* Returns alignment array (0=left, 1=center, 2=right)
|
|
132
|
+
* Column count is returned via column_count parameter
|
|
133
|
+
* Format: +:===:+ (center), +===:+ (right), +:===+ (left with colon), +---+ (left)
|
|
134
|
+
*/
|
|
135
|
+
static void parse_alignment(const char *line, int *alignments, size_t *column_count) {
|
|
136
|
+
if (!line || !alignments || !column_count) return;
|
|
137
|
+
|
|
138
|
+
*column_count = 0;
|
|
139
|
+
|
|
140
|
+
/* Skip whitespace */
|
|
141
|
+
const char *p = line;
|
|
142
|
+
while (*p == ' ' || *p == '\t') {
|
|
143
|
+
p++;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (*p != '+') return;
|
|
147
|
+
p++;
|
|
148
|
+
|
|
149
|
+
size_t col = 0;
|
|
150
|
+
bool left_colon = false;
|
|
151
|
+
bool right_colon = false;
|
|
152
|
+
|
|
153
|
+
while (*p && col < MAX_COLUMNS) {
|
|
154
|
+
if (*p == '+') {
|
|
155
|
+
/* Column boundary - determine alignment */
|
|
156
|
+
if (left_colon && right_colon) {
|
|
157
|
+
alignments[col] = 1; /* Center: :---: or :===: */
|
|
158
|
+
} else if (right_colon) {
|
|
159
|
+
alignments[col] = 2; /* Right: ---: or ===: */
|
|
160
|
+
} else {
|
|
161
|
+
alignments[col] = 0; /* Left: --- or === or :--- */
|
|
162
|
+
}
|
|
163
|
+
col++;
|
|
164
|
+
left_colon = false;
|
|
165
|
+
right_colon = false;
|
|
166
|
+
} else if (*p == ':') {
|
|
167
|
+
if (p == line + 1 || (p > line && (p[-1] == '+' || p[-1] == ' ' || p[-1] == '\t'))) {
|
|
168
|
+
left_colon = true;
|
|
169
|
+
} else {
|
|
170
|
+
right_colon = true;
|
|
171
|
+
}
|
|
172
|
+
} else if (*p == '-' || *p == '=') {
|
|
173
|
+
/* Part of separator, continue */
|
|
174
|
+
}
|
|
175
|
+
p++;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
*column_count = col;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Extract cell count from a single line (for column count inference)
|
|
183
|
+
*/
|
|
184
|
+
static size_t count_cells_in_line(const char *line) {
|
|
185
|
+
if (!line) return 0;
|
|
186
|
+
|
|
187
|
+
const char *p = line;
|
|
188
|
+
|
|
189
|
+
/* Skip whitespace */
|
|
190
|
+
while (*p == ' ' || *p == '\t') {
|
|
191
|
+
p++;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Skip leading + if present */
|
|
195
|
+
if (*p == '+') {
|
|
196
|
+
p++;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
bool starts_with_pipe = (*p == '|');
|
|
200
|
+
size_t pipe_count = 0;
|
|
201
|
+
|
|
202
|
+
/* Count | characters */
|
|
203
|
+
while (*p && *p != '\n' && *p != '\r') {
|
|
204
|
+
if (*p == '|') {
|
|
205
|
+
pipe_count++;
|
|
206
|
+
}
|
|
207
|
+
p++;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/* Number of cells: if starts with |, cells = pipes - 1, else pipes + 1 */
|
|
211
|
+
if (starts_with_pipe) {
|
|
212
|
+
return pipe_count > 0 ? pipe_count - 1 : 0;
|
|
213
|
+
} else {
|
|
214
|
+
return pipe_count + 1;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Check if cell content contains block-level elements
|
|
220
|
+
* (code blocks, lists, multiple paragraphs, etc.)
|
|
221
|
+
*/
|
|
222
|
+
static bool cell_has_block_elements(const char *content) {
|
|
223
|
+
if (!content) return false;
|
|
224
|
+
|
|
225
|
+
const char *p = content;
|
|
226
|
+
bool in_code_block = false;
|
|
227
|
+
int list_marker_count = 0;
|
|
228
|
+
int paragraph_count = 0;
|
|
229
|
+
bool prev_was_blank = false;
|
|
230
|
+
|
|
231
|
+
while (*p) {
|
|
232
|
+
/* Check for code blocks */
|
|
233
|
+
if (strncmp(p, "```", 3) == 0 || strncmp(p, "~~~", 3) == 0) {
|
|
234
|
+
return true; /* Code block found */
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/* Check for list markers */
|
|
238
|
+
if ((*p == '-' || *p == '*' || *p == '+') &&
|
|
239
|
+
(p[1] == ' ' || p[1] == '\t')) {
|
|
240
|
+
list_marker_count++;
|
|
241
|
+
}
|
|
242
|
+
if (isdigit((unsigned char)*p)) {
|
|
243
|
+
const char *num_start = p;
|
|
244
|
+
while (isdigit((unsigned char)*p)) p++;
|
|
245
|
+
if (*p == '.' && (p[1] == ' ' || p[1] == '\t')) {
|
|
246
|
+
list_marker_count++;
|
|
247
|
+
}
|
|
248
|
+
p = num_start;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/* Check for multiple paragraphs (blank line between content) */
|
|
252
|
+
if (*p == '\n') {
|
|
253
|
+
if (prev_was_blank && paragraph_count == 0) {
|
|
254
|
+
/* Found blank line - check if there's content before and after */
|
|
255
|
+
const char *before = p - 1;
|
|
256
|
+
while (before > content && (*before == ' ' || *before == '\t' || *before == '\r')) {
|
|
257
|
+
before--;
|
|
258
|
+
}
|
|
259
|
+
if (before > content) {
|
|
260
|
+
const char *after = p + 1;
|
|
261
|
+
while (*after == '\n' || *after == '\r' || *after == ' ' || *after == '\t') {
|
|
262
|
+
after++;
|
|
263
|
+
}
|
|
264
|
+
if (*after && *after != '\0') {
|
|
265
|
+
paragraph_count++;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
prev_was_blank = true;
|
|
270
|
+
} else if (*p != ' ' && *p != '\t' && *p != '\r') {
|
|
271
|
+
prev_was_blank = false;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
p++;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/* If we found lists or multiple paragraphs, it has block elements */
|
|
278
|
+
return (list_marker_count > 0 || paragraph_count > 0);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Convert block-level markdown in cell to HTML format
|
|
283
|
+
* This allows block elements to be preserved in pipe table cells
|
|
284
|
+
*/
|
|
285
|
+
static char *convert_cell_block_elements_to_html(const char *content) {
|
|
286
|
+
if (!content) return NULL;
|
|
287
|
+
|
|
288
|
+
/* For now, preserve content as-is but wrap in a div for block elements */
|
|
289
|
+
/* This is a simplified approach - full implementation would parse and convert each block type */
|
|
290
|
+
size_t len = strlen(content);
|
|
291
|
+
size_t html_len = len + 100; /* Extra space for HTML tags */
|
|
292
|
+
char *html = malloc(html_len);
|
|
293
|
+
if (!html) return strdup(content); /* Fallback to original */
|
|
294
|
+
|
|
295
|
+
/* Check if it has block elements */
|
|
296
|
+
if (!cell_has_block_elements(content)) {
|
|
297
|
+
/* No block elements - return as-is */
|
|
298
|
+
strcpy(html, content);
|
|
299
|
+
return html;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* Has block elements - wrap in div and preserve newlines as <br> or keep structure */
|
|
303
|
+
/* Simple approach: wrap in <div> and preserve line breaks */
|
|
304
|
+
char *p = html;
|
|
305
|
+
const char *src = content;
|
|
306
|
+
|
|
307
|
+
strcpy(p, "<div>");
|
|
308
|
+
p += 5;
|
|
309
|
+
|
|
310
|
+
/* Convert newlines to <br> for simple cases, or preserve structure for code blocks */
|
|
311
|
+
bool in_code = false;
|
|
312
|
+
while (*src) {
|
|
313
|
+
if (strncmp(src, "```", 3) == 0 || strncmp(src, "~~~", 3) == 0) {
|
|
314
|
+
in_code = !in_code;
|
|
315
|
+
/* Copy code block marker */
|
|
316
|
+
*p++ = *src++;
|
|
317
|
+
*p++ = *src++;
|
|
318
|
+
*p++ = *src++;
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (*src == '\n') {
|
|
323
|
+
if (in_code) {
|
|
324
|
+
*p++ = '\n'; /* Preserve newlines in code */
|
|
325
|
+
} else {
|
|
326
|
+
/* Convert to <br> for paragraphs, but preserve double newlines for block separation */
|
|
327
|
+
const char *next = src + 1;
|
|
328
|
+
while (*next == ' ' || *next == '\t' || *next == '\r') next++;
|
|
329
|
+
if (*next == '\n' || *next == '\0') {
|
|
330
|
+
/* Double newline or end - preserve as paragraph break */
|
|
331
|
+
strcpy(p, "</p><p>");
|
|
332
|
+
p += 7;
|
|
333
|
+
} else {
|
|
334
|
+
strcpy(p, "<br>");
|
|
335
|
+
p += 4;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
src++;
|
|
339
|
+
} else {
|
|
340
|
+
*p++ = *src++;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/* Check buffer size */
|
|
344
|
+
if ((size_t)(p - html) > html_len - 20) {
|
|
345
|
+
size_t current_len = p - html;
|
|
346
|
+
html_len *= 2;
|
|
347
|
+
char *new_html = realloc(html, html_len);
|
|
348
|
+
if (!new_html) {
|
|
349
|
+
free(html);
|
|
350
|
+
return strdup(content);
|
|
351
|
+
}
|
|
352
|
+
html = new_html;
|
|
353
|
+
p = html + current_len;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
strcpy(p, "</div>");
|
|
358
|
+
p += 6;
|
|
359
|
+
*p = '\0';
|
|
360
|
+
|
|
361
|
+
return html;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Check if two lines have the same column structure (same number of pipes in same positions)
|
|
366
|
+
* This helps determine if lines should be combined into multi-line cells
|
|
367
|
+
*/
|
|
368
|
+
static bool has_same_column_structure(const char *line1, const char *line2) {
|
|
369
|
+
if (!line1 || !line2) return false;
|
|
370
|
+
|
|
371
|
+
const char *p1 = line1;
|
|
372
|
+
const char *p2 = line2;
|
|
373
|
+
|
|
374
|
+
/* Skip leading whitespace */
|
|
375
|
+
while (*p1 == ' ' || *p1 == '\t') p1++;
|
|
376
|
+
while (*p2 == ' ' || *p2 == '\t') p2++;
|
|
377
|
+
|
|
378
|
+
/* Skip leading + if present */
|
|
379
|
+
if (*p1 == '+') p1++;
|
|
380
|
+
if (*p2 == '+') p2++;
|
|
381
|
+
|
|
382
|
+
/* Count pipes in both lines - they should have the same number */
|
|
383
|
+
size_t pipe_count1 = 0, pipe_count2 = 0;
|
|
384
|
+
const char *q1 = p1, *q2 = p2;
|
|
385
|
+
while (*q1 && *q1 != '\n' && *q1 != '\r') {
|
|
386
|
+
if (*q1 == '|') pipe_count1++;
|
|
387
|
+
q1++;
|
|
388
|
+
}
|
|
389
|
+
while (*q2 && *q2 != '\n' && *q2 != '\r') {
|
|
390
|
+
if (*q2 == '|') pipe_count2++;
|
|
391
|
+
q2++;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/* Lines must have the same number of pipes to have the same column structure */
|
|
395
|
+
return pipe_count1 > 0 && pipe_count1 == pipe_count2;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Extract cell content from grid table row lines
|
|
400
|
+
* Grid table rows can span multiple lines until the next separator
|
|
401
|
+
* Returns array of cell strings (caller must free)
|
|
402
|
+
*/
|
|
403
|
+
static char **extract_cells_from_row_lines(char **row_lines, size_t row_line_count, size_t *cell_count) {
|
|
404
|
+
if (!row_lines || row_line_count == 0 || !cell_count) return NULL;
|
|
405
|
+
|
|
406
|
+
char **cells = malloc(MAX_COLUMNS * sizeof(char*));
|
|
407
|
+
if (!cells) return NULL;
|
|
408
|
+
|
|
409
|
+
*cell_count = 0;
|
|
410
|
+
|
|
411
|
+
/* Collect all cell content from all row lines */
|
|
412
|
+
for (size_t line_idx = 0; line_idx < row_line_count; line_idx++) {
|
|
413
|
+
const char *line = row_lines[line_idx];
|
|
414
|
+
if (!line) continue;
|
|
415
|
+
|
|
416
|
+
/* Skip separator lines - they shouldn't be in row_lines, but double-check */
|
|
417
|
+
if (is_grid_table_separator(line)) {
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/* Skip whitespace */
|
|
422
|
+
const char *p = line;
|
|
423
|
+
while (*p == ' ' || *p == '\t') {
|
|
424
|
+
p++;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/* Skip leading + if present (shouldn't be in content rows, but handle it) */
|
|
428
|
+
if (*p == '+') {
|
|
429
|
+
p++;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
/* Extract cells from this line */
|
|
433
|
+
const char *cell_start = NULL;
|
|
434
|
+
size_t current_col = 0;
|
|
435
|
+
bool first_pipe = true;
|
|
436
|
+
|
|
437
|
+
while (*p && current_col < MAX_COLUMNS) {
|
|
438
|
+
if (*p == '|') {
|
|
439
|
+
/* Cell boundary */
|
|
440
|
+
if (cell_start) {
|
|
441
|
+
/* Trim trailing whitespace */
|
|
442
|
+
const char *cell_end = p;
|
|
443
|
+
while (cell_end > cell_start && isspace((unsigned char)cell_end[-1])) {
|
|
444
|
+
cell_end--;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
size_t cell_len = cell_end - cell_start;
|
|
448
|
+
|
|
449
|
+
if (current_col < *cell_count && cells[current_col]) {
|
|
450
|
+
/* Append to existing cell (multi-line cell) */
|
|
451
|
+
/* Join with newline to preserve block element structure */
|
|
452
|
+
size_t old_len = strlen(cells[current_col]);
|
|
453
|
+
size_t new_len = old_len + cell_len + 1; /* +1 for newline */
|
|
454
|
+
char *new_cell = realloc(cells[current_col], new_len + 1);
|
|
455
|
+
if (new_cell) {
|
|
456
|
+
cells[current_col] = new_cell;
|
|
457
|
+
if (old_len > 0) {
|
|
458
|
+
cells[current_col][old_len] = '\n'; /* Join with newline for block elements */
|
|
459
|
+
old_len++;
|
|
460
|
+
}
|
|
461
|
+
memcpy(cells[current_col] + old_len, cell_start, cell_len);
|
|
462
|
+
cells[current_col][old_len + cell_len] = '\0';
|
|
463
|
+
}
|
|
464
|
+
} else {
|
|
465
|
+
/* New cell */
|
|
466
|
+
if (current_col >= *cell_count) {
|
|
467
|
+
*cell_count = current_col + 1;
|
|
468
|
+
}
|
|
469
|
+
cells[current_col] = malloc(cell_len + 1);
|
|
470
|
+
if (cells[current_col]) {
|
|
471
|
+
memcpy(cells[current_col], cell_start, cell_len);
|
|
472
|
+
cells[current_col][cell_len] = '\0';
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
current_col++;
|
|
476
|
+
} else if (!first_pipe) {
|
|
477
|
+
/* Empty cell (not at start of line) */
|
|
478
|
+
if (current_col >= *cell_count) {
|
|
479
|
+
*cell_count = current_col + 1;
|
|
480
|
+
}
|
|
481
|
+
cells[current_col] = malloc(1);
|
|
482
|
+
if (cells[current_col]) {
|
|
483
|
+
cells[current_col][0] = '\0';
|
|
484
|
+
}
|
|
485
|
+
current_col++;
|
|
486
|
+
}
|
|
487
|
+
/* Skip the first pipe (leading pipe) - don't create a cell for it */
|
|
488
|
+
first_pipe = false;
|
|
489
|
+
cell_start = p + 1;
|
|
490
|
+
} else if (*p == '\n' || *p == '\r') {
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
p++;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/* Handle final cell if line doesn't end with | */
|
|
497
|
+
if (cell_start && *cell_start && current_col < MAX_COLUMNS) {
|
|
498
|
+
const char *cell_end = p;
|
|
499
|
+
while (cell_end > cell_start && isspace((unsigned char)cell_end[-1])) {
|
|
500
|
+
cell_end--;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
size_t cell_len = cell_end - cell_start;
|
|
504
|
+
if (current_col >= *cell_count) {
|
|
505
|
+
*cell_count = current_col + 1;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
if (cells[current_col]) {
|
|
509
|
+
/* Append to existing */
|
|
510
|
+
size_t old_len = strlen(cells[current_col]);
|
|
511
|
+
size_t new_len = old_len + cell_len + 1;
|
|
512
|
+
char *new_cell = realloc(cells[current_col], new_len + 1);
|
|
513
|
+
if (new_cell) {
|
|
514
|
+
cells[current_col] = new_cell;
|
|
515
|
+
if (old_len > 0) {
|
|
516
|
+
cells[current_col][old_len] = '\n'; /* Join with newline */
|
|
517
|
+
old_len++;
|
|
518
|
+
}
|
|
519
|
+
memcpy(cells[current_col] + old_len, cell_start, cell_len);
|
|
520
|
+
cells[current_col][old_len + cell_len] = '\0';
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
cells[current_col] = malloc(cell_len + 1);
|
|
524
|
+
if (cells[current_col]) {
|
|
525
|
+
memcpy(cells[current_col], cell_start, cell_len);
|
|
526
|
+
cells[current_col][cell_len] = '\0';
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
return cells;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Create pipe table separator row from alignment array
|
|
537
|
+
*/
|
|
538
|
+
static char *create_pipe_separator(int *alignments, size_t column_count) {
|
|
539
|
+
if (!alignments || column_count == 0) return NULL;
|
|
540
|
+
|
|
541
|
+
/* Calculate size needed */
|
|
542
|
+
size_t len = column_count * 8 + 2; /* | :---: | ... | */
|
|
543
|
+
char *sep = malloc(len);
|
|
544
|
+
if (!sep) return NULL;
|
|
545
|
+
|
|
546
|
+
char *p = sep;
|
|
547
|
+
|
|
548
|
+
for (size_t i = 0; i < column_count; i++) {
|
|
549
|
+
*p++ = '|';
|
|
550
|
+
|
|
551
|
+
int align = alignments[i];
|
|
552
|
+
if (align == 1) {
|
|
553
|
+
/* Center: :---: */
|
|
554
|
+
*p++ = ' ';
|
|
555
|
+
*p++ = ':';
|
|
556
|
+
*p++ = '-';
|
|
557
|
+
*p++ = '-';
|
|
558
|
+
*p++ = '-';
|
|
559
|
+
*p++ = ':';
|
|
560
|
+
*p++ = ' ';
|
|
561
|
+
} else if (align == 2) {
|
|
562
|
+
/* Right: ---: */
|
|
563
|
+
*p++ = ' ';
|
|
564
|
+
*p++ = '-';
|
|
565
|
+
*p++ = '-';
|
|
566
|
+
*p++ = '-';
|
|
567
|
+
*p++ = ':';
|
|
568
|
+
*p++ = ' ';
|
|
569
|
+
} else {
|
|
570
|
+
/* Left: --- */
|
|
571
|
+
*p++ = ' ';
|
|
572
|
+
*p++ = '-';
|
|
573
|
+
*p++ = '-';
|
|
574
|
+
*p++ = '-';
|
|
575
|
+
*p++ = ' ';
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
*p++ = '|';
|
|
580
|
+
|
|
581
|
+
*p = '\0';
|
|
582
|
+
return sep;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Convert grid table rows to pipe table format
|
|
587
|
+
* Groups lines between separators into rows and handles multi-line cells
|
|
588
|
+
*/
|
|
589
|
+
static char *convert_grid_table_to_pipe(char **lines, size_t line_count,
|
|
590
|
+
int *alignments, size_t column_count) {
|
|
591
|
+
if (!lines || line_count == 0 || !alignments || column_count == 0) {
|
|
592
|
+
return NULL;
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
/* Calculate approximate size needed */
|
|
596
|
+
size_t total_size = 0;
|
|
597
|
+
for (size_t i = 0; i < line_count; i++) {
|
|
598
|
+
if (lines[i]) {
|
|
599
|
+
total_size += strlen(lines[i]) + column_count * 4 + 10;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
total_size += 200; /* Extra for separator and formatting */
|
|
603
|
+
|
|
604
|
+
char *output = malloc(total_size);
|
|
605
|
+
if (!output) return NULL;
|
|
606
|
+
|
|
607
|
+
char *p = output;
|
|
608
|
+
size_t remaining = total_size;
|
|
609
|
+
|
|
610
|
+
/* Add blank lines at start of table for proper recognition */
|
|
611
|
+
*p++ = '\n';
|
|
612
|
+
*p++ = '\n';
|
|
613
|
+
remaining -= 2;
|
|
614
|
+
|
|
615
|
+
bool separator_processed = false;
|
|
616
|
+
bool header_written = false;
|
|
617
|
+
bool rows_written = false; /* Track if we've written any rows */
|
|
618
|
+
|
|
619
|
+
/* First, find the header separator to identify header vs body */
|
|
620
|
+
size_t header_sep_idx = 0;
|
|
621
|
+
bool has_header_sep = false;
|
|
622
|
+
for (size_t i = 0; i < line_count; i++) {
|
|
623
|
+
if (lines[i] && is_header_separator(lines[i])) {
|
|
624
|
+
header_sep_idx = i;
|
|
625
|
+
has_header_sep = true;
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/* Group lines into rows (lines between separators) */
|
|
631
|
+
size_t row_start = 0;
|
|
632
|
+
|
|
633
|
+
for (size_t i = 0; i < line_count; i++) {
|
|
634
|
+
const char *line = lines[i];
|
|
635
|
+
if (!line) continue;
|
|
636
|
+
|
|
637
|
+
/* Check if this is a separator line */
|
|
638
|
+
if (is_grid_table_separator(line)) {
|
|
639
|
+
bool is_header_sep = is_header_separator(line);
|
|
640
|
+
bool is_footer_sep = false;
|
|
641
|
+
|
|
642
|
+
/* Check if this is a footer separator (last separator before blank line) */
|
|
643
|
+
if (is_header_sep && i > 0) {
|
|
644
|
+
/* Check if there are more non-separator lines after this */
|
|
645
|
+
bool has_more_content = false;
|
|
646
|
+
for (size_t j = i + 1; j < line_count; j++) {
|
|
647
|
+
if (lines[j] && !is_grid_table_separator(lines[j]) &&
|
|
648
|
+
strchr(lines[j], '|')) {
|
|
649
|
+
has_more_content = true;
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
if (!has_more_content) {
|
|
654
|
+
is_footer_sep = true;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/* Process rows between previous separator and this one */
|
|
659
|
+
if (i > row_start) {
|
|
660
|
+
/* Check if this is header section (before header separator) */
|
|
661
|
+
bool is_header_section = (has_header_sep && i <= header_sep_idx);
|
|
662
|
+
|
|
663
|
+
/* Group lines into logical rows (lines with same column structure are multi-line cells) */
|
|
664
|
+
size_t line_idx = row_start;
|
|
665
|
+
while (line_idx < i) {
|
|
666
|
+
/* Find all consecutive lines with same column structure */
|
|
667
|
+
size_t row_line_start = line_idx;
|
|
668
|
+
size_t row_line_count = 0;
|
|
669
|
+
|
|
670
|
+
/* Collect lines that form a single logical row */
|
|
671
|
+
const char *first_line = NULL;
|
|
672
|
+
for (size_t j = line_idx; j < i; j++) {
|
|
673
|
+
if (lines[j] && !is_grid_table_separator(lines[j]) && strchr(lines[j], '|')) {
|
|
674
|
+
if (!first_line) {
|
|
675
|
+
first_line = lines[j];
|
|
676
|
+
row_line_start = j;
|
|
677
|
+
row_line_count = 1;
|
|
678
|
+
} else if (has_same_column_structure(first_line, lines[j])) {
|
|
679
|
+
/* Same column structure - part of multi-line cell */
|
|
680
|
+
row_line_count++;
|
|
681
|
+
} else {
|
|
682
|
+
/* Different column structure - new row */
|
|
683
|
+
/* Note: Lines with nested separators (like +-------+ within cells) will be
|
|
684
|
+
* treated as separate rows, which is correct. The nested separator will be
|
|
685
|
+
* included as literal text in the cell content. */
|
|
686
|
+
break;
|
|
687
|
+
}
|
|
688
|
+
} else if (first_line) {
|
|
689
|
+
/* Blank line or separator - end of current row */
|
|
690
|
+
break;
|
|
691
|
+
} else {
|
|
692
|
+
/* Skip blank lines before first content line */
|
|
693
|
+
line_idx++;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
if (row_line_count > 0) {
|
|
698
|
+
/* Extract cells from all lines in this logical row */
|
|
699
|
+
char **row_lines_array = malloc(row_line_count * sizeof(char*));
|
|
700
|
+
if (row_lines_array) {
|
|
701
|
+
for (size_t j = 0; j < row_line_count; j++) {
|
|
702
|
+
row_lines_array[j] = lines[row_line_start + j];
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
size_t cell_count = 0;
|
|
706
|
+
char **cells = extract_cells_from_row_lines(row_lines_array, row_line_count, &cell_count);
|
|
707
|
+
|
|
708
|
+
if (cells && cell_count > 0) {
|
|
709
|
+
/* Write header separator after first header row, before first body row */
|
|
710
|
+
if (is_header_section && !header_written && !separator_processed && !is_footer_sep) {
|
|
711
|
+
header_written = true;
|
|
712
|
+
} else if (!is_header_section && !separator_processed && !is_footer_sep) {
|
|
713
|
+
/* This is first body row - write separator before it */
|
|
714
|
+
char *sep = create_pipe_separator(alignments, column_count);
|
|
715
|
+
if (sep) {
|
|
716
|
+
size_t sep_len = strlen(sep);
|
|
717
|
+
if (sep_len < remaining) {
|
|
718
|
+
memcpy(p, sep, sep_len);
|
|
719
|
+
p += sep_len;
|
|
720
|
+
remaining -= sep_len;
|
|
721
|
+
*p++ = '\n';
|
|
722
|
+
remaining--;
|
|
723
|
+
}
|
|
724
|
+
free(sep);
|
|
725
|
+
}
|
|
726
|
+
separator_processed = true;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/* Convert to pipe table row */
|
|
730
|
+
if (remaining > column_count * 50) {
|
|
731
|
+
*p++ = '|';
|
|
732
|
+
remaining--;
|
|
733
|
+
|
|
734
|
+
for (size_t k = 0; k < column_count; k++) {
|
|
735
|
+
const char *cell_content = (k < cell_count && cells[k]) ? cells[k] : "";
|
|
736
|
+
|
|
737
|
+
/* Trim leading/trailing whitespace from cell content */
|
|
738
|
+
const char *content_start = cell_content;
|
|
739
|
+
const char *content_end = cell_content + strlen(cell_content);
|
|
740
|
+
while (content_start < content_end && isspace((unsigned char)*content_start)) {
|
|
741
|
+
content_start++;
|
|
742
|
+
}
|
|
743
|
+
while (content_end > content_start && isspace((unsigned char)content_end[-1])) {
|
|
744
|
+
content_end--;
|
|
745
|
+
}
|
|
746
|
+
size_t content_len = content_end - content_start;
|
|
747
|
+
|
|
748
|
+
if (content_len > 0 && content_len < remaining - 5) {
|
|
749
|
+
*p++ = ' ';
|
|
750
|
+
remaining--;
|
|
751
|
+
memcpy(p, content_start, content_len);
|
|
752
|
+
p += content_len;
|
|
753
|
+
remaining -= content_len;
|
|
754
|
+
*p++ = ' ';
|
|
755
|
+
remaining--;
|
|
756
|
+
} else {
|
|
757
|
+
*p++ = ' ';
|
|
758
|
+
remaining--;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
*p++ = '|';
|
|
762
|
+
remaining--;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
*p++ = '\n';
|
|
766
|
+
remaining--;
|
|
767
|
+
rows_written = true; /* Mark that we've written a row */
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
/* Free cells */
|
|
771
|
+
for (size_t k = 0; k < cell_count; k++) {
|
|
772
|
+
if (cells[k]) free(cells[k]);
|
|
773
|
+
}
|
|
774
|
+
free(cells);
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
free(row_lines_array);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
line_idx = row_line_start + row_line_count;
|
|
781
|
+
} else {
|
|
782
|
+
line_idx++;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/* Write separator after header rows if this is the header separator */
|
|
788
|
+
if (is_header_sep && !is_footer_sep && !separator_processed && header_written) {
|
|
789
|
+
char *sep = create_pipe_separator(alignments, column_count);
|
|
790
|
+
if (sep) {
|
|
791
|
+
size_t sep_len = strlen(sep);
|
|
792
|
+
if (sep_len < remaining) {
|
|
793
|
+
memcpy(p, sep, sep_len);
|
|
794
|
+
p += sep_len;
|
|
795
|
+
remaining -= sep_len;
|
|
796
|
+
*p++ = '\n';
|
|
797
|
+
remaining--;
|
|
798
|
+
}
|
|
799
|
+
free(sep);
|
|
800
|
+
}
|
|
801
|
+
separator_processed = true;
|
|
802
|
+
} else if (!is_header_sep && !is_footer_sep && !separator_processed && rows_written) {
|
|
803
|
+
/* Regular separator (not header) - write separator after rows have been written */
|
|
804
|
+
/* But only if we haven't written header separator yet */
|
|
805
|
+
if (!has_header_sep || i > header_sep_idx) {
|
|
806
|
+
char *sep = create_pipe_separator(alignments, column_count);
|
|
807
|
+
if (sep) {
|
|
808
|
+
size_t sep_len = strlen(sep);
|
|
809
|
+
if (sep_len < remaining) {
|
|
810
|
+
memcpy(p, sep, sep_len);
|
|
811
|
+
p += sep_len;
|
|
812
|
+
remaining -= sep_len;
|
|
813
|
+
*p++ = '\n';
|
|
814
|
+
remaining--;
|
|
815
|
+
}
|
|
816
|
+
free(sep);
|
|
817
|
+
}
|
|
818
|
+
separator_processed = true;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
row_start = i + 1;
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/* Process final rows after last separator */
|
|
828
|
+
if (row_start < line_count) {
|
|
829
|
+
char **row_lines = malloc((line_count - row_start) * sizeof(char*));
|
|
830
|
+
if (row_lines) {
|
|
831
|
+
size_t row_line_count = 0;
|
|
832
|
+
for (size_t j = row_start; j < line_count; j++) {
|
|
833
|
+
/* Skip separator rows - only include content rows */
|
|
834
|
+
if (lines[j] && !is_grid_table_separator(lines[j]) && strchr(lines[j], '|')) {
|
|
835
|
+
row_lines[row_line_count++] = lines[j];
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
if (row_line_count > 0) {
|
|
840
|
+
size_t cell_count = 0;
|
|
841
|
+
char **cells = extract_cells_from_row_lines(row_lines, row_line_count, &cell_count);
|
|
842
|
+
|
|
843
|
+
if (cells && cell_count > 0) {
|
|
844
|
+
if (remaining > column_count * 50) {
|
|
845
|
+
*p++ = '|';
|
|
846
|
+
remaining--;
|
|
847
|
+
|
|
848
|
+
for (size_t j = 0; j < column_count; j++) {
|
|
849
|
+
const char *cell_content = (j < cell_count && cells[j]) ? cells[j] : "";
|
|
850
|
+
|
|
851
|
+
/* Trim leading/trailing whitespace from cell content */
|
|
852
|
+
const char *content_start = cell_content;
|
|
853
|
+
const char *content_end = cell_content + strlen(cell_content);
|
|
854
|
+
while (content_start < content_end && isspace((unsigned char)*content_start)) {
|
|
855
|
+
content_start++;
|
|
856
|
+
}
|
|
857
|
+
while (content_end > content_start && isspace((unsigned char)content_end[-1])) {
|
|
858
|
+
content_end--;
|
|
859
|
+
}
|
|
860
|
+
size_t content_len = content_end - content_start;
|
|
861
|
+
|
|
862
|
+
*p++ = '|';
|
|
863
|
+
remaining--;
|
|
864
|
+
|
|
865
|
+
if (content_len > 0 && content_len < remaining - 5) {
|
|
866
|
+
*p++ = ' ';
|
|
867
|
+
remaining--;
|
|
868
|
+
memcpy(p, content_start, content_len);
|
|
869
|
+
p += content_len;
|
|
870
|
+
remaining -= content_len;
|
|
871
|
+
*p++ = ' ';
|
|
872
|
+
remaining--;
|
|
873
|
+
} else {
|
|
874
|
+
*p++ = ' ';
|
|
875
|
+
remaining--;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
*p++ = '\n';
|
|
880
|
+
remaining--;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
for (size_t j = 0; j < cell_count; j++) {
|
|
884
|
+
if (cells[j]) free(cells[j]);
|
|
885
|
+
}
|
|
886
|
+
free(cells);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
free(row_lines);
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
/* Add blank line at end of table */
|
|
894
|
+
if (p > output && p[-1] != '\n') {
|
|
895
|
+
*p++ = '\n';
|
|
896
|
+
remaining--;
|
|
897
|
+
}
|
|
898
|
+
*p++ = '\n';
|
|
899
|
+
remaining--;
|
|
900
|
+
|
|
901
|
+
*p = '\0';
|
|
902
|
+
return output;
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Main preprocessing function
|
|
907
|
+
*/
|
|
908
|
+
char *apex_preprocess_grid_tables(const char *text) {
|
|
909
|
+
if (!text) return NULL;
|
|
910
|
+
|
|
911
|
+
size_t len = strlen(text);
|
|
912
|
+
if (len == 0) return strdup("");
|
|
913
|
+
|
|
914
|
+
/* Allocate output buffer (may grow) */
|
|
915
|
+
size_t cap = len * 2 + 1;
|
|
916
|
+
char *output = malloc(cap);
|
|
917
|
+
if (!output) return NULL;
|
|
918
|
+
|
|
919
|
+
const char *read = text;
|
|
920
|
+
char *write = output;
|
|
921
|
+
size_t remaining = cap;
|
|
922
|
+
bool in_code_block = false;
|
|
923
|
+
|
|
924
|
+
while (*read) {
|
|
925
|
+
const char *line_start = read;
|
|
926
|
+
|
|
927
|
+
/* Find line ending */
|
|
928
|
+
const char *line_end = strchr(read, '\n');
|
|
929
|
+
if (!line_end) {
|
|
930
|
+
line_end = read + strlen(read);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
size_t line_len = line_end - line_start;
|
|
934
|
+
bool has_newline = (*line_end == '\n');
|
|
935
|
+
|
|
936
|
+
/* Track code blocks */
|
|
937
|
+
const char *p = line_start;
|
|
938
|
+
while (p < line_end && (*p == ' ' || *p == '\t')) {
|
|
939
|
+
p++;
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
if (!in_code_block &&
|
|
943
|
+
(line_end - p) >= 3 &&
|
|
944
|
+
((p[0] == '`' && p[1] == '`' && p[2] == '`') ||
|
|
945
|
+
(p[0] == '~' && p[1] == '~' && p[2] == '~'))) {
|
|
946
|
+
in_code_block = true;
|
|
947
|
+
} else if (in_code_block &&
|
|
948
|
+
(line_end - p) >= 3 &&
|
|
949
|
+
((p[0] == '`' && p[1] == '`' && p[2] == '`') ||
|
|
950
|
+
(p[0] == '~' && p[1] == '~' && p[2] == '~'))) {
|
|
951
|
+
in_code_block = false;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
/* Check if this is a grid table start */
|
|
955
|
+
if (!in_code_block && is_grid_table_start(line_start)) {
|
|
956
|
+
/* Collect all consecutive non-blank lines until blank line */
|
|
957
|
+
char **table_lines = malloc(100 * sizeof(char*));
|
|
958
|
+
if (!table_lines) {
|
|
959
|
+
/* Out of memory - copy line as-is */
|
|
960
|
+
if (line_len < remaining) {
|
|
961
|
+
memcpy(write, line_start, line_len);
|
|
962
|
+
write += line_len;
|
|
963
|
+
remaining -= line_len;
|
|
964
|
+
if (has_newline) {
|
|
965
|
+
*write++ = '\n';
|
|
966
|
+
remaining--;
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
read = has_newline ? line_end + 1 : line_end;
|
|
970
|
+
continue;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
size_t table_line_count = 0;
|
|
974
|
+
|
|
975
|
+
/* Collect table lines */
|
|
976
|
+
while (*read && table_line_count < 100) {
|
|
977
|
+
const char *current_line_start = read;
|
|
978
|
+
const char *current_line_end = strchr(read, '\n');
|
|
979
|
+
if (!current_line_end) {
|
|
980
|
+
current_line_end = read + strlen(read);
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
/* Check if blank line */
|
|
984
|
+
bool is_blank = true;
|
|
985
|
+
for (const char *q = current_line_start; q < current_line_end; q++) {
|
|
986
|
+
if (!isspace((unsigned char)*q)) {
|
|
987
|
+
is_blank = false;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
if (is_blank) {
|
|
993
|
+
break;
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
size_t current_line_len = current_line_end - current_line_start;
|
|
997
|
+
table_lines[table_line_count] = malloc(current_line_len + 1);
|
|
998
|
+
if (table_lines[table_line_count]) {
|
|
999
|
+
memcpy(table_lines[table_line_count], current_line_start, current_line_len);
|
|
1000
|
+
table_lines[table_line_count][current_line_len] = '\0';
|
|
1001
|
+
table_line_count++;
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
read = (*current_line_end == '\n') ? current_line_end + 1 : current_line_end;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
if (table_line_count > 0) {
|
|
1008
|
+
/* Parse alignment from separator lines and find maximum column count */
|
|
1009
|
+
int alignments[MAX_COLUMNS] = {0};
|
|
1010
|
+
size_t column_count = 0;
|
|
1011
|
+
|
|
1012
|
+
/* First pass: find maximum column count from all separators */
|
|
1013
|
+
for (size_t i = 0; i < table_line_count; i++) {
|
|
1014
|
+
if (is_grid_table_separator(table_lines[i])) {
|
|
1015
|
+
size_t sep_cols = 0;
|
|
1016
|
+
int sep_alignments[MAX_COLUMNS] = {0};
|
|
1017
|
+
parse_alignment(table_lines[i], sep_alignments, &sep_cols);
|
|
1018
|
+
if (sep_cols > column_count) {
|
|
1019
|
+
column_count = sep_cols;
|
|
1020
|
+
/* Use alignments from the separator with most columns */
|
|
1021
|
+
memcpy(alignments, sep_alignments, sizeof(sep_alignments));
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
/* If no separator found, try to infer from content rows */
|
|
1027
|
+
if (column_count == 0) {
|
|
1028
|
+
for (size_t i = 0; i < table_line_count; i++) {
|
|
1029
|
+
if (strchr(table_lines[i], '|') && !is_grid_table_separator(table_lines[i])) {
|
|
1030
|
+
size_t row_cols = count_cells_in_line(table_lines[i]);
|
|
1031
|
+
if (row_cols > column_count) {
|
|
1032
|
+
column_count = row_cols;
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
}
|
|
1036
|
+
/* Set default alignments */
|
|
1037
|
+
for (size_t j = 0; j < column_count && j < MAX_COLUMNS; j++) {
|
|
1038
|
+
alignments[j] = 0; /* Default left */
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/* Convert grid table to pipe table */
|
|
1043
|
+
char *pipe_table = convert_grid_table_to_pipe(table_lines, table_line_count,
|
|
1044
|
+
alignments, column_count);
|
|
1045
|
+
|
|
1046
|
+
if (pipe_table) {
|
|
1047
|
+
size_t pipe_len = strlen(pipe_table);
|
|
1048
|
+
|
|
1049
|
+
/* Ensure we have enough space */
|
|
1050
|
+
if (remaining < pipe_len) {
|
|
1051
|
+
size_t written = write - output;
|
|
1052
|
+
cap = (written + pipe_len + 100) * 2;
|
|
1053
|
+
char *new_output = realloc(output, cap);
|
|
1054
|
+
if (new_output) {
|
|
1055
|
+
output = new_output;
|
|
1056
|
+
write = output + written;
|
|
1057
|
+
remaining = cap - written;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/* Write the table (it already has blank lines at start and end) */
|
|
1062
|
+
if (pipe_len <= remaining) {
|
|
1063
|
+
memcpy(write, pipe_table, pipe_len);
|
|
1064
|
+
write += pipe_len;
|
|
1065
|
+
remaining -= pipe_len;
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
free(pipe_table);
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
/* Free table lines */
|
|
1072
|
+
for (size_t i = 0; i < table_line_count; i++) {
|
|
1073
|
+
if (table_lines[i]) free(table_lines[i]);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
free(table_lines);
|
|
1078
|
+
|
|
1079
|
+
/* read is already pointing past all the table lines we just processed
|
|
1080
|
+
* (it was updated in the loop at line 1009) */
|
|
1081
|
+
/* Skip the blank line if present */
|
|
1082
|
+
if (*read == '\n') {
|
|
1083
|
+
read++;
|
|
1084
|
+
}
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/* Not a grid table - copy line as-is */
|
|
1089
|
+
if (line_len < remaining) {
|
|
1090
|
+
memcpy(write, line_start, line_len);
|
|
1091
|
+
write += line_len;
|
|
1092
|
+
remaining -= line_len;
|
|
1093
|
+
if (has_newline) {
|
|
1094
|
+
*write++ = '\n';
|
|
1095
|
+
remaining--;
|
|
1096
|
+
}
|
|
1097
|
+
} else {
|
|
1098
|
+
/* Need to reallocate */
|
|
1099
|
+
size_t written = write - output;
|
|
1100
|
+
cap = (written + line_len + 1) * 2;
|
|
1101
|
+
char *new_output = realloc(output, cap);
|
|
1102
|
+
if (new_output) {
|
|
1103
|
+
output = new_output;
|
|
1104
|
+
write = output + written;
|
|
1105
|
+
remaining = cap - written;
|
|
1106
|
+
memcpy(write, line_start, line_len);
|
|
1107
|
+
write += line_len;
|
|
1108
|
+
remaining -= line_len;
|
|
1109
|
+
if (has_newline) {
|
|
1110
|
+
*write++ = '\n';
|
|
1111
|
+
remaining--;
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
read = has_newline ? line_end + 1 : line_end;
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
*write = '\0';
|
|
1120
|
+
return output;
|
|
1121
|
+
}
|