apex-ruby 1.0.18 → 1.0.20
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 +4 -4
- data/README.md +17 -3
- data/ext/apex_ext/apex_ext.c +260 -91
- data/ext/apex_ext/apex_src/CHANGELOG.md +440 -0
- data/ext/apex_ext/apex_src/CMakeLists.txt +15 -1
- data/ext/apex_ext/apex_src/Formula/apex.rb +7 -2
- data/ext/apex_ext/apex_src/Package.swift +15 -4
- data/ext/apex_ext/apex_src/README.md +94 -35
- data/ext/apex_ext/apex_src/VERSION +1 -1
- data/ext/apex_ext/apex_src/apex-debug.log +4 -0
- data/ext/apex_ext/apex_src/apex.code-workspace +38 -0
- data/ext/apex_ext/apex_src/apex.taskpaper +12 -0
- data/ext/apex_ext/apex_src/apex_deflist_debug.log +25 -0
- data/ext/apex_ext/apex_src/buildnotes.md +1435 -0
- data/ext/apex_ext/apex_src/cli/main.c +262 -33
- data/ext/apex_ext/apex_src/debug.log +7 -0
- data/ext/apex_ext/apex_src/docs/CITATIONS_EXAMPLES.md +274 -0
- data/ext/apex_ext/apex_src/docs/CITATIONS_IMPLEMENTATION_PLAN.md +749 -0
- data/ext/apex_ext/apex_src/docs/CITATIONS_PLAN.md +744 -0
- data/ext/apex_ext/apex_src/docs/INDEX_IMPLEMENTATION_ANALYSIS.md +382 -0
- data/ext/apex_ext/apex_src/docs/plans/2025-02-27-man-page-output-implementation.md +351 -0
- data/ext/apex_ext/apex_src/docs/superpowers/plans/2026-07-12-toc-output-format.md +745 -0
- data/ext/apex_ext/apex_src/docs/superpowers/plans/2026-07-18-bear-image-attributes.md +829 -0
- data/ext/apex_ext/apex_src/docs/superpowers/plans/2026-07-19-apex-node-npm.md +1148 -0
- data/ext/apex_ext/apex_src/docs/superpowers/specs/2026-07-12-toc-output-format-design.md +161 -0
- data/ext/apex_ext/apex_src/docs/superpowers/specs/2026-07-18-bear-image-attributes-design.md +184 -0
- data/ext/apex_ext/apex_src/docs/superpowers/specs/2026-07-19-apex-node-npm-design.md +211 -0
- data/ext/apex_ext/apex_src/documentation/app-settings-table.md +67 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Citations.md +340 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Credits.md +11 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Header-IDs.md +234 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Inline-Attribute-Lists.md +516 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Metadata-Transforms.md +461 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Modes.md +193 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Multi-File-Documents.md +201 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Plugins.md +678 -0
- data/ext/apex_ext/apex_src/documentation/app-transformed/Syntax.md +1367 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex Command Line Options.cheatsheet.txt +6 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/C-API.html +774 -300
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Callouts.html +1194 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Citations.html +416 -216
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Command-Line-Options.html +3544 -1094
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Configuration.html +371 -97
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Credits.html +153 -23
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Examples.html +358 -124
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Filters.html +1656 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Generating-Man-Pages.html +1226 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Getting-Started.html +201 -56
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Header-IDs.html +279 -109
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Home.html +200 -53
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Indices.html +2327 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Inline-Attribute-Lists.html +690 -271
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Installation.html +201 -55
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Limitations-and-Roadmap.html +238 -68
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Metadata-Transforms.html +421 -221
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Modes.html +340 -78
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Multi-File-Documents.html +251 -86
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Multi-Format-Images.html +1362 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Pandoc-Integration.html +277 -90
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Plugins.html +673 -346
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Quarto-Mode.html +1405 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Rendering-Markdown-In-Terminal.html +1902 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Syntax.html +1939 -1698
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Tables.html +1781 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Troubleshooting.html +315 -140
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Usage.html +307 -113
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Using-Apex-with-Jekyll.html +1132 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Writing-Tests.html +1754 -0
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Xcode-Integration.html +872 -376
- 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/html/apex-app-docs.html +8746 -0
- data/ext/apex_ext/apex_src/documentation/shared_styles.css +20 -15
- data/ext/apex_ext/apex_src/documentation/transform_for_app.md +55 -0
- data/ext/apex_ext/apex_src/escaping-repro.md +103 -0
- data/ext/apex_ext/apex_src/examples/quick-actions/Markdown to RTF.workflow/Contents/Info.plist +8 -0
- data/ext/apex_ext/apex_src/examples/quick-actions/Markdown to RTF.workflow/Contents/QuickLook/Preview.png +0 -0
- data/ext/apex_ext/apex_src/examples/quick-actions/Markdown to RTF.workflow/Contents/document.wflow +547 -0
- data/ext/apex_ext/apex_src/examples/quick-actions/Markdown-to-RTF.workflow.zip +0 -0
- data/ext/apex_ext/apex_src/examples/quick-actions/README.md +33 -0
- data/ext/apex_ext/apex_src/include/apex/apex.h +92 -6
- data/ext/apex_ext/apex_src/include/apex/ast_rtf.h +23 -0
- data/ext/apex_ext/apex_src/include/apex/ast_terminal.h +6 -0
- data/ext/apex_ext/apex_src/include/apex/module.modulemap +5 -0
- data/ext/apex_ext/apex_src/include/apex/plugins.h +105 -0
- data/ext/apex_ext/apex_src/include/apexc.h +1 -0
- data/ext/apex_ext/apex_src/man/apex.1 +82 -78
- data/ext/apex_ext/apex_src/man/apex.1.md +81 -4
- data/ext/apex_ext/apex_src/objc/Apex.swift +73 -0
- data/ext/apex_ext/apex_src/objc/ApexPlugins.swift +79 -0
- data/ext/apex_ext/apex_src/objc/NSString+Apex.h +83 -5
- data/ext/apex_ext/apex_src/objc/NSString+Apex.m +244 -1
- data/ext/apex_ext/apex_src/objc/NSString+ApexPlugins.h +76 -0
- data/ext/apex_ext/apex_src/objc/NSString+ApexPlugins.m +169 -0
- data/ext/apex_ext/apex_src/output.html +87 -0
- data/ext/apex_ext/apex_src/plans/quarto-mode.md +442 -0
- data/ext/apex_ext/apex_src/src/_README.md +85 -32
- data/ext/apex_ext/apex_src/src/apex.c +770 -200
- data/ext/apex_ext/apex_src/src/ast_rtf.c +848 -0
- data/ext/apex_ext/apex_src/src/ast_terminal.c +184 -7
- data/ext/apex_ext/apex_src/src/extensions/abbreviations.c +10 -3
- data/ext/apex_ext/apex_src/src/extensions/advanced_tables.c +7 -11
- data/ext/apex_ext/apex_src/src/extensions/bear_image_attrs.c +467 -0
- data/ext/apex_ext/apex_src/src/extensions/bear_image_attrs.h +27 -0
- data/ext/apex_ext/apex_src/src/extensions/callouts.c +400 -4
- data/ext/apex_ext/apex_src/src/extensions/callouts.h +15 -5
- data/ext/apex_ext/apex_src/src/extensions/citations.c +26 -5
- data/ext/apex_ext/apex_src/src/extensions/code_fence_attrs.c +632 -0
- data/ext/apex_ext/apex_src/src/extensions/code_fence_attrs.h +22 -0
- data/ext/apex_ext/apex_src/src/extensions/concordance.c +632 -0
- data/ext/apex_ext/apex_src/src/extensions/definition_list.c +129 -15
- data/ext/apex_ext/apex_src/src/extensions/grid_tables.c +1050 -121
- data/ext/apex_ext/apex_src/src/extensions/html_markdown.c +569 -16
- data/ext/apex_ext/apex_src/src/extensions/ial.c +502 -52
- data/ext/apex_ext/apex_src/src/extensions/ial.h +2 -1
- data/ext/apex_ext/apex_src/src/extensions/includes.c +532 -33
- data/ext/apex_ext/apex_src/src/extensions/includes.h +7 -1
- data/ext/apex_ext/apex_src/src/extensions/index.c +1427 -140
- data/ext/apex_ext/apex_src/src/extensions/index.h +28 -0
- data/ext/apex_ext/apex_src/src/extensions/metadata.c +200 -161
- data/ext/apex_ext/apex_src/src/extensions/quarto_diagrams.c +251 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_diagrams.h +22 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_lists.c +624 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_lists.h +35 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_polish.c +264 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_polish.h +23 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_shortcodes.c +307 -0
- data/ext/apex_ext/apex_src/src/extensions/quarto_shortcodes.h +21 -0
- data/ext/apex_ext/apex_src/src/extensions/raw_content.c +351 -0
- data/ext/apex_ext/apex_src/src/extensions/raw_content.h +20 -0
- data/ext/apex_ext/apex_src/src/extensions/relaxed_tables.c +117 -3
- data/ext/apex_ext/apex_src/src/extensions/special_markers.c +53 -0
- data/ext/apex_ext/apex_src/src/extensions/syntax_highlight.c +23 -1
- data/ext/apex_ext/apex_src/src/extensions/table_html_postprocess.c +83 -92
- data/ext/apex_ext/apex_src/src/extensions/toc.c +446 -25
- data/ext/apex_ext/apex_src/src/extensions/toc.h +26 -1
- data/ext/apex_ext/apex_src/src/extensions/wiki_links.c +28 -0
- data/ext/apex_ext/apex_src/src/html_renderer.c +387 -17
- data/ext/apex_ext/apex_src/src/plugin_catalog.c +517 -0
- data/ext/apex_ext/apex_src/src/plugins_remote.c +88 -14
- data/ext/apex_ext/apex_src/src/plugins_remote.h +34 -0
- data/ext/apex_ext/apex_src/src/pretty_html.c +6 -1
- data/ext/apex_ext/apex_src/tests/fixtures/comprehensive_test.md +21 -0
- data/ext/apex_ext/apex_src/tests/fixtures/images/bear_image_attributes.md +10 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/sections.md +19 -0
- data/ext/apex_ext/apex_src/tests/fixtures/includes/sections.txt +11 -0
- data/ext/apex_ext/apex_src/tests/fixtures/minimal_pb.md +2 -0
- data/ext/apex_ext/apex_src/tests/fixtures/obsidian-callouts.md +46 -0
- data/ext/apex_ext/apex_src/tests/fixtures/pagebreak_html_repro.md +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/python-callouts.md +47 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/callouts.md +3 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/code-attrs.md +3 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/diagrams.md +8 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/lists.md +19 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/raw-content.md +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/shortcodes.md +7 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/smoke.md +81 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto/spans.md +5 -0
- data/ext/apex_ext/apex_src/tests/fixtures/quarto-callouts.md +47 -0
- data/ext/apex_ext/apex_src/tests/fixtures/speed.md +192 -0
- data/ext/apex_ext/apex_src/tests/fixtures/tables/grid-tables.md +37 -0
- data/ext/apex_ext/apex_src/tests/paginate_cli_test.sh +16 -0
- data/ext/apex_ext/apex_src/tests/test_bear_image_attrs.c +301 -0
- data/ext/apex_ext/apex_src/tests/test_concordance.tsv +4 -0
- data/ext/apex_ext/apex_src/tests/test_escaping_repro.c +82 -0
- data/ext/apex_ext/apex_src/tests/test_extensions.c +821 -1
- data/ext/apex_ext/apex_src/tests/test_ial.c +7 -0
- data/ext/apex_ext/apex_src/tests/test_marked_integration.c +25 -0
- data/ext/apex_ext/apex_src/tests/test_metadata.c +129 -0
- data/ext/apex_ext/apex_src/tests/test_output.c +568 -2
- data/ext/apex_ext/apex_src/tests/test_runner.c +11 -0
- data/ext/apex_ext/apex_src/tests/test_tables.c +420 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/CMakeLists.txt +1 -1
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/autolink.c +77 -1
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.c +135 -5
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/blocks.c +56 -1
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/config.h +38 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/main.c +1 -1
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/__pycache__/cmark.cpython-314.pyc +0 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/__pycache__/normalize.cpython-314.pyc +0 -0
- data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions.txt +69 -0
- data/ext/apex_ext/apex_src/xcode_build/CMakeScripts/ReRunCMake.make +74 -0
- data/ext/apex_ext/apex_src/xcode_build/CTestTestfile.cmake +22 -0
- data/ext/apex_ext/apex_src/xcode_build/Debug/Apex.framework/Versions/A/Apex +0 -0
- data/ext/apex_ext/apex_src/xcode_build/Debug/Apex.framework/Versions/A/Resources/Info.plist +44 -0
- data/ext/apex_ext/apex_src/xcode_build/Debug/Apex.framework/Versions/A/_CodeSignature/CodeResources +128 -0
- data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.pbxproj +5118 -0
- data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.xcworkspace/xcuserdata/ttscoff.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.xcworkspace/xcuserdata/ttscoff.xcuserdatad/WorkspaceSettings.xcsettings +8 -0
- data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/xcuserdata/ttscoff.xcuserdatad/xcschemes/xcschememanagement.plist +99 -0
- data/ext/apex_ext/apex_src/xcode_build/cmake_install.cmake +452 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/CMakeScripts/ReRunCMake.make +52 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/cmake_install.cmake +55 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/cmark-gfm.xcodeproj/project.pbxproj +2455 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/cmark-gfm.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/extensions/cmake_install.cmake +171 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/man/cmake_install.cmake +55 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/cmake_install.cmake +220 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/cmark-gfm_export.h +43 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/cmark-gfm_version.h +7 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/config.h +76 -0
- data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/libcmark-gfm.pc +10 -0
- data/ext/apex_ext/extconf.rb +35 -0
- data/lib/apex/version.rb +2 -2
- metadata +117 -2
- data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/tempOptimizedIndex.dsidx +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 23ce0573c0b136df9588e5c233689ca99950a98082d8eadf9f3a1590179db147
|
|
4
|
+
data.tar.gz: f76c392a039d0d6500fd2db9dd0bda0f0bef7baad3a0cd4b8cc214e333578590
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7e1c59e9226e7f570f163a4a73c5e4945bb6cc054eba569ddd449f65f8ab7ad0d537daed69e7118ec6997e37afa46886e675af48b7a312bf5184513157edf08
|
|
7
|
+
data.tar.gz: 390948ff201cb6fe79027332ab3228d4d42031541423b0c6bb2d69823dffbed54d7578b94596046b013c30db117c8577932da44a89a3a6b08739fb9cf7057b99
|
data/README.md
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Ruby bindings for the [Apex](https://github.com/ApexMarkdown/apex) unified Markdown processor.
|
|
4
4
|
|
|
5
5
|
Apex is a C library that supports CommonMark, GFM, MultiMarkdown, Kramdown, and a number of
|
|
6
|
-
Marked-specific extensions. This gem vendors the Apex sources
|
|
7
|
-
Ruby API for converting Markdown to HTML.
|
|
6
|
+
Marked-specific extensions. This gem vendors the Apex sources (currently the **1.1.x** library)
|
|
7
|
+
and exposes a small, kramdown-style Ruby API for converting Markdown to HTML.
|
|
8
|
+
|
|
9
|
+
Query the underlying C library version with `Apex::Native.version`.
|
|
8
10
|
|
|
9
11
|
## Requirements
|
|
10
12
|
|
|
@@ -58,11 +60,20 @@ html = Apex::Document.markdown_to_html(text, mode: :gfm) # or :github
|
|
|
58
60
|
html = Apex::Document.markdown_to_html(text, mode: :multimarkdown) # or :mmd
|
|
59
61
|
html = Apex::Document.markdown_to_html(text, mode: :commonmark) # or :cmark
|
|
60
62
|
html = Apex::Document.markdown_to_html(text, mode: :kramdown)
|
|
63
|
+
html = Apex::Document.markdown_to_html(text, mode: :quarto)
|
|
61
64
|
```
|
|
62
65
|
|
|
66
|
+
Mode selection uses `apex_options_for_mode`, so unified/MMD/kramdown defaults match the CLI (including YAML front-matter extraction). Document front matter is applied to options; explicit keyword arguments override front matter.
|
|
67
|
+
|
|
68
|
+
### Metadata / YAML front matter
|
|
69
|
+
|
|
70
|
+
In `:unified`, `:multimarkdown`, and `:kramdown`, YAML/MMD/Pandoc metadata at the top of the document is **extracted and removed** from the Markdown before rendering (so it does not appear as an `<hr>` plus leftover text). In `:gfm` and `:commonmark`, front matter is left in the document and typically renders as a horizontal rule.
|
|
71
|
+
|
|
72
|
+
There is no separate `enable_metadata` flag. `strip_metadata` is accepted for compatibility but is unused by the C library; stripping is controlled by mode as above.
|
|
73
|
+
|
|
63
74
|
### Options
|
|
64
75
|
|
|
65
|
-
Any additional keyword arguments are mapped
|
|
76
|
+
Any additional keyword arguments are mapped to the underlying `apex_options` struct
|
|
66
77
|
defined in `apex.h`. For example:
|
|
67
78
|
|
|
68
79
|
```ruby
|
|
@@ -73,6 +84,9 @@ html = Apex::Document.markdown_to_html(
|
|
|
73
84
|
enable_footnotes: true,
|
|
74
85
|
generate_header_ids: true,
|
|
75
86
|
relaxed_tables: true,
|
|
87
|
+
enable_indices: true,
|
|
88
|
+
concordance: "terms.tsv", # or concordance_files: ["a.tsv", "b.tsv"]
|
|
89
|
+
bibliography: "refs.bib", # or bibliography_files: [...]
|
|
76
90
|
wikilink_extension: "html"
|
|
77
91
|
)
|
|
78
92
|
```
|
data/ext/apex_ext/apex_ext.c
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#include "ruby.h"
|
|
2
2
|
#include "apex/apex.h"
|
|
3
|
+
#include "extensions/metadata.h"
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
#include <string.h>
|
|
3
6
|
#include <strings.h>
|
|
4
7
|
|
|
5
8
|
static VALUE mApex;
|
|
@@ -24,43 +27,42 @@ mode_from_ruby(VALUE mode_val)
|
|
|
24
27
|
return APEX_MODE_KRAMDOWN;
|
|
25
28
|
if (!strcasecmp(cstr, "unified"))
|
|
26
29
|
return APEX_MODE_UNIFIED;
|
|
30
|
+
if (!strcasecmp(cstr, "quarto"))
|
|
31
|
+
return APEX_MODE_QUARTO;
|
|
27
32
|
|
|
28
33
|
return APEX_MODE_UNIFIED;
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
static
|
|
32
|
-
|
|
36
|
+
static int
|
|
37
|
+
hash_has_key(VALUE h, const char *key)
|
|
33
38
|
{
|
|
34
39
|
ID id = rb_intern(key);
|
|
35
40
|
VALUE k = ID2SYM(id);
|
|
36
41
|
VALUE v = rb_funcall(h, rb_intern("key?"), 1, k);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
return RTEST(v);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static void
|
|
46
|
+
set_bool(VALUE h, const char *key, bool *field)
|
|
47
|
+
{
|
|
48
|
+
if (!hash_has_key(h, key)) return;
|
|
49
|
+
VALUE val = rb_hash_aref(h, ID2SYM(rb_intern(key)));
|
|
50
|
+
*field = RTEST(val);
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
static void
|
|
44
54
|
set_int(VALUE h, const char *key, int *field)
|
|
45
55
|
{
|
|
46
|
-
|
|
47
|
-
VALUE
|
|
48
|
-
|
|
49
|
-
if (RTEST(v)) {
|
|
50
|
-
VALUE val = rb_hash_aref(h, k);
|
|
51
|
-
if (!NIL_P(val)) *field = NUM2INT(val);
|
|
52
|
-
}
|
|
56
|
+
if (!hash_has_key(h, key)) return;
|
|
57
|
+
VALUE val = rb_hash_aref(h, ID2SYM(rb_intern(key)));
|
|
58
|
+
if (!NIL_P(val)) *field = NUM2INT(val);
|
|
53
59
|
}
|
|
54
60
|
|
|
55
61
|
static void
|
|
56
62
|
set_cstr(VALUE h, const char *key, const char **field)
|
|
57
63
|
{
|
|
58
|
-
|
|
59
|
-
VALUE
|
|
60
|
-
VALUE v = rb_funcall(h, rb_intern("key?"), 1, k);
|
|
61
|
-
if (!RTEST(v)) return;
|
|
62
|
-
|
|
63
|
-
VALUE val = rb_hash_aref(h, k);
|
|
64
|
+
if (!hash_has_key(h, key)) return;
|
|
65
|
+
VALUE val = rb_hash_aref(h, ID2SYM(rb_intern(key)));
|
|
64
66
|
if (NIL_P(val)) {
|
|
65
67
|
*field = NULL;
|
|
66
68
|
} else {
|
|
@@ -69,114 +71,254 @@ set_cstr(VALUE h, const char *key, const char **field)
|
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
/* Build
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
/* Build a NULL-terminated strdup'd C string array from a Ruby Array or String.
|
|
75
|
+
* Caller must free with free_cstr_array(). */
|
|
76
|
+
static char **
|
|
77
|
+
cstr_array_from_ruby(VALUE h, const char *key)
|
|
75
78
|
{
|
|
76
|
-
|
|
79
|
+
if (!hash_has_key(h, key)) return NULL;
|
|
80
|
+
|
|
81
|
+
VALUE val = rb_hash_aref(h, ID2SYM(rb_intern(key)));
|
|
82
|
+
if (NIL_P(val)) return NULL;
|
|
83
|
+
|
|
84
|
+
if (TYPE(val) == T_STRING) {
|
|
85
|
+
char **arr = malloc(2 * sizeof(char *));
|
|
86
|
+
if (!arr) return NULL;
|
|
87
|
+
arr[0] = strdup(StringValueCStr(val));
|
|
88
|
+
arr[1] = NULL;
|
|
89
|
+
if (!arr[0]) { free(arr); return NULL; }
|
|
90
|
+
return arr;
|
|
91
|
+
}
|
|
77
92
|
|
|
78
|
-
if (
|
|
93
|
+
if (TYPE(val) != T_ARRAY) return NULL;
|
|
94
|
+
|
|
95
|
+
long n = RARRAY_LEN(val);
|
|
96
|
+
char **arr = malloc((size_t)(n + 1) * sizeof(char *));
|
|
97
|
+
if (!arr) return NULL;
|
|
98
|
+
|
|
99
|
+
long count = 0;
|
|
100
|
+
for (long i = 0; i < n; i++) {
|
|
101
|
+
VALUE item = rb_ary_entry(val, i);
|
|
102
|
+
if (NIL_P(item)) continue;
|
|
103
|
+
item = StringValue(item);
|
|
104
|
+
arr[count] = strdup(StringValueCStr(item));
|
|
105
|
+
if (!arr[count]) {
|
|
106
|
+
for (long j = 0; j < count; j++) free(arr[j]);
|
|
107
|
+
free(arr);
|
|
108
|
+
return NULL;
|
|
109
|
+
}
|
|
110
|
+
count++;
|
|
111
|
+
}
|
|
112
|
+
arr[count] = NULL;
|
|
113
|
+
if (count == 0) { free(arr); return NULL; }
|
|
114
|
+
return arr;
|
|
115
|
+
}
|
|
79
116
|
|
|
80
|
-
|
|
81
|
-
|
|
117
|
+
static void
|
|
118
|
+
free_cstr_array(char **arr)
|
|
119
|
+
{
|
|
120
|
+
if (!arr) return;
|
|
121
|
+
for (size_t i = 0; arr[i]; i++) free(arr[i]);
|
|
122
|
+
free(arr);
|
|
123
|
+
}
|
|
82
124
|
|
|
125
|
+
/* Apply kwargs that override mode defaults / document metadata. */
|
|
126
|
+
static void
|
|
127
|
+
apply_kwargs(VALUE h, apex_options *o, char ***bib_out, char ***conc_out)
|
|
128
|
+
{
|
|
83
129
|
/* Feature flags */
|
|
84
|
-
set_bool(h, "enable_plugins", &o
|
|
85
|
-
set_bool(h, "enable_tables", &o
|
|
86
|
-
set_bool(h, "enable_footnotes", &o
|
|
87
|
-
set_bool(h, "enable_definition_lists", &o
|
|
88
|
-
set_bool(h, "enable_smart_typography", &o
|
|
89
|
-
set_bool(h, "enable_math", &o
|
|
90
|
-
set_bool(h, "
|
|
91
|
-
set_bool(h, "
|
|
92
|
-
set_bool(h, "
|
|
93
|
-
set_bool(h, "
|
|
94
|
-
set_bool(h, "
|
|
95
|
-
set_bool(h, "
|
|
130
|
+
set_bool(h, "enable_plugins", &o->enable_plugins);
|
|
131
|
+
set_bool(h, "enable_tables", &o->enable_tables);
|
|
132
|
+
set_bool(h, "enable_footnotes", &o->enable_footnotes);
|
|
133
|
+
set_bool(h, "enable_definition_lists", &o->enable_definition_lists);
|
|
134
|
+
set_bool(h, "enable_smart_typography", &o->enable_smart_typography);
|
|
135
|
+
set_bool(h, "enable_math", &o->enable_math);
|
|
136
|
+
set_bool(h, "enable_critic_markup", &o->enable_critic_markup);
|
|
137
|
+
set_bool(h, "enable_wiki_links", &o->enable_wiki_links);
|
|
138
|
+
set_bool(h, "enable_task_lists", &o->enable_task_lists);
|
|
139
|
+
set_bool(h, "enable_attributes", &o->enable_attributes);
|
|
140
|
+
set_bool(h, "enable_callouts", &o->enable_callouts);
|
|
141
|
+
set_bool(h, "enable_py_callouts", &o->enable_py_callouts);
|
|
142
|
+
set_bool(h, "enable_quarto_callouts", &o->enable_quarto_callouts);
|
|
143
|
+
set_bool(h, "enable_marked_extensions", &o->enable_marked_extensions);
|
|
144
|
+
set_bool(h, "enable_divs", &o->enable_divs);
|
|
145
|
+
set_bool(h, "enable_spans", &o->enable_spans);
|
|
146
|
+
set_bool(h, "enable_grid_tables", &o->enable_grid_tables);
|
|
147
|
+
|
|
148
|
+
set_int(h, "critic_mode", &o->critic_mode);
|
|
96
149
|
|
|
97
150
|
/* Metadata handling */
|
|
98
|
-
set_bool(h, "strip_metadata", &o
|
|
99
|
-
set_bool(h, "enable_metadata_variables", &o
|
|
100
|
-
set_bool(h, "enable_metadata_transforms",&o
|
|
151
|
+
set_bool(h, "strip_metadata", &o->strip_metadata);
|
|
152
|
+
set_bool(h, "enable_metadata_variables", &o->enable_metadata_variables);
|
|
153
|
+
set_bool(h, "enable_metadata_transforms",&o->enable_metadata_transforms);
|
|
101
154
|
|
|
102
155
|
/* File inclusion */
|
|
103
|
-
set_bool(h, "enable_file_includes", &o
|
|
104
|
-
set_int (h, "max_include_depth", &o
|
|
105
|
-
set_cstr(h, "base_directory", &o
|
|
156
|
+
set_bool(h, "enable_file_includes", &o->enable_file_includes);
|
|
157
|
+
set_int (h, "max_include_depth", &o->max_include_depth);
|
|
158
|
+
set_cstr(h, "base_directory", &o->base_directory);
|
|
106
159
|
|
|
107
160
|
/* Output options */
|
|
108
|
-
set_bool(h, "unsafe", &o
|
|
109
|
-
set_bool(h, "validate_utf8", &o
|
|
110
|
-
set_bool(h, "github_pre_lang", &o
|
|
111
|
-
set_bool(h, "standalone", &o
|
|
112
|
-
set_bool(h, "pretty", &o
|
|
113
|
-
set_bool(h, "xhtml", &o
|
|
114
|
-
set_bool(h, "strict_xhtml", &o
|
|
115
|
-
set_cstr(h, "document_title", &o
|
|
161
|
+
set_bool(h, "unsafe", &o->unsafe);
|
|
162
|
+
set_bool(h, "validate_utf8", &o->validate_utf8);
|
|
163
|
+
set_bool(h, "github_pre_lang", &o->github_pre_lang);
|
|
164
|
+
set_bool(h, "standalone", &o->standalone);
|
|
165
|
+
set_bool(h, "pretty", &o->pretty);
|
|
166
|
+
set_bool(h, "xhtml", &o->xhtml);
|
|
167
|
+
set_bool(h, "strict_xhtml", &o->strict_xhtml);
|
|
168
|
+
set_cstr(h, "document_title", &o->document_title);
|
|
116
169
|
|
|
117
170
|
/* Line break handling */
|
|
118
|
-
set_bool(h, "hardbreaks", &o
|
|
119
|
-
set_bool(h, "nobreaks", &o
|
|
171
|
+
set_bool(h, "hardbreaks", &o->hardbreaks);
|
|
172
|
+
set_bool(h, "nobreaks", &o->nobreaks);
|
|
120
173
|
|
|
121
174
|
/* Header ID generation */
|
|
122
|
-
set_bool(h, "generate_header_ids", &o
|
|
123
|
-
set_bool(h, "header_anchors", &o
|
|
124
|
-
set_int (h, "id_format", &o
|
|
175
|
+
set_bool(h, "generate_header_ids", &o->generate_header_ids);
|
|
176
|
+
set_bool(h, "header_anchors", &o->header_anchors);
|
|
177
|
+
set_int (h, "id_format", &o->id_format);
|
|
178
|
+
set_int (h, "toc_min", &o->toc_min);
|
|
179
|
+
set_int (h, "toc_max", &o->toc_max);
|
|
125
180
|
|
|
126
181
|
/* Table options */
|
|
127
|
-
set_bool(h, "relaxed_tables", &o
|
|
128
|
-
set_int (h, "caption_position", &o
|
|
129
|
-
set_bool(h, "per_cell_alignment", &o
|
|
182
|
+
set_bool(h, "relaxed_tables", &o->relaxed_tables);
|
|
183
|
+
set_int (h, "caption_position", &o->caption_position);
|
|
184
|
+
set_bool(h, "per_cell_alignment", &o->per_cell_alignment);
|
|
130
185
|
|
|
131
186
|
/* List options */
|
|
132
|
-
set_bool(h, "allow_mixed_list_markers", &o
|
|
133
|
-
set_bool(h, "allow_alpha_lists", &o
|
|
187
|
+
set_bool(h, "allow_mixed_list_markers", &o->allow_mixed_list_markers);
|
|
188
|
+
set_bool(h, "allow_alpha_lists", &o->allow_alpha_lists);
|
|
134
189
|
|
|
135
190
|
/* Superscript and subscript */
|
|
136
|
-
set_bool(h, "enable_sup_sub", &o
|
|
191
|
+
set_bool(h, "enable_sup_sub", &o->enable_sup_sub);
|
|
137
192
|
|
|
138
193
|
/* Strikethrough */
|
|
139
|
-
set_bool(h, "enable_strikethrough",&o
|
|
194
|
+
set_bool(h, "enable_strikethrough",&o->enable_strikethrough);
|
|
140
195
|
|
|
141
196
|
/* Autolink options */
|
|
142
|
-
set_bool(h, "enable_autolink", &o
|
|
143
|
-
set_bool(h, "obfuscate_emails", &o
|
|
197
|
+
set_bool(h, "enable_autolink", &o->enable_autolink);
|
|
198
|
+
set_bool(h, "obfuscate_emails", &o->obfuscate_emails);
|
|
144
199
|
|
|
145
200
|
/* Image options */
|
|
146
|
-
set_bool(h, "
|
|
147
|
-
set_bool(h, "
|
|
201
|
+
set_bool(h, "embed_images", &o->embed_images);
|
|
202
|
+
set_bool(h, "enable_image_captions", &o->enable_image_captions);
|
|
203
|
+
set_bool(h, "title_captions_only", &o->title_captions_only);
|
|
204
|
+
|
|
205
|
+
/* Citations */
|
|
206
|
+
set_bool(h, "enable_citations", &o->enable_citations);
|
|
207
|
+
set_cstr(h, "csl_file", &o->csl_file);
|
|
208
|
+
set_bool(h, "suppress_bibliography", &o->suppress_bibliography);
|
|
209
|
+
set_bool(h, "link_citations", &o->link_citations);
|
|
210
|
+
set_bool(h, "show_tooltips", &o->show_tooltips);
|
|
211
|
+
set_cstr(h, "nocite", &o->nocite);
|
|
212
|
+
|
|
213
|
+
char **bib = cstr_array_from_ruby(h, "bibliography_files");
|
|
214
|
+
if (!bib) bib = cstr_array_from_ruby(h, "bibliography");
|
|
215
|
+
if (bib) {
|
|
216
|
+
*bib_out = bib;
|
|
217
|
+
o->bibliography_files = bib;
|
|
218
|
+
o->enable_citations = true;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Indices / TextIndex / concordance */
|
|
222
|
+
set_bool(h, "enable_indices", &o->enable_indices);
|
|
223
|
+
set_bool(h, "enable_mmark_index_syntax", &o->enable_mmark_index_syntax);
|
|
224
|
+
set_bool(h, "enable_textindex_syntax", &o->enable_textindex_syntax);
|
|
225
|
+
set_bool(h, "enable_leanpub_index_syntax", &o->enable_leanpub_index_syntax);
|
|
226
|
+
set_bool(h, "suppress_index", &o->suppress_index);
|
|
227
|
+
set_bool(h, "group_index_by_letter", &o->group_index_by_letter);
|
|
228
|
+
|
|
229
|
+
char **conc = cstr_array_from_ruby(h, "concordance_files");
|
|
230
|
+
if (!conc) conc = cstr_array_from_ruby(h, "concordance");
|
|
231
|
+
if (conc) {
|
|
232
|
+
*conc_out = conc;
|
|
233
|
+
o->concordance_files = conc;
|
|
234
|
+
o->enable_indices = true;
|
|
235
|
+
o->enable_textindex_syntax = true;
|
|
236
|
+
}
|
|
148
237
|
|
|
149
238
|
/* Wiki link options */
|
|
150
|
-
set_int (h, "wikilink_space", &o
|
|
151
|
-
set_cstr(h, "wikilink_extension", &o
|
|
152
|
-
set_bool(h, "wikilink_sanitize", &o
|
|
239
|
+
set_int (h, "wikilink_space", &o->wikilink_space);
|
|
240
|
+
set_cstr(h, "wikilink_extension", &o->wikilink_extension);
|
|
241
|
+
set_bool(h, "wikilink_sanitize", &o->wikilink_sanitize);
|
|
242
|
+
|
|
243
|
+
/* Stylesheet */
|
|
244
|
+
set_bool(h, "embed_stylesheet", &o->embed_stylesheet);
|
|
153
245
|
|
|
154
246
|
/* ARIA accessibility options */
|
|
155
|
-
set_bool(h, "enable_aria", &o
|
|
247
|
+
set_bool(h, "enable_aria", &o->enable_aria);
|
|
156
248
|
|
|
157
249
|
/* Emoji options */
|
|
158
|
-
set_bool(h, "enable_emoji_autocorrect", &o
|
|
250
|
+
set_bool(h, "enable_emoji_autocorrect", &o->enable_emoji_autocorrect);
|
|
159
251
|
|
|
160
|
-
/* Terminal output
|
|
161
|
-
set_bool(h, "terminal_inline_images", &o
|
|
162
|
-
set_int (h, "terminal_image_width", &o
|
|
252
|
+
/* Terminal output */
|
|
253
|
+
set_bool(h, "terminal_inline_images", &o->terminal_inline_images);
|
|
254
|
+
set_int (h, "terminal_image_width", &o->terminal_image_width);
|
|
255
|
+
set_bool(h, "paginate", &o->paginate);
|
|
256
|
+
set_bool(h, "paginate_symbols", &o->paginate_symbols);
|
|
257
|
+
set_cstr(h, "theme_name", &o->theme_name);
|
|
258
|
+
set_int (h, "terminal_width", &o->terminal_width);
|
|
163
259
|
|
|
164
260
|
/* Syntax highlighting options */
|
|
165
|
-
set_cstr(h, "code_highlighter", &o
|
|
166
|
-
set_bool(h, "code_line_numbers", &o
|
|
167
|
-
set_bool(h, "highlight_language_only", &o
|
|
261
|
+
set_cstr(h, "code_highlighter", &o->code_highlighter);
|
|
262
|
+
set_bool(h, "code_line_numbers", &o->code_line_numbers);
|
|
263
|
+
set_bool(h, "highlight_language_only", &o->highlight_language_only);
|
|
264
|
+
set_cstr(h, "code_highlight_theme", &o->code_highlight_theme);
|
|
168
265
|
|
|
169
266
|
/* Marked / integration-specific options */
|
|
170
|
-
set_bool(h, "enable_widont", &o
|
|
171
|
-
set_bool(h, "code_is_poetry", &o
|
|
172
|
-
set_bool(h, "enable_markdown_in_html", &o
|
|
173
|
-
set_bool(h, "random_footnote_ids", &o
|
|
174
|
-
set_bool(h, "enable_hashtags", &o
|
|
175
|
-
set_bool(h, "style_hashtags", &o
|
|
176
|
-
set_bool(h, "proofreader_mode", &o
|
|
177
|
-
set_bool(h, "hr_page_break", &o
|
|
178
|
-
set_bool(h, "title_from_h1", &o
|
|
179
|
-
set_bool(h, "page_break_before_footnotes", &o
|
|
267
|
+
set_bool(h, "enable_widont", &o->enable_widont);
|
|
268
|
+
set_bool(h, "code_is_poetry", &o->code_is_poetry);
|
|
269
|
+
set_bool(h, "enable_markdown_in_html", &o->enable_markdown_in_html);
|
|
270
|
+
set_bool(h, "random_footnote_ids", &o->random_footnote_ids);
|
|
271
|
+
set_bool(h, "enable_hashtags", &o->enable_hashtags);
|
|
272
|
+
set_bool(h, "style_hashtags", &o->style_hashtags);
|
|
273
|
+
set_bool(h, "proofreader_mode", &o->proofreader_mode);
|
|
274
|
+
set_bool(h, "hr_page_break", &o->hr_page_break);
|
|
275
|
+
set_bool(h, "title_from_h1", &o->title_from_h1);
|
|
276
|
+
set_bool(h, "page_break_before_footnotes", &o->page_break_before_footnotes);
|
|
277
|
+
|
|
278
|
+
set_cstr(h, "input_file_path", &o->input_file_path);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/*
|
|
282
|
+
* Build options:
|
|
283
|
+
* 1) mode defaults via apex_options_for_mode
|
|
284
|
+
* 2) document front matter applied to options (library parity with CLI)
|
|
285
|
+
* 3) explicit kwargs override front matter
|
|
286
|
+
*/
|
|
287
|
+
static apex_options
|
|
288
|
+
options_from_hash(VALUE h, const char *text, char ***bib_out, char ***conc_out,
|
|
289
|
+
apex_metadata_item **meta_out)
|
|
290
|
+
{
|
|
291
|
+
*bib_out = NULL;
|
|
292
|
+
*conc_out = NULL;
|
|
293
|
+
*meta_out = NULL;
|
|
294
|
+
|
|
295
|
+
apex_mode_t mode = APEX_MODE_UNIFIED;
|
|
296
|
+
if (!NIL_P(h) && TYPE(h) == T_HASH) {
|
|
297
|
+
VALUE mode_val = rb_hash_aref(h, ID2SYM(rb_intern("mode")));
|
|
298
|
+
mode = mode_from_ruby(mode_val);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
apex_options o = apex_options_for_mode(mode);
|
|
302
|
+
|
|
303
|
+
/* Apply document metadata before kwargs so explicit options win. */
|
|
304
|
+
if (text && (mode == APEX_MODE_MULTIMARKDOWN ||
|
|
305
|
+
mode == APEX_MODE_KRAMDOWN ||
|
|
306
|
+
apex_mode_is_unified_family(mode))) {
|
|
307
|
+
char *work = strdup(text);
|
|
308
|
+
if (work) {
|
|
309
|
+
char *ptr = work;
|
|
310
|
+
apex_metadata_item *meta = apex_extract_metadata_for_mode(&ptr, mode);
|
|
311
|
+
if (meta) {
|
|
312
|
+
apex_apply_metadata_to_options(meta, &o);
|
|
313
|
+
*meta_out = meta;
|
|
314
|
+
}
|
|
315
|
+
free(work);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
if (!NIL_P(h) && TYPE(h) == T_HASH) {
|
|
320
|
+
apply_kwargs(h, &o, bib_out, conc_out);
|
|
321
|
+
}
|
|
180
322
|
|
|
181
323
|
return o;
|
|
182
324
|
}
|
|
@@ -199,9 +341,23 @@ rb_apex_markdown_to_html(int argc, VALUE *argv, VALUE self)
|
|
|
199
341
|
const char *c_text = RSTRING_PTR(text);
|
|
200
342
|
size_t len = (size_t)RSTRING_LEN(text);
|
|
201
343
|
|
|
202
|
-
|
|
344
|
+
/* NUL-terminate for metadata extract helpers that expect C strings */
|
|
345
|
+
char *text_copy = malloc(len + 1);
|
|
346
|
+
if (!text_copy) return Qnil;
|
|
347
|
+
memcpy(text_copy, c_text, len);
|
|
348
|
+
text_copy[len] = '\0';
|
|
349
|
+
|
|
350
|
+
char **bib = NULL;
|
|
351
|
+
char **conc = NULL;
|
|
352
|
+
apex_metadata_item *meta = NULL;
|
|
353
|
+
apex_options opts = options_from_hash(opts_hash, text_copy, &bib, &conc, &meta);
|
|
203
354
|
|
|
204
355
|
char *out = apex_markdown_to_html(c_text, len, &opts);
|
|
356
|
+
free(text_copy);
|
|
357
|
+
free_cstr_array(bib);
|
|
358
|
+
free_cstr_array(conc);
|
|
359
|
+
if (meta) apex_free_metadata(meta);
|
|
360
|
+
|
|
205
361
|
if (!out) return Qnil;
|
|
206
362
|
|
|
207
363
|
VALUE rb_out = rb_utf8_str_new_cstr(out);
|
|
@@ -209,6 +365,18 @@ rb_apex_markdown_to_html(int argc, VALUE *argv, VALUE self)
|
|
|
209
365
|
return rb_out;
|
|
210
366
|
}
|
|
211
367
|
|
|
368
|
+
/*
|
|
369
|
+
* call-seq:
|
|
370
|
+
* Apex::Native.version -> String
|
|
371
|
+
*
|
|
372
|
+
* Underlying Apex C library version string.
|
|
373
|
+
*/
|
|
374
|
+
static VALUE
|
|
375
|
+
rb_apex_version(VALUE self)
|
|
376
|
+
{
|
|
377
|
+
return rb_utf8_str_new_cstr(APEX_VERSION_STRING);
|
|
378
|
+
}
|
|
379
|
+
|
|
212
380
|
void
|
|
213
381
|
Init_apex_ext(void)
|
|
214
382
|
{
|
|
@@ -217,5 +385,6 @@ Init_apex_ext(void)
|
|
|
217
385
|
|
|
218
386
|
rb_define_singleton_method(mApexNative, "markdown_to_html",
|
|
219
387
|
rb_apex_markdown_to_html, -1);
|
|
388
|
+
rb_define_singleton_method(mApexNative, "version",
|
|
389
|
+
rb_apex_version, 0);
|
|
220
390
|
}
|
|
221
|
-
|