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.
- 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
|
@@ -0,0 +1,749 @@
|
|
|
1
|
+
# Apex Citations and Bibliography Implementation Plan
|
|
2
|
+
|
|
3
|
+
## Executive Summary
|
|
4
|
+
|
|
5
|
+
This document provides a comprehensive plan for implementing
|
|
6
|
+
citations and bibliographies in Apex, based on analysis of
|
|
7
|
+
how mmark, MultiMarkdown, and Pandoc handle citations. It
|
|
8
|
+
addresses key questions about bibliography formats, external
|
|
9
|
+
files, metadata integration, and syntax modes.
|
|
10
|
+
|
|
11
|
+
## Analysis of Existing Tools
|
|
12
|
+
|
|
13
|
+
### Pandoc Output Analysis
|
|
14
|
+
|
|
15
|
+
**Citation Format:**
|
|
16
|
+
|
|
17
|
+
Uses `<span class="citation" data-cites="key1 key2">(Formatted Citation)</span>`
|
|
18
|
+
|
|
19
|
+
Supports multiple citations in one span: `data-cites="doe99 smith2000 smith2004"`
|
|
20
|
+
|
|
21
|
+
- Author-date style: `(Doe 1999; Jane Smith 2000, 2004)`
|
|
22
|
+
- Author-in-text: `John Smith (2004)` (no parentheses)
|
|
23
|
+
- Author-suppressed: `(2004)` (no author name)
|
|
24
|
+
|
|
25
|
+
**Bibliography Format:**
|
|
26
|
+
|
|
27
|
+
Uses `<div id="refs" class="references csl-bib-body hanging-indent">`
|
|
28
|
+
|
|
29
|
+
- Each entry: `<div id="ref-key" class="csl-entry">`
|
|
30
|
+
- Formatted with CSL (Citation Style Language)
|
|
31
|
+
- Includes proper typography (em dashes, quotes, italics)
|
|
32
|
+
|
|
33
|
+
**Key Observations:**
|
|
34
|
+
|
|
35
|
+
Pandoc uses CSL (Citation Style Language) for all formatting
|
|
36
|
+
|
|
37
|
+
- Citations are processed through citeproc
|
|
38
|
+
- Bibliography is automatically generated from cited items
|
|
39
|
+
- Supports BibTeX, CSL JSON, and other formats as input
|
|
40
|
+
|
|
41
|
+
### mmark Output Analysis
|
|
42
|
+
|
|
43
|
+
**Citation Format:**
|
|
44
|
+
|
|
45
|
+
- Uses XML2RFC format: `<xref target="RFC2535"></xref>`
|
|
46
|
+
|
|
47
|
+
For HTML output, converts to simple links or formatted text
|
|
48
|
+
|
|
49
|
+
- Special handling for RFC/BCP/STD/I-D/W3C documents
|
|
50
|
+
- Auto-generates references for these document types
|
|
51
|
+
|
|
52
|
+
**Bibliography Format:**
|
|
53
|
+
|
|
54
|
+
- Requires `{backmatter}` marker to generate bibliography
|
|
55
|
+
- Uses XML2RFC `<reference>` elements
|
|
56
|
+
- Auto-fetches RFC/I-D metadata from citation index
|
|
57
|
+
|
|
58
|
+
**Key Observations:**
|
|
59
|
+
|
|
60
|
+
- mmark is specialized for RFC documents
|
|
61
|
+
- Uses external citation index for RFC/I-D metadata
|
|
62
|
+
- Bibliography only appears if `{backmatter}` is present
|
|
63
|
+
- Less flexible than Pandoc for general academic citations
|
|
64
|
+
|
|
65
|
+
### MultiMarkdown Output Analysis
|
|
66
|
+
|
|
67
|
+
**Citation Format:**
|
|
68
|
+
|
|
69
|
+
Uses numeric references: `<a href="#Doe:2006" id="Doe:2006:1">[1]</a>`
|
|
70
|
+
|
|
71
|
+
- Simple numbered citations
|
|
72
|
+
- Links to bibliography entries
|
|
73
|
+
|
|
74
|
+
**Bibliography Format:**
|
|
75
|
+
|
|
76
|
+
Uses `<div id="bibliography">` with entries like `<div id="Doe:2006">`
|
|
77
|
+
|
|
78
|
+
- Simple format, no CSL styling
|
|
79
|
+
- References defined inline or in separate section
|
|
80
|
+
|
|
81
|
+
**Key Observations:**
|
|
82
|
+
|
|
83
|
+
- Simpler than Pandoc
|
|
84
|
+
- No CSL support
|
|
85
|
+
- Numeric citations only
|
|
86
|
+
- Good for basic use cases
|
|
87
|
+
|
|
88
|
+
## Recommended Approach for Apex
|
|
89
|
+
|
|
90
|
+
### Bibliography Format: CSL JSON (Primary)
|
|
91
|
+
|
|
92
|
+
**Why CSL JSON?**
|
|
93
|
+
|
|
94
|
+
1. **Native Format**: CSL JSON is the native format for
|
|
95
|
+
|
|
96
|
+
citation processing
|
|
97
|
+
|
|
98
|
+
2. **Flexibility**: Supports all citation styles via CSL
|
|
99
|
+
|
|
100
|
+
stylesheets
|
|
101
|
+
|
|
102
|
+
**Standard**: Widely used (Pandoc, Zotero, Mendeley, etc.)
|
|
103
|
+
|
|
104
|
+
4. **Extensibility**: Easy to add new fields and entry types
|
|
105
|
+
5. **Processing**: Can be directly consumed by citeproc
|
|
106
|
+
|
|
107
|
+
processors
|
|
108
|
+
|
|
109
|
+
**Format Priority:**
|
|
110
|
+
|
|
111
|
+
1. **CSL JSON** (`.json`) - Primary format, native support
|
|
112
|
+
2. **BibTeX** (`.bib`) - Most common, convert to CSL JSON
|
|
113
|
+
|
|
114
|
+
internally
|
|
115
|
+
|
|
116
|
+
**CSL YAML** (`.yaml`) - Human-readable, convert to CSL JSON
|
|
117
|
+
|
|
118
|
+
4. **RIS** (`.ris`) - Lower priority, can add later
|
|
119
|
+
|
|
120
|
+
### Bibliography Storage: External Files (Recommended)
|
|
121
|
+
|
|
122
|
+
**Yes, external files should be supported** for the
|
|
123
|
+
following reasons:
|
|
124
|
+
|
|
125
|
+
1. **Reusability**: Same bibliography can be used across
|
|
126
|
+
|
|
127
|
+
multiple documents
|
|
128
|
+
|
|
129
|
+
2. **Management**: Reference managers (Zotero, Mendeley)
|
|
130
|
+
|
|
131
|
+
export to `.bib` or `.json`
|
|
132
|
+
|
|
133
|
+
3. **Standard Practice**: Pandoc, Quarto, and other tools
|
|
134
|
+
|
|
135
|
+
use external files
|
|
136
|
+
|
|
137
|
+
4. **Scalability**: Large bibliographies are easier to
|
|
138
|
+
|
|
139
|
+
manage in separate files
|
|
140
|
+
|
|
141
|
+
**Implementation Options:**
|
|
142
|
+
|
|
143
|
+
#### Option 1: External Files Only (Recommended)
|
|
144
|
+
- Specify via metadata: `bibliography: references.bib`
|
|
145
|
+
- Specify via CLI: `--bibliography references.bib`
|
|
146
|
+
|
|
147
|
+
Support multiple files: `bibliography: [refs1.bib, refs2.bib]`
|
|
148
|
+
|
|
149
|
+
- Auto-detect format from extension
|
|
150
|
+
|
|
151
|
+
#### Option 2: Hybrid (External + Inline)
|
|
152
|
+
- Support external files (primary)
|
|
153
|
+
- Support inline YAML `references:` field (for small
|
|
154
|
+
|
|
155
|
+
bibliographies)
|
|
156
|
+
|
|
157
|
+
- Support MultiMarkdown reference definitions (for
|
|
158
|
+
|
|
159
|
+
compatibility)
|
|
160
|
+
|
|
161
|
+
- Merge all sources (inline takes precedence)
|
|
162
|
+
|
|
163
|
+
**Recommendation**: Implement Option 2 (Hybrid) for maximum
|
|
164
|
+
flexibility.
|
|
165
|
+
|
|
166
|
+
### Metadata Integration
|
|
167
|
+
|
|
168
|
+
**YAML Front Matter:**
|
|
169
|
+
```yaml
|
|
170
|
+
---
|
|
171
|
+
bibliography: references.bib
|
|
172
|
+
# or multiple files:
|
|
173
|
+
bibliography:
|
|
174
|
+
- refs1.bib
|
|
175
|
+
- refs2.bib
|
|
176
|
+
|
|
177
|
+
csl: apa.csl # Citation style file
|
|
178
|
+
suppress-bibliography: false
|
|
179
|
+
link-citations: true
|
|
180
|
+
show-tooltips: false
|
|
181
|
+
nocite: |
|
|
182
|
+
@item1, @item2
|
|
183
|
+
# or include all:
|
|
184
|
+
nocite: '@*'
|
|
185
|
+
|
|
186
|
+
references: # Inline references (CSL JSON format)
|
|
187
|
+
- id: doe99
|
|
188
|
+
type: article-journal
|
|
189
|
+
author:
|
|
190
|
+
- family: Doe
|
|
191
|
+
given: John
|
|
192
|
+
issued:
|
|
193
|
+
date-parts: [[1999]]
|
|
194
|
+
title: Article Title
|
|
195
|
+
container-title: Journal Name
|
|
196
|
+
volume: 1
|
|
197
|
+
page: 1-10
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**MultiMarkdown Metadata:**
|
|
203
|
+
```
|
|
204
|
+
Bibliography: references.bib
|
|
205
|
+
CSL: apa.csl
|
|
206
|
+
Suppress Bibliography: false
|
|
207
|
+
Link Citations: true
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**Pandoc Title Block:**
|
|
212
|
+
```
|
|
213
|
+
% Bibliography: references.bib
|
|
214
|
+
% CSL: apa.csl
|
|
215
|
+
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### Command-Line Flags
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
# Single bibliography file
|
|
222
|
+
apex input.md --bibliography refs.bib
|
|
223
|
+
|
|
224
|
+
# Multiple bibliography files
|
|
225
|
+
apex input.md --bibliography refs1.bib --bibliography refs2.bib
|
|
226
|
+
|
|
227
|
+
# Citation style
|
|
228
|
+
apex input.md --bibliography refs.bib --csl apa.csl
|
|
229
|
+
|
|
230
|
+
# Suppress bibliography
|
|
231
|
+
apex input.md --bibliography refs.bib --no-bibliography
|
|
232
|
+
|
|
233
|
+
# Link citations to bibliography
|
|
234
|
+
apex input.md --bibliography refs.bib --link-citations
|
|
235
|
+
|
|
236
|
+
# Show tooltips on citations
|
|
237
|
+
apex input.md --bibliography refs.bib --show-tooltips
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Precedence Order:**
|
|
242
|
+
|
|
243
|
+
1. Command-line flags (highest priority)
|
|
244
|
+
2. Document metadata
|
|
245
|
+
3. Default values (lowest priority)
|
|
246
|
+
|
|
247
|
+
### Syntax Modes
|
|
248
|
+
|
|
249
|
+
#### Mode-Specific Behavior
|
|
250
|
+
|
|
251
|
+
**CommonMark Mode:**
|
|
252
|
+
|
|
253
|
+
- Citations: **Disabled** (pure CommonMark, no extensions)
|
|
254
|
+
- Syntax: None
|
|
255
|
+
|
|
256
|
+
**GFM Mode:**
|
|
257
|
+
|
|
258
|
+
- Citations: **Disabled** (GFM doesn't support citations)
|
|
259
|
+
- Syntax: None
|
|
260
|
+
|
|
261
|
+
**MultiMarkdown Mode:**
|
|
262
|
+
|
|
263
|
+
- Citations: **Enabled**
|
|
264
|
+
- Syntax: MultiMarkdown syntax only (`[#key]`)
|
|
265
|
+
- Bibliography: From reference definitions or external file
|
|
266
|
+
- Output: Numeric citations (like MultiMarkdown)
|
|
267
|
+
|
|
268
|
+
**Kramdown Mode:**
|
|
269
|
+
|
|
270
|
+
- Citations: **Disabled** (Kramdown uses different citation
|
|
271
|
+
|
|
272
|
+
system)
|
|
273
|
+
|
|
274
|
+
- Syntax: None
|
|
275
|
+
- *Note: Could add Kramdown citation syntax in future*
|
|
276
|
+
|
|
277
|
+
**Unified Mode:**
|
|
278
|
+
|
|
279
|
+
- Citations: **Enabled**
|
|
280
|
+
- Syntax: **All syntaxes** (Pandoc, MultiMarkdown, mmark)
|
|
281
|
+
- Auto-detection: Flexible parsing
|
|
282
|
+
- Bibliography: All sources (external files, inline YAML,
|
|
283
|
+
|
|
284
|
+
MMD definitions)
|
|
285
|
+
|
|
286
|
+
#### Syntax Detection in Unified Mode
|
|
287
|
+
|
|
288
|
+
**Strategy: Pattern-Based Detection**
|
|
289
|
+
|
|
290
|
+
1. **Pandoc Syntax** (`[@key]` or `@key`):
|
|
291
|
+
- Pattern: `[@` followed by alphanumeric key
|
|
292
|
+
- Most common, try first
|
|
293
|
+
|
|
294
|
+
Supports: prefixes, locators, suffixes, author suppression
|
|
295
|
+
|
|
296
|
+
2. **MultiMarkdown Syntax** (`[#key]`):
|
|
297
|
+
- Pattern: `[#` followed by citation key
|
|
298
|
+
- Distinctive `#` marker
|
|
299
|
+
- Supports: locators before citation
|
|
300
|
+
|
|
301
|
+
3. **mmark Syntax** (`[@RFC1234]`):
|
|
302
|
+
- Pattern: `[@` followed by RFC/BCP/STD/I-D/W3C prefix
|
|
303
|
+
- Special case: auto-generate references
|
|
304
|
+
|
|
305
|
+
Supports: modifiers (`!`, `?`, `-`), combined references
|
|
306
|
+
|
|
307
|
+
**Detection Algorithm:**
|
|
308
|
+
```
|
|
309
|
+
For each potential citation:
|
|
310
|
+
1. Check for mmark pattern: [@RFC...] or [@BCP...] etc.
|
|
311
|
+
→ If match: Process as mmark citation
|
|
312
|
+
2. Check for MultiMarkdown pattern: [#key]
|
|
313
|
+
→ If match: Process as MMD citation
|
|
314
|
+
3. Check for Pandoc pattern: [@key] or @key
|
|
315
|
+
→ If match: Process as Pandoc citation
|
|
316
|
+
4. If no match: Leave as-is (not a citation)
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
**Edge Cases:**
|
|
321
|
+
|
|
322
|
+
- `[@RFC1234]` could be Pandoc or mmark → Prefer mmark if
|
|
323
|
+
|
|
324
|
+
matches RFC pattern
|
|
325
|
+
|
|
326
|
+
- `[#key]` is unambiguous → Always MultiMarkdown
|
|
327
|
+
- `[@key]` without RFC prefix → Pandoc syntax
|
|
328
|
+
|
|
329
|
+
## Implementation Architecture
|
|
330
|
+
|
|
331
|
+
### Processing Pipeline
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
1. Preprocessing Phase
|
|
335
|
+
├─ Extract metadata (YAML, MMD, Pandoc)
|
|
336
|
+
├─ Load bibliography files (from metadata or CLI)
|
|
337
|
+
├─ Parse bibliography (BibTeX → CSL JSON, CSL JSON, CSL YAML)
|
|
338
|
+
└─ Build citation index (map keys to entries)
|
|
339
|
+
|
|
340
|
+
2. Parsing Phase
|
|
341
|
+
├─ Scan for citations (mode-aware)
|
|
342
|
+
├─ Extract citation data (key, locator, prefix, suffix)
|
|
343
|
+
├─ Match citations to bibliography entries
|
|
344
|
+
└─ Store citation registry
|
|
345
|
+
|
|
346
|
+
3. Rendering Phase
|
|
347
|
+
├─ Process citations through CSL (or simple formatter)
|
|
348
|
+
├─ Generate citation HTML
|
|
349
|
+
├─ Collect cited items for bibliography
|
|
350
|
+
└─ Format bibliography entries
|
|
351
|
+
|
|
352
|
+
4. Post-processing Phase
|
|
353
|
+
├─ Insert bibliography at marker or end
|
|
354
|
+
├─ Add links between citations and bibliography
|
|
355
|
+
├─ Add tooltips (if enabled)
|
|
356
|
+
└─ Final HTML output
|
|
357
|
+
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### File Structure
|
|
361
|
+
|
|
362
|
+
```
|
|
363
|
+
src/extensions/
|
|
364
|
+
├── citations.h # Citation parsing header
|
|
365
|
+
├── citations.c # Citation parsing implementation
|
|
366
|
+
├── bibliography.h # Bibliography handling header
|
|
367
|
+
├── bibliography.c # Bibliography parsing/formatting
|
|
368
|
+
├── bibtex_parser.h # BibTeX parser header
|
|
369
|
+
├── bibtex_parser.c # BibTeX parser implementation
|
|
370
|
+
└── csl_formatter.h # CSL formatter header (if implementing minimal CSL)
|
|
371
|
+
└── csl_formatter.c # CSL formatter implementation (if implementing minimal CSL)
|
|
372
|
+
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
### Core Data Structures
|
|
376
|
+
|
|
377
|
+
```c
|
|
378
|
+
/* Citation structure */
|
|
379
|
+
typedef struct {
|
|
380
|
+
char *key; // Citation key (e.g., "doe99")
|
|
381
|
+
char *prefix; // Prefix text (e.g., "see")
|
|
382
|
+
char *locator; // Locator (e.g., "pp. 33-35")
|
|
383
|
+
char *suffix; // Suffix text (e.g., "and passim")
|
|
384
|
+
bool author_suppressed; // -@key syntax
|
|
385
|
+
bool author_in_text; // @key syntax (no brackets)
|
|
386
|
+
int syntax_type; // PANDOC, MMD, MMARK
|
|
387
|
+
int position; // Position in document
|
|
388
|
+
} apex_citation;
|
|
389
|
+
|
|
390
|
+
/* Bibliography entry (CSL JSON format) */
|
|
391
|
+
typedef struct {
|
|
392
|
+
char *id; // Citation key
|
|
393
|
+
char *type; // Entry type (article-journal, book, etc.)
|
|
394
|
+
cJSON *data; // Full CSL JSON object (using cJSON)
|
|
395
|
+
} apex_bibliography_entry;
|
|
396
|
+
|
|
397
|
+
/* Citation registry */
|
|
398
|
+
typedef struct {
|
|
399
|
+
apex_citation **citations; // Array of citations
|
|
400
|
+
size_t count; // Number of citations
|
|
401
|
+
apex_bibliography_entry **entries; // Bibliography entries
|
|
402
|
+
size_t entry_count; // Number of entries
|
|
403
|
+
cJSON *csl_style; // CSL style (if using)
|
|
404
|
+
} apex_citation_registry;
|
|
405
|
+
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
## Bibliography Format Details
|
|
409
|
+
|
|
410
|
+
### CSL JSON Structure
|
|
411
|
+
|
|
412
|
+
```json
|
|
413
|
+
[
|
|
414
|
+
{
|
|
415
|
+
"id": "doe99",
|
|
416
|
+
"type": "article-journal",
|
|
417
|
+
"author": [
|
|
418
|
+
{
|
|
419
|
+
"family": "Doe",
|
|
420
|
+
"given": "John"
|
|
421
|
+
}
|
|
422
|
+
],
|
|
423
|
+
"issued": {
|
|
424
|
+
"date-parts": [[1999]]
|
|
425
|
+
},
|
|
426
|
+
"title": "Article Title",
|
|
427
|
+
"container-title": "Journal Name",
|
|
428
|
+
"volume": "1",
|
|
429
|
+
"page": "1-10"
|
|
430
|
+
}
|
|
431
|
+
]
|
|
432
|
+
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### BibTeX to CSL JSON Conversion
|
|
436
|
+
|
|
437
|
+
**Common BibTeX Entry Types:**
|
|
438
|
+
|
|
439
|
+
- `@article` → `article-journal`
|
|
440
|
+
- `@book` → `book`
|
|
441
|
+
- `@inbook` → `chapter`
|
|
442
|
+
- `@incollection` → `chapter`
|
|
443
|
+
- `@inproceedings` → `paper-conference`
|
|
444
|
+
- `@phdthesis` → `thesis`
|
|
445
|
+
- `@mastersthesis` → `thesis`
|
|
446
|
+
- `@techreport` → `report`
|
|
447
|
+
|
|
448
|
+
**Field Mapping:**
|
|
449
|
+
|
|
450
|
+
- `author` → `author` (parse names)
|
|
451
|
+
- `title` → `title`
|
|
452
|
+
- `journal` → `container-title`
|
|
453
|
+
- `year` → `issued.date-parts`
|
|
454
|
+
- `pages` → `page`
|
|
455
|
+
- `publisher` → `publisher`
|
|
456
|
+
- `volume` → `volume`
|
|
457
|
+
- `number` → `issue`
|
|
458
|
+
|
|
459
|
+
### CSL YAML Structure
|
|
460
|
+
|
|
461
|
+
```yaml
|
|
462
|
+
- id: doe99
|
|
463
|
+
type: article-journal
|
|
464
|
+
author:
|
|
465
|
+
- family: Doe
|
|
466
|
+
given: John
|
|
467
|
+
issued:
|
|
468
|
+
date-parts:
|
|
469
|
+
- - 1999
|
|
470
|
+
title: Article Title
|
|
471
|
+
container-title: Journal Name
|
|
472
|
+
volume: 1
|
|
473
|
+
page: 1-10
|
|
474
|
+
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
## Output Format
|
|
478
|
+
|
|
479
|
+
### Citation HTML (Pandoc-style)
|
|
480
|
+
|
|
481
|
+
**Author-Date Style:**
|
|
482
|
+
```html
|
|
483
|
+
<span class="citation" data-cites="doe99">(Doe 1999)</span>
|
|
484
|
+
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
**Multiple Citations:**
|
|
488
|
+
```html
|
|
489
|
+
<span class="citation" data-cites="doe99 smith2000 smith2004">
|
|
490
|
+
(Doe 1999; Jane Smith 2000, 2004)
|
|
491
|
+
</span>
|
|
492
|
+
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
**With Locator:**
|
|
496
|
+
```html
|
|
497
|
+
<span class="citation" data-cites="doe99">Doe (1999, 33–35)</span>
|
|
498
|
+
|
|
499
|
+
```
|
|
500
|
+
|
|
501
|
+
**Author-Suppressed:**
|
|
502
|
+
```html
|
|
503
|
+
<span class="citation" data-cites="smith04">(2004)</span>
|
|
504
|
+
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
**With Links:**
|
|
508
|
+
```html
|
|
509
|
+
<a href="#ref-doe99" class="citation" data-cites="doe99">
|
|
510
|
+
(Doe 1999)
|
|
511
|
+
</a>
|
|
512
|
+
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**With Tooltips:**
|
|
516
|
+
```html
|
|
517
|
+
<a href="#ref-doe99" class="citation" data-cites="doe99"
|
|
518
|
+
title="Doe, John. 1999. 'Article Title.' Journal Name 1: 1-10.">
|
|
519
|
+
(Doe 1999)
|
|
520
|
+
</a>
|
|
521
|
+
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Bibliography HTML
|
|
525
|
+
|
|
526
|
+
```html
|
|
527
|
+
<div id="refs" class="references csl-bib-body hanging-indent" role="doc-bibliography">
|
|
528
|
+
<div id="ref-doe99" class="csl-entry" role="doc-biblioentry">
|
|
529
|
+
Doe, John. 1999. <span>"Article Title."</span> <em>Journal Name</em> 1: 1–10.
|
|
530
|
+
</div>
|
|
531
|
+
<div id="ref-smith2000" class="csl-entry" role="doc-biblioentry">
|
|
532
|
+
Smith, Jane. 2000. <em>Book Title</em>. Publisher.
|
|
533
|
+
</div>
|
|
534
|
+
</div>
|
|
535
|
+
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
### Bibliography Insertion Points
|
|
539
|
+
|
|
540
|
+
1. **`<!-- REFERENCES -->` marker** (if present)
|
|
541
|
+
2. **`{backmatter}` marker** (mmark style, if present)
|
|
542
|
+
3. **`<div id="refs">`** (if present)
|
|
543
|
+
4. **End of document** (default)
|
|
544
|
+
|
|
545
|
+
## Dependencies
|
|
546
|
+
|
|
547
|
+
### Required Libraries
|
|
548
|
+
|
|
549
|
+
1. **JSON Parser**: `cJSON` (lightweight C JSON library)
|
|
550
|
+
- For parsing CSL JSON and BibTeX (after conversion)
|
|
551
|
+
- License: MIT
|
|
552
|
+
- Small footprint
|
|
553
|
+
|
|
554
|
+
2. **BibTeX Parser**: Implement minimal parser in C
|
|
555
|
+
- Parse BibTeX entries
|
|
556
|
+
- Convert to CSL JSON
|
|
557
|
+
- Handle common entry types and fields
|
|
558
|
+
|
|
559
|
+
3. **YAML Parser**: Reuse existing Apex YAML parser
|
|
560
|
+
- Already used for metadata
|
|
561
|
+
- Can parse CSL YAML format
|
|
562
|
+
|
|
563
|
+
### CSL Processing Options
|
|
564
|
+
|
|
565
|
+
**Option 1: Minimal CSL Implementation (Recommended for
|
|
566
|
+
MVP)**
|
|
567
|
+
|
|
568
|
+
- Implement basic author-date formatting
|
|
569
|
+
- Support common entry types (article, book, chapter)
|
|
570
|
+
- Simple formatting rules
|
|
571
|
+
- **Pros**: No external dependencies, full control
|
|
572
|
+
- **Cons**: Limited style support, more work
|
|
573
|
+
|
|
574
|
+
**Option 2: Use citeproc-rs via FFI**
|
|
575
|
+
|
|
576
|
+
- Rust library with C bindings
|
|
577
|
+
- Full CSL support
|
|
578
|
+
- **Pros**: Complete CSL support, well-tested
|
|
579
|
+
- **Cons**: Requires Rust toolchain, FFI complexity
|
|
580
|
+
|
|
581
|
+
**Option 3: Use citeproc-js via Node.js**
|
|
582
|
+
|
|
583
|
+
- JavaScript library
|
|
584
|
+
- **Pros**: Full CSL support
|
|
585
|
+
- **Cons**: Requires Node.js, complex integration
|
|
586
|
+
|
|
587
|
+
**Recommendation**: Start with Option 1 (minimal
|
|
588
|
+
implementation) for MVP, consider Option 2 for full CSL
|
|
589
|
+
support later.
|
|
590
|
+
|
|
591
|
+
## Implementation Phases
|
|
592
|
+
|
|
593
|
+
### Phase 1: Basic Citation Parsing (MVP)
|
|
594
|
+
- [ ] Parse Pandoc syntax `[@key]` (simple keys only)
|
|
595
|
+
- [ ] Parse MultiMarkdown syntax `[#key]`
|
|
596
|
+
- [ ] Parse mmark syntax `[@RFC1234]` (basic)
|
|
597
|
+
- [ ] Store citations in registry
|
|
598
|
+
- [ ] Basic HTML output (show key or simple format)
|
|
599
|
+
- [ ] Mode-aware syntax detection
|
|
600
|
+
|
|
601
|
+
### Phase 2: Bibliography Loading
|
|
602
|
+
- [ ] Load CSL JSON files
|
|
603
|
+
- [ ] Parse CSL JSON to internal format
|
|
604
|
+
- [ ] Load BibTeX files
|
|
605
|
+
- [ ] Convert BibTeX to CSL JSON
|
|
606
|
+
- [ ] Load CSL YAML files
|
|
607
|
+
- [ ] Parse MultiMarkdown reference definitions
|
|
608
|
+
- [ ] Merge multiple bibliography sources
|
|
609
|
+
- [ ] Match citations to bibliography entries
|
|
610
|
+
|
|
611
|
+
### Phase 3: Basic Citation Formatting
|
|
612
|
+
- [ ] Implement minimal author-date formatter
|
|
613
|
+
- [ ] Format citations with author names and years
|
|
614
|
+
- [ ] Handle multiple citations
|
|
615
|
+
- [ ] Generate proper HTML output
|
|
616
|
+
- [ ] Add CSS classes
|
|
617
|
+
|
|
618
|
+
### Phase 4: Bibliography Generation
|
|
619
|
+
- [ ] Collect cited items
|
|
620
|
+
- [ ] Sort bibliography entries
|
|
621
|
+
- [ ] Format bibliography entries
|
|
622
|
+
- [ ] Generate bibliography HTML
|
|
623
|
+
- [ ] Insert bibliography at marker or end
|
|
624
|
+
|
|
625
|
+
### Phase 5: Advanced Features
|
|
626
|
+
- [ ] Support locators (pages, chapters, etc.)
|
|
627
|
+
- [ ] Support prefixes and suffixes
|
|
628
|
+
- [ ] Support author suppression (`-@key`)
|
|
629
|
+
- [ ] Support author-in-text (`@key`)
|
|
630
|
+
- [ ] Add citation links
|
|
631
|
+
- [ ] Add tooltips
|
|
632
|
+
- [ ] Support `nocite` metadata
|
|
633
|
+
|
|
634
|
+
### Phase 6: Full CSL Support (Future)
|
|
635
|
+
- [ ] Integrate full CSL processor
|
|
636
|
+
- [ ] Support multiple citation styles
|
|
637
|
+
- [ ] Load CSL style files
|
|
638
|
+
- [ ] Support numeric and note styles
|
|
639
|
+
|
|
640
|
+
## Testing Strategy
|
|
641
|
+
|
|
642
|
+
### Unit Tests
|
|
643
|
+
|
|
644
|
+
1. **Citation Parsing**:
|
|
645
|
+
- Test each syntax (Pandoc, MMD, mmark)
|
|
646
|
+
- Test edge cases (nested brackets, special characters)
|
|
647
|
+
- Test mode detection in unified mode
|
|
648
|
+
|
|
649
|
+
2. **Bibliography Parsing**:
|
|
650
|
+
- Test each format (BibTeX, CSL JSON, CSL YAML)
|
|
651
|
+
- Test multiple files
|
|
652
|
+
- Test inline references
|
|
653
|
+
- Test error handling (missing files, invalid format)
|
|
654
|
+
|
|
655
|
+
3. **Citation Formatting**:
|
|
656
|
+
- Test author-date formatting
|
|
657
|
+
- Test multiple citations
|
|
658
|
+
- Test with/without links
|
|
659
|
+
- Test with/without tooltips
|
|
660
|
+
|
|
661
|
+
4. **Bibliography Generation**:
|
|
662
|
+
- Test sorting
|
|
663
|
+
- Test formatting
|
|
664
|
+
- Test insertion points
|
|
665
|
+
- Test suppression
|
|
666
|
+
|
|
667
|
+
### Integration Tests
|
|
668
|
+
|
|
669
|
+
1. **End-to-end**:
|
|
670
|
+
- Full document with citations
|
|
671
|
+
- Multiple bibliography sources
|
|
672
|
+
- Different citation styles
|
|
673
|
+
- Different output formats
|
|
674
|
+
|
|
675
|
+
2. **Mode Compatibility**:
|
|
676
|
+
|
|
677
|
+
Test in each mode (commonmark, gfm, mmd, kramdown, unified)
|
|
678
|
+
|
|
679
|
+
- Test syntax detection in unified mode
|
|
680
|
+
- Test feature flags
|
|
681
|
+
|
|
682
|
+
## Configuration
|
|
683
|
+
|
|
684
|
+
### API Options
|
|
685
|
+
|
|
686
|
+
```c
|
|
687
|
+
typedef struct {
|
|
688
|
+
// ... existing options ...
|
|
689
|
+
|
|
690
|
+
// Citation options
|
|
691
|
+
bool enable_citations;
|
|
692
|
+
char **bibliography_files; // NULL-terminated array
|
|
693
|
+
const char *csl_file; // CSL style file
|
|
694
|
+
bool suppress_bibliography;
|
|
695
|
+
bool link_citations;
|
|
696
|
+
bool show_tooltips;
|
|
697
|
+
const char *nocite; // Comma-separated keys, or "*" for all
|
|
698
|
+
} apex_options;
|
|
699
|
+
|
|
700
|
+
```
|
|
701
|
+
|
|
702
|
+
## Open Questions
|
|
703
|
+
|
|
704
|
+
1. **CSL Processor**: Start with minimal implementation or
|
|
705
|
+
|
|
706
|
+
use existing library?
|
|
707
|
+
|
|
708
|
+
- **Recommendation**: Start minimal, add full CSL later
|
|
709
|
+
|
|
710
|
+
2. **BibTeX Parser**: Implement or use library?
|
|
711
|
+
- **Recommendation**: Implement minimal parser
|
|
712
|
+
|
|
713
|
+
3. **Performance**: How to handle large bibliographies
|
|
714
|
+
|
|
715
|
+
(1000+ entries)?
|
|
716
|
+
|
|
717
|
+
- **Recommendation**: Use hash table for lookup, cache
|
|
718
|
+
|
|
719
|
+
parsed bibliographies
|
|
720
|
+
|
|
721
|
+
4. **Validation**: How strict should citation validation be?
|
|
722
|
+
- **Recommendation**: Warn on missing citations, don't
|
|
723
|
+
|
|
724
|
+
error (like Pandoc)
|
|
725
|
+
|
|
726
|
+
5. **Error Handling**: How to handle missing citations?
|
|
727
|
+
|
|
728
|
+
**Recommendation**: Show citation key in output with warning
|
|
729
|
+
|
|
730
|
+
6. **Backwards Compatibility**: How to ensure existing
|
|
731
|
+
|
|
732
|
+
documents still work?
|
|
733
|
+
|
|
734
|
+
- **Recommendation**: Citations only processed if
|
|
735
|
+
|
|
736
|
+
bibliography is provided
|
|
737
|
+
|
|
738
|
+
## References
|
|
739
|
+
|
|
740
|
+
[Pandoc Citations](https://pandoc.org/demo/example33/8.20-citation-syntax.html)
|
|
741
|
+
|
|
742
|
+
[MultiMarkdown Citations](https://fletcher.github.io/MultiMarkdown-6/Documentation/bibliography.html)
|
|
743
|
+
|
|
744
|
+
- [mmark Citations](https://mmark.miek.nl/post/citations/)
|
|
745
|
+
- [CSL Project](https://citationstyles.org/)
|
|
746
|
+
|
|
747
|
+
[Citation Style Language](https://docs.citationstyles.org/en/stable/)
|
|
748
|
+
|
|
749
|
+
- [cJSON Library](https://github.com/DaveGamble/cJSON)
|