apex-ruby 1.0.17 → 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.
Files changed (207) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -3
  3. data/ext/apex_ext/apex_ext.c +260 -91
  4. data/ext/apex_ext/apex_src/CHANGELOG.md +440 -0
  5. data/ext/apex_ext/apex_src/CMakeLists.txt +15 -1
  6. data/ext/apex_ext/apex_src/Formula/apex.rb +7 -2
  7. data/ext/apex_ext/apex_src/Package.swift +15 -4
  8. data/ext/apex_ext/apex_src/README.md +94 -35
  9. data/ext/apex_ext/apex_src/VERSION +1 -1
  10. data/ext/apex_ext/apex_src/apex-debug.log +4 -0
  11. data/ext/apex_ext/apex_src/apex.code-workspace +38 -0
  12. data/ext/apex_ext/apex_src/apex.taskpaper +12 -0
  13. data/ext/apex_ext/apex_src/apex_deflist_debug.log +25 -0
  14. data/ext/apex_ext/apex_src/buildnotes.md +1435 -0
  15. data/ext/apex_ext/apex_src/cli/main.c +262 -33
  16. data/ext/apex_ext/apex_src/debug.log +7 -0
  17. data/ext/apex_ext/apex_src/docs/CITATIONS_EXAMPLES.md +274 -0
  18. data/ext/apex_ext/apex_src/docs/CITATIONS_IMPLEMENTATION_PLAN.md +749 -0
  19. data/ext/apex_ext/apex_src/docs/CITATIONS_PLAN.md +744 -0
  20. data/ext/apex_ext/apex_src/docs/INDEX_IMPLEMENTATION_ANALYSIS.md +382 -0
  21. data/ext/apex_ext/apex_src/docs/plans/2025-02-27-man-page-output-implementation.md +351 -0
  22. data/ext/apex_ext/apex_src/docs/superpowers/plans/2026-07-12-toc-output-format.md +745 -0
  23. data/ext/apex_ext/apex_src/docs/superpowers/plans/2026-07-18-bear-image-attributes.md +829 -0
  24. data/ext/apex_ext/apex_src/docs/superpowers/plans/2026-07-19-apex-node-npm.md +1148 -0
  25. data/ext/apex_ext/apex_src/docs/superpowers/specs/2026-07-12-toc-output-format-design.md +161 -0
  26. data/ext/apex_ext/apex_src/docs/superpowers/specs/2026-07-18-bear-image-attributes-design.md +184 -0
  27. data/ext/apex_ext/apex_src/docs/superpowers/specs/2026-07-19-apex-node-npm-design.md +211 -0
  28. data/ext/apex_ext/apex_src/documentation/app-settings-table.md +67 -0
  29. data/ext/apex_ext/apex_src/documentation/app-transformed/Citations.md +340 -0
  30. data/ext/apex_ext/apex_src/documentation/app-transformed/Credits.md +11 -0
  31. data/ext/apex_ext/apex_src/documentation/app-transformed/Header-IDs.md +234 -0
  32. data/ext/apex_ext/apex_src/documentation/app-transformed/Inline-Attribute-Lists.md +516 -0
  33. data/ext/apex_ext/apex_src/documentation/app-transformed/Metadata-Transforms.md +461 -0
  34. data/ext/apex_ext/apex_src/documentation/app-transformed/Modes.md +193 -0
  35. data/ext/apex_ext/apex_src/documentation/app-transformed/Multi-File-Documents.md +201 -0
  36. data/ext/apex_ext/apex_src/documentation/app-transformed/Plugins.md +678 -0
  37. data/ext/apex_ext/apex_src/documentation/app-transformed/Syntax.md +1367 -0
  38. data/ext/apex_ext/apex_src/documentation/docsets/Apex Command Line Options.cheatsheet.txt +6 -0
  39. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/C-API.html +774 -300
  40. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Callouts.html +1194 -0
  41. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Citations.html +416 -216
  42. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Command-Line-Options.html +3544 -1094
  43. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Configuration.html +371 -97
  44. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Credits.html +153 -23
  45. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Examples.html +358 -124
  46. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Filters.html +1656 -0
  47. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Generating-Man-Pages.html +1226 -0
  48. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Getting-Started.html +201 -56
  49. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Header-IDs.html +279 -109
  50. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Home.html +200 -53
  51. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Indices.html +2327 -0
  52. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Inline-Attribute-Lists.html +690 -271
  53. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Installation.html +201 -55
  54. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Limitations-and-Roadmap.html +238 -68
  55. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Metadata-Transforms.html +421 -221
  56. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Modes.html +340 -78
  57. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Multi-File-Documents.html +251 -86
  58. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Multi-Format-Images.html +1362 -0
  59. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Pandoc-Integration.html +277 -90
  60. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Plugins.html +673 -346
  61. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Quarto-Mode.html +1405 -0
  62. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Rendering-Markdown-In-Terminal.html +1902 -0
  63. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Syntax.html +1939 -1698
  64. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Tables.html +1781 -0
  65. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Troubleshooting.html +315 -140
  66. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Usage.html +307 -113
  67. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Using-Apex-with-Jekyll.html +1132 -0
  68. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Writing-Tests.html +1754 -0
  69. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/Documents/Xcode-Integration.html +872 -376
  70. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/docSet.dsidx +0 -0
  71. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/optimizedIndex.dsidx +0 -0
  72. data/ext/apex_ext/apex_src/documentation/html/apex-app-docs.html +8746 -0
  73. data/ext/apex_ext/apex_src/documentation/shared_styles.css +20 -15
  74. data/ext/apex_ext/apex_src/documentation/transform_for_app.md +55 -0
  75. data/ext/apex_ext/apex_src/escaping-repro.md +103 -0
  76. data/ext/apex_ext/apex_src/examples/quick-actions/Markdown to RTF.workflow/Contents/Info.plist +8 -0
  77. data/ext/apex_ext/apex_src/examples/quick-actions/Markdown to RTF.workflow/Contents/QuickLook/Preview.png +0 -0
  78. data/ext/apex_ext/apex_src/examples/quick-actions/Markdown to RTF.workflow/Contents/document.wflow +547 -0
  79. data/ext/apex_ext/apex_src/examples/quick-actions/Markdown-to-RTF.workflow.zip +0 -0
  80. data/ext/apex_ext/apex_src/examples/quick-actions/README.md +33 -0
  81. data/ext/apex_ext/apex_src/include/apex/apex.h +92 -6
  82. data/ext/apex_ext/apex_src/include/apex/ast_rtf.h +23 -0
  83. data/ext/apex_ext/apex_src/include/apex/ast_terminal.h +6 -0
  84. data/ext/apex_ext/apex_src/include/apex/module.modulemap +5 -0
  85. data/ext/apex_ext/apex_src/include/apex/plugins.h +105 -0
  86. data/ext/apex_ext/apex_src/include/apexc.h +1 -0
  87. data/ext/apex_ext/apex_src/man/apex.1 +82 -78
  88. data/ext/apex_ext/apex_src/man/apex.1.md +81 -4
  89. data/ext/apex_ext/apex_src/objc/Apex.swift +73 -0
  90. data/ext/apex_ext/apex_src/objc/ApexPlugins.swift +79 -0
  91. data/ext/apex_ext/apex_src/objc/NSString+Apex.h +83 -5
  92. data/ext/apex_ext/apex_src/objc/NSString+Apex.m +244 -1
  93. data/ext/apex_ext/apex_src/objc/NSString+ApexPlugins.h +76 -0
  94. data/ext/apex_ext/apex_src/objc/NSString+ApexPlugins.m +169 -0
  95. data/ext/apex_ext/apex_src/output.html +87 -0
  96. data/ext/apex_ext/apex_src/plans/quarto-mode.md +442 -0
  97. data/ext/apex_ext/apex_src/src/_README.md +85 -32
  98. data/ext/apex_ext/apex_src/src/apex.c +770 -200
  99. data/ext/apex_ext/apex_src/src/ast_rtf.c +848 -0
  100. data/ext/apex_ext/apex_src/src/ast_terminal.c +184 -7
  101. data/ext/apex_ext/apex_src/src/extensions/abbreviations.c +10 -3
  102. data/ext/apex_ext/apex_src/src/extensions/advanced_tables.c +7 -11
  103. data/ext/apex_ext/apex_src/src/extensions/bear_image_attrs.c +467 -0
  104. data/ext/apex_ext/apex_src/src/extensions/bear_image_attrs.h +27 -0
  105. data/ext/apex_ext/apex_src/src/extensions/callouts.c +400 -4
  106. data/ext/apex_ext/apex_src/src/extensions/callouts.h +15 -5
  107. data/ext/apex_ext/apex_src/src/extensions/citations.c +26 -5
  108. data/ext/apex_ext/apex_src/src/extensions/code_fence_attrs.c +632 -0
  109. data/ext/apex_ext/apex_src/src/extensions/code_fence_attrs.h +22 -0
  110. data/ext/apex_ext/apex_src/src/extensions/concordance.c +632 -0
  111. data/ext/apex_ext/apex_src/src/extensions/definition_list.c +129 -15
  112. data/ext/apex_ext/apex_src/src/extensions/grid_tables.c +1050 -121
  113. data/ext/apex_ext/apex_src/src/extensions/html_markdown.c +569 -16
  114. data/ext/apex_ext/apex_src/src/extensions/ial.c +502 -52
  115. data/ext/apex_ext/apex_src/src/extensions/ial.h +2 -1
  116. data/ext/apex_ext/apex_src/src/extensions/includes.c +532 -33
  117. data/ext/apex_ext/apex_src/src/extensions/includes.h +7 -1
  118. data/ext/apex_ext/apex_src/src/extensions/index.c +1427 -140
  119. data/ext/apex_ext/apex_src/src/extensions/index.h +28 -0
  120. data/ext/apex_ext/apex_src/src/extensions/metadata.c +200 -161
  121. data/ext/apex_ext/apex_src/src/extensions/quarto_diagrams.c +251 -0
  122. data/ext/apex_ext/apex_src/src/extensions/quarto_diagrams.h +22 -0
  123. data/ext/apex_ext/apex_src/src/extensions/quarto_lists.c +624 -0
  124. data/ext/apex_ext/apex_src/src/extensions/quarto_lists.h +35 -0
  125. data/ext/apex_ext/apex_src/src/extensions/quarto_polish.c +264 -0
  126. data/ext/apex_ext/apex_src/src/extensions/quarto_polish.h +23 -0
  127. data/ext/apex_ext/apex_src/src/extensions/quarto_shortcodes.c +307 -0
  128. data/ext/apex_ext/apex_src/src/extensions/quarto_shortcodes.h +21 -0
  129. data/ext/apex_ext/apex_src/src/extensions/raw_content.c +351 -0
  130. data/ext/apex_ext/apex_src/src/extensions/raw_content.h +20 -0
  131. data/ext/apex_ext/apex_src/src/extensions/relaxed_tables.c +117 -3
  132. data/ext/apex_ext/apex_src/src/extensions/special_markers.c +53 -0
  133. data/ext/apex_ext/apex_src/src/extensions/syntax_highlight.c +23 -1
  134. data/ext/apex_ext/apex_src/src/extensions/table_html_postprocess.c +83 -92
  135. data/ext/apex_ext/apex_src/src/extensions/toc.c +446 -25
  136. data/ext/apex_ext/apex_src/src/extensions/toc.h +26 -1
  137. data/ext/apex_ext/apex_src/src/extensions/wiki_links.c +28 -0
  138. data/ext/apex_ext/apex_src/src/html_renderer.c +387 -17
  139. data/ext/apex_ext/apex_src/src/plugin_catalog.c +517 -0
  140. data/ext/apex_ext/apex_src/src/plugins_remote.c +88 -14
  141. data/ext/apex_ext/apex_src/src/plugins_remote.h +34 -0
  142. data/ext/apex_ext/apex_src/src/pretty_html.c +6 -1
  143. data/ext/apex_ext/apex_src/tests/fixtures/comprehensive_test.md +21 -0
  144. data/ext/apex_ext/apex_src/tests/fixtures/images/bear_image_attributes.md +10 -0
  145. data/ext/apex_ext/apex_src/tests/fixtures/includes/sections.md +19 -0
  146. data/ext/apex_ext/apex_src/tests/fixtures/includes/sections.txt +11 -0
  147. data/ext/apex_ext/apex_src/tests/fixtures/minimal_pb.md +2 -0
  148. data/ext/apex_ext/apex_src/tests/fixtures/obsidian-callouts.md +46 -0
  149. data/ext/apex_ext/apex_src/tests/fixtures/pagebreak_html_repro.md +5 -0
  150. data/ext/apex_ext/apex_src/tests/fixtures/python-callouts.md +47 -0
  151. data/ext/apex_ext/apex_src/tests/fixtures/quarto/callouts.md +3 -0
  152. data/ext/apex_ext/apex_src/tests/fixtures/quarto/code-attrs.md +3 -0
  153. data/ext/apex_ext/apex_src/tests/fixtures/quarto/diagrams.md +8 -0
  154. data/ext/apex_ext/apex_src/tests/fixtures/quarto/lists.md +19 -0
  155. data/ext/apex_ext/apex_src/tests/fixtures/quarto/raw-content.md +5 -0
  156. data/ext/apex_ext/apex_src/tests/fixtures/quarto/shortcodes.md +7 -0
  157. data/ext/apex_ext/apex_src/tests/fixtures/quarto/smoke.md +81 -0
  158. data/ext/apex_ext/apex_src/tests/fixtures/quarto/spans.md +5 -0
  159. data/ext/apex_ext/apex_src/tests/fixtures/quarto-callouts.md +47 -0
  160. data/ext/apex_ext/apex_src/tests/fixtures/speed.md +192 -0
  161. data/ext/apex_ext/apex_src/tests/fixtures/tables/grid-tables.md +37 -0
  162. data/ext/apex_ext/apex_src/tests/paginate_cli_test.sh +16 -0
  163. data/ext/apex_ext/apex_src/tests/test_bear_image_attrs.c +301 -0
  164. data/ext/apex_ext/apex_src/tests/test_concordance.tsv +4 -0
  165. data/ext/apex_ext/apex_src/tests/test_escaping_repro.c +82 -0
  166. data/ext/apex_ext/apex_src/tests/test_extensions.c +821 -1
  167. data/ext/apex_ext/apex_src/tests/test_ial.c +7 -0
  168. data/ext/apex_ext/apex_src/tests/test_marked_integration.c +25 -0
  169. data/ext/apex_ext/apex_src/tests/test_metadata.c +129 -0
  170. data/ext/apex_ext/apex_src/tests/test_output.c +568 -2
  171. data/ext/apex_ext/apex_src/tests/test_runner.c +11 -0
  172. data/ext/apex_ext/apex_src/tests/test_tables.c +420 -0
  173. data/ext/apex_ext/apex_src/vendor/cmark-gfm/CMakeLists.txt +1 -1
  174. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/autolink.c +77 -1
  175. data/ext/apex_ext/apex_src/vendor/cmark-gfm/extensions/table.c +135 -5
  176. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/blocks.c +56 -1
  177. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/config.h +38 -0
  178. data/ext/apex_ext/apex_src/vendor/cmark-gfm/src/main.c +1 -1
  179. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/__pycache__/cmark.cpython-314.pyc +0 -0
  180. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/__pycache__/normalize.cpython-314.pyc +0 -0
  181. data/ext/apex_ext/apex_src/vendor/cmark-gfm/test/extensions.txt +69 -0
  182. data/ext/apex_ext/apex_src/xcode_build/CMakeScripts/ReRunCMake.make +74 -0
  183. data/ext/apex_ext/apex_src/xcode_build/CTestTestfile.cmake +22 -0
  184. data/ext/apex_ext/apex_src/xcode_build/Debug/Apex.framework/Versions/A/Apex +0 -0
  185. data/ext/apex_ext/apex_src/xcode_build/Debug/Apex.framework/Versions/A/Resources/Info.plist +44 -0
  186. data/ext/apex_ext/apex_src/xcode_build/Debug/Apex.framework/Versions/A/_CodeSignature/CodeResources +128 -0
  187. data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.pbxproj +5118 -0
  188. data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  189. data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.xcworkspace/xcuserdata/ttscoff.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  190. data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/project.xcworkspace/xcuserdata/ttscoff.xcuserdatad/WorkspaceSettings.xcsettings +8 -0
  191. data/ext/apex_ext/apex_src/xcode_build/apex.xcodeproj/xcuserdata/ttscoff.xcuserdatad/xcschemes/xcschememanagement.plist +99 -0
  192. data/ext/apex_ext/apex_src/xcode_build/cmake_install.cmake +452 -0
  193. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/CMakeScripts/ReRunCMake.make +52 -0
  194. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/cmake_install.cmake +55 -0
  195. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/cmark-gfm.xcodeproj/project.pbxproj +2455 -0
  196. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/cmark-gfm.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +8 -0
  197. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/extensions/cmake_install.cmake +171 -0
  198. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/man/cmake_install.cmake +55 -0
  199. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/cmake_install.cmake +220 -0
  200. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/cmark-gfm_export.h +43 -0
  201. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/cmark-gfm_version.h +7 -0
  202. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/config.h +76 -0
  203. data/ext/apex_ext/apex_src/xcode_build/vendor/cmark-gfm/src/libcmark-gfm.pc +10 -0
  204. data/ext/apex_ext/extconf.rb +35 -0
  205. data/lib/apex/version.rb +2 -2
  206. metadata +117 -2
  207. data/ext/apex_ext/apex_src/documentation/docsets/Apex.docset/Contents/Resources/tempOptimizedIndex.dsidx +0 -0
@@ -0,0 +1,382 @@
1
+ # Index Implementation Analysis
2
+
3
+ This document analyzes the implementation of index syntax
4
+ support in Apex, covering mmark syntax, TextIndex syntax,
5
+ and implementation considerations.
6
+
7
+ ## mmark Index Syntax
8
+
9
+ ### Syntax Overview
10
+
11
+ mmark uses parentheses-based syntax for index entries:
12
+
13
+ - **Standard index entry**: `(!item)` - Creates an index
14
+
15
+ entry for "item"
16
+
17
+ - **Sub-item entry**: `(!item, subitem)` - Creates a
18
+
19
+ sub-entry under "item"
20
+
21
+ - **Primary entry**: `(!!item, subitem)` - Marks an entry as
22
+
23
+ primary (bold in output)
24
+
25
+ - **Section-level index**: An index entry can apply to an
26
+
27
+ entire section by placing it as the first paragraph after
28
+ a section heading
29
+
30
+ ### Example Usage
31
+
32
+ ```markdown
33
+ # Test Document
34
+
35
+ This document contains protocols (!Protocol) and implementations (!Implementation).
36
+
37
+ ## HTTP
38
+
39
+ HTTP (!HTTP) is a protocol (!Protocol) used for web communication.
40
+
41
+ ### HTTP/1.1
42
+
43
+ HTTP/1.1 (!HTTP, HTTP/1.1) is a common version.
44
+
45
+ ### HTTP/2
46
+
47
+ HTTP/2 (!HTTP, HTTP/2) introduced multiplexing.
48
+
49
+ ## Security
50
+
51
+ Security (!Security) is important. We discuss encryption (!Encryption).
52
+
53
+ ### Encryption Methods
54
+
55
+ Symmetric encryption (!Encryption, Symmetric) uses the same key.
56
+
57
+ Asymmetric encryption (!Encryption, Asymmetric) uses different keys.
58
+
59
+ ## Primary Index Entry
60
+
61
+ This section discusses the primary topic (!!Primary Topic, Sub Topic).
62
+
63
+ ## Section-Level Index
64
+
65
+ (!Section Index Entry)
66
+
67
+ This entire section should be indexed as "Section Index Entry".
68
+
69
+ ```
70
+
71
+ ### mmark Output
72
+
73
+ When processed with `mmark -html`, the syntax generates:
74
+
75
+ **Inline markers**: Each index entry is converted to a `<span class="index" id="idxref:N"></span>` marker in the HTML
76
+
77
+ **Index section**: At the end of the document, mmark automatically generates an `<h1 id="index-section">Index</h1>` section with a structured index:
78
+
79
+ - Alphabetically organized by first letter
80
+ - Hierarchical structure for sub-items
81
+
82
+ Links back to document locations using `idxref:N` anchors
83
+
84
+ - Primary entries are marked (typically bold)
85
+
86
+ ### Implementation Notes
87
+
88
+ - The `-index=false` flag suppresses index generation
89
+ - Index entries are processed during inline parsing
90
+ - The index is generated as a post-processing step after the
91
+
92
+ document is parsed
93
+
94
+ ## TextIndex Syntax
95
+
96
+ ### Syntax Overview
97
+
98
+ TextIndex uses curly braces with a caret for index entries:
99
+
100
+ - **Basic syntax**: `{^}` - Marks the preceding word or
101
+
102
+ phrase for indexing
103
+
104
+ - **With explicit term**: `[term]{^}` - Indexes "term"
105
+
106
+ explicitly
107
+
108
+ - **With parameters**: `{^param1 param2}` - Supports various
109
+
110
+ parameters for sorting, cross-references, etc.
111
+
112
+ ### Example Usage
113
+
114
+ ```markdown
115
+ # Test Document
116
+
117
+ Most mechanical keyboard firmware{^} supports the use of [key combinations]{^}.
118
+
119
+ ## Protocols
120
+
121
+ HTTP{^} is a protocol{^} used for web communication.
122
+
123
+ ### HTTP/1.1
124
+
125
+ HTTP/1.1{^} is a common version of the protocol{^}.
126
+
127
+ ### HTTP/2
128
+
129
+ HTTP/2{^} introduced multiplexing.
130
+
131
+ ## Security
132
+
133
+ Security{^} is important. We discuss encryption{^} and authentication{^}.
134
+
135
+ ### Encryption Methods
136
+
137
+ Symmetric encryption{^} uses the same key for encryption and decryption.
138
+
139
+ Asymmetric encryption{^} uses different keys.
140
+
141
+ ```
142
+
143
+ ### TextIndex Features
144
+
145
+ From the Python implementation, TextIndex supports:
146
+
147
+ 1. **Concordance files**: External files that automatically
148
+
149
+ mark terms for indexing
150
+
151
+ 2. **Cross-references**: Link related terms within the index
152
+ 3. **Aliases**: Provide alternative terms or synonyms
153
+ 4. **Plural handling**: Manage singular and plural forms
154
+ 5. **Section mode**: Index entire sections
155
+ 6. **Sorting options**: Control how entries are sorted
156
+ 7. **Emphasis handling**: Mark entries with emphasis
157
+
158
+ ### TextIndex Pattern
159
+
160
+ The regex pattern used by TextIndex is:
161
+ ```regex
162
+ (?:(?<!\\)\[([^\]<>]+)(?<!\\)\]|([^\s\[\]\{\}<>]++))*(?<!>)\{\^([^\}<\n]*)\}(?!<)
163
+
164
+ ```
165
+
166
+ This matches:
167
+
168
+ - Optional `[term]` or a word/phrase
169
+ - Followed by `{^}` with optional parameters inside
170
+
171
+ ## Implementation Difficulty Assessment
172
+
173
+ ### Complexity: Medium
174
+
175
+ Implementing index support in Apex would be **moderately
176
+ complex**, similar to the citations extension but
177
+ potentially simpler in some ways.
178
+
179
+ ### Similar Existing Features
180
+
181
+ Apex already has several features that demonstrate similar
182
+ patterns:
183
+
184
+ 1. **Citations Extension** (`src/extensions/citations.c`):
185
+
186
+ Processes inline syntax patterns (`[@key]`, `[#key]`, etc.)
187
+
188
+ - Collects citations during parsing
189
+ - Generates bibliography at the end
190
+ - Similar two-phase approach: collect during parse,
191
+
192
+ generate during render
193
+
194
+ 2. **Table of Contents** (`src/extensions/toc.c`):
195
+ - Collects headers from AST
196
+ - Generates TOC HTML
197
+ - Inserts at `<!--TOC-->` markers or end of document
198
+ - Similar post-processing approach
199
+
200
+ 3. **Wiki Links** (`src/extensions/wiki_links.c`):
201
+ - Processes inline syntax `[[Page Name]]`
202
+ - Uses inline parser matching
203
+ - Converts to HTML links
204
+
205
+ ### Implementation Approach
206
+
207
+ #### Phase 1: Inline Parsing
208
+
209
+ 1. **Create index extension** (`src/extensions/index.c`):
210
+ - Register as inline syntax extension
211
+ - Match patterns:
212
+
213
+ mmark: `(!item)`, `(!item, subitem)`, `(!!item, subitem)`
214
+
215
+ - TextIndex: `{^}`, `[term]{^}`, `{^params}`
216
+
217
+ Store index entries in a registry (similar to citations)
218
+
219
+ 2. **Index entry structure**:
220
+ ```c
221
+ typedef struct apex_index_entry {
222
+ char *item; /* Main index term */
223
+ char *subitem; /* Sub-item (optional) */
224
+ bool primary; /* Primary entry flag (mmark) */
225
+ int position; /* Position in document */
226
+ char *anchor_id; /* Generated anchor ID */
227
+ struct apex_index_entry *next;
228
+ } apex_index_entry;
229
+
230
+ ```
231
+
232
+ 3. **Processing**:
233
+ - During inline parsing, detect index syntax
234
+ - Extract terms and parameters
235
+ - Create index entries
236
+ - Replace syntax with invisible markers or spans (like
237
+
238
+ mmark does)
239
+
240
+ #### Phase 2: Index Generation
241
+
242
+ 1. **Collect all entries** from the registry
243
+ 2. **Sort alphabetically** by item, then subitem
244
+ 3. **Group by first letter** (optional, like mmark)
245
+ 4. **Generate HTML**:
246
+ - Create hierarchical structure (items with sub-items)
247
+ - Link to document positions using anchor IDs
248
+ - Mark primary entries appropriately
249
+ 5. **Insert at end** or at `<!--INDEX-->` marker
250
+
251
+ ### Code Structure
252
+
253
+ ```
254
+ src/extensions/
255
+ index.c - Main implementation
256
+ index.h - Header with structures and functions
257
+
258
+ ```
259
+
260
+ Key functions needed:
261
+
262
+ - `create_index_extension()` - Register extension
263
+ - `apex_process_index_entries()` - Parse and collect entries
264
+ - `apex_generate_index_html()` - Generate index HTML
265
+ - `apex_insert_index()` - Insert index into document
266
+
267
+ ### Challenges
268
+
269
+ 1. **Syntax conflicts**:
270
+
271
+ `(!item)` could conflict with other parentheses-based syntax
272
+
273
+ - `{^}` could conflict with other brace syntax
274
+ - Need careful pattern matching to avoid false positives
275
+
276
+ 2. **Position tracking**:
277
+ - Need to track document positions for linking
278
+ - Similar to how citations track positions
279
+
280
+ 3. **Sorting and grouping**:
281
+ - Alphabetical sorting with proper handling of special
282
+
283
+ characters
284
+
285
+ - Grouping by first letter (optional feature)
286
+
287
+ 4. **Section-level indexing**:
288
+
289
+ Detecting when an index entry applies to an entire section
290
+
291
+ - Requires understanding of document structure
292
+
293
+ 5. **Dual syntax support**:
294
+ - Supporting both mmark and TextIndex syntax
295
+ - May need configuration option to choose syntax or
296
+
297
+ support both
298
+
299
+ ### Estimated Effort
300
+
301
+ - **Basic mmark syntax**: 2-3 days
302
+ - **TextIndex syntax**: 1-2 days additional
303
+ - **Section-level indexing**: 1 day
304
+ - **Testing and refinement**: 1-2 days
305
+
306
+ **Total**: ~5-8 days of development time
307
+
308
+ ## Other Markdown Flavors with Index Support
309
+
310
+ ### MultiMarkdown
311
+
312
+ MultiMarkdown has native support for index creation using
313
+ the same syntax as mmark:
314
+
315
+ - `(!item)` for standard entries
316
+ - `(!item, subitem)` for sub-entries
317
+ - `(!!item, subitem)` for primary entries
318
+
319
+ This makes sense since mmark is based on MultiMarkdown.
320
+
321
+ ### Pandoc
322
+
323
+ Pandoc does **not** have native index support, but:
324
+
325
+ - Supports extensive customization through filters
326
+ - Can implement indexing using Lua filters
327
+ - Requires additional scripting or external tools
328
+
329
+ ### Kramdown
330
+
331
+ Kramdown does **not** provide built-in support for indexes.
332
+ Users would need:
333
+
334
+ - Custom solutions
335
+ - External tools to generate indexes
336
+
337
+ ### Summary
338
+
339
+ Among major Markdown processors:
340
+
341
+ - **MultiMarkdown/mmark**: Native support with `(!item)`
342
+
343
+ syntax
344
+
345
+ - **Pandoc**: No native support, but extensible via filters
346
+ - **Kramdown**: No native support
347
+ - **TextIndex**: Standalone tool with `{^}` syntax
348
+
349
+ ## Recommendations
350
+
351
+ 1. **Start with mmark syntax**: It's more established and
352
+
353
+ similar to MultiMarkdown (which Apex already supports)
354
+
355
+ 2. **Add TextIndex syntax as optional**: Can be enabled via
356
+
357
+ flag or mode
358
+
359
+ 3. **Follow citations pattern**: Use similar architecture to
360
+
361
+ citations extension
362
+
363
+ **Make index generation optional**: Support `--no-index` flag (like mmark's `-index=false`)
364
+
365
+ 5. **Support index marker**: Allow `<!--INDEX-->` marker for
366
+
367
+ custom placement
368
+
369
+ 6. **Consider configuration options**:
370
+ - Alphabetical grouping (by first letter)
371
+ - Index placement (end vs. marker)
372
+ - Primary entry styling
373
+
374
+ ## Test Files
375
+
376
+ Test documents have been created:
377
+
378
+ - `test_index_mmark.md` - mmark syntax examples
379
+ - `test_index_textindex.md` - TextIndex syntax examples
380
+
381
+ These can be used for testing once implementation is
382
+ complete.