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
|
@@ -45,8 +45,10 @@ static int find_def_separator(const unsigned char *line, int len) {
|
|
|
45
45
|
if (line[i] == ':' && line[i + 1] == ':') {
|
|
46
46
|
/* Skip :: that's part of URL (://) */
|
|
47
47
|
if (i + 3 <= len && line[i + 2] == '/') continue;
|
|
48
|
-
/* Skip
|
|
48
|
+
/* Skip ::: or more (div/custom element fence) */
|
|
49
49
|
if (i > 0 && line[i - 1] == ':') continue;
|
|
50
|
+
/* Skip Leanpub {::marker /} syntax */
|
|
51
|
+
if (i > 0 && line[i - 1] == '{') continue;
|
|
50
52
|
if (i + 2 < len && line[i + 2] == ':') continue;
|
|
51
53
|
last_sep = i;
|
|
52
54
|
}
|
|
@@ -140,6 +142,25 @@ static bool line_is_indented_code_block(const char *line, size_t len) {
|
|
|
140
142
|
return (content < line + len) && !looks_like_list_marker(content);
|
|
141
143
|
}
|
|
142
144
|
|
|
145
|
+
/** True if :: at scan is part of Leanpub {::marker /} syntax, not a definition list. */
|
|
146
|
+
static bool is_leanpub_marker_colons(const char *line_start, const char *colon_pos) {
|
|
147
|
+
return colon_pos > line_start && colon_pos[-1] == '{';
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** True if line is an ATX Markdown heading (# .. ######). */
|
|
151
|
+
static bool is_atx_heading_line(const char *line, size_t len) {
|
|
152
|
+
size_t i = 0;
|
|
153
|
+
while (i < len && (line[i] == ' ' || line[i] == '\t')) i++;
|
|
154
|
+
if (i >= len || line[i] != '#') return false;
|
|
155
|
+
int hashes = 0;
|
|
156
|
+
while (i < len && line[i] == '#') {
|
|
157
|
+
hashes++;
|
|
158
|
+
i++;
|
|
159
|
+
}
|
|
160
|
+
if (hashes < 1 || hashes > 6) return false;
|
|
161
|
+
return i >= len || line[i] == ' ' || line[i] == '\t';
|
|
162
|
+
}
|
|
163
|
+
|
|
143
164
|
/**
|
|
144
165
|
* Scans line for inline code backticks, updates state for next line, and returns
|
|
145
166
|
* whether sep_pos is inside an inline code span. Single backticks toggle; 3+ are
|
|
@@ -172,6 +193,40 @@ static bool is_code_fence_line(const char *line, size_t len) {
|
|
|
172
193
|
if (p + 3 <= line + len && p[0] == '`' && p[1] == '`' && p[2] == '`') {
|
|
173
194
|
return true;
|
|
174
195
|
}
|
|
196
|
+
if (p + 3 <= line + len && p[0] == '~' && p[1] == '~' && p[2] == '~') {
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
return false;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Lines that clearly start a new Markdown block should not be buffered as
|
|
204
|
+
* potential definition-list terms (avoids eating blanks / mis-ordering fences).
|
|
205
|
+
*/
|
|
206
|
+
static bool is_block_start_line(const char *line, size_t len) {
|
|
207
|
+
const char *p = line;
|
|
208
|
+
const char *end = line + len;
|
|
209
|
+
while (p < end && (*p == ' ' || *p == '\t')) p++;
|
|
210
|
+
if (p >= end) return false;
|
|
211
|
+
|
|
212
|
+
if (*p == '>' || *p == '#' || *p == '|' || *p == '<') return true;
|
|
213
|
+
|
|
214
|
+
/* Unordered list markers */
|
|
215
|
+
if ((*p == '-' || *p == '*' || *p == '+') &&
|
|
216
|
+
(p + 1 >= end || p[1] == ' ' || p[1] == '\t')) {
|
|
217
|
+
return true;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* Ordered list markers: 1. / 1) */
|
|
221
|
+
if (isdigit((unsigned char)*p)) {
|
|
222
|
+
const char *q = p;
|
|
223
|
+
while (q < end && isdigit((unsigned char)*q)) q++;
|
|
224
|
+
if (q < end && (*q == '.' || *q == ')') &&
|
|
225
|
+
(q + 1 >= end || q[1] == ' ' || q[1] == '\t')) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
175
230
|
return false;
|
|
176
231
|
}
|
|
177
232
|
|
|
@@ -247,6 +302,7 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
247
302
|
if (scan[2] == ':') { scan++; continue; }
|
|
248
303
|
const char *line_start = scan;
|
|
249
304
|
while (line_start > text && line_start[-1] != '\n') line_start--;
|
|
305
|
+
if (is_leanpub_marker_colons(line_start, scan)) { scan++; continue; }
|
|
250
306
|
const char *p = line_start;
|
|
251
307
|
while (p < scan && (*p == ' ' || *p == '\t')) p++;
|
|
252
308
|
if (p >= scan || *p != '[') { has_pattern = true; break; }
|
|
@@ -290,6 +346,7 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
290
346
|
bool in_inline_code_span = false;
|
|
291
347
|
char term_buffer[4096];
|
|
292
348
|
int term_len = 0;
|
|
349
|
+
int blanks_after_term = 0; /* blanks skipped while a potential term is buffered */
|
|
293
350
|
bool dd_open = false; /* True when we output <dd> but not yet </dd> (for Kramdown continuation) */
|
|
294
351
|
bool prev_line_was_table_row = false;
|
|
295
352
|
|
|
@@ -316,13 +373,38 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
316
373
|
/* Track code blocks */
|
|
317
374
|
if (is_code_fence_line(line_start, line_length)) {
|
|
318
375
|
in_code_block = !in_code_block;
|
|
319
|
-
if (
|
|
320
|
-
/*
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
376
|
+
if (in_code_block) {
|
|
377
|
+
/* Entering fenced code: close DL cleanly and flush buffered prose
|
|
378
|
+
* before the fence. Extra blank after </dl> so CommonMark does not
|
|
379
|
+
* treat the fence as part of an HTML block. */
|
|
380
|
+
if (dd_open) {
|
|
381
|
+
ENSURE_SPACE(10);
|
|
382
|
+
memcpy(write, "</dd>\n", 6);
|
|
383
|
+
write += 6;
|
|
384
|
+
remaining -= 6;
|
|
385
|
+
dd_open = false;
|
|
386
|
+
}
|
|
387
|
+
if (in_def_list) {
|
|
388
|
+
ENSURE_SPACE(10);
|
|
389
|
+
memcpy(write, "</dl>\n\n", 7);
|
|
390
|
+
write += 7;
|
|
391
|
+
remaining -= 7;
|
|
392
|
+
in_def_list = false;
|
|
393
|
+
}
|
|
394
|
+
if (term_len > 0) {
|
|
395
|
+
ENSURE_SPACE((size_t)term_len + 2 + (size_t)blanks_after_term);
|
|
396
|
+
memcpy(write, term_buffer, (size_t)term_len);
|
|
397
|
+
write += term_len;
|
|
398
|
+
remaining -= (size_t)term_len;
|
|
399
|
+
*write++ = '\n';
|
|
400
|
+
remaining--;
|
|
401
|
+
for (int bi = 0; bi < blanks_after_term; bi++) {
|
|
402
|
+
*write++ = '\n';
|
|
403
|
+
remaining--;
|
|
404
|
+
}
|
|
405
|
+
term_len = 0;
|
|
406
|
+
blanks_after_term = 0;
|
|
407
|
+
}
|
|
326
408
|
}
|
|
327
409
|
ENSURE_SPACE(line_length + 2);
|
|
328
410
|
memcpy(write, line_start, line_length);
|
|
@@ -347,6 +429,20 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
347
429
|
|
|
348
430
|
/* Skip definition processing inside indented code blocks */
|
|
349
431
|
if (in_indented_code_block) {
|
|
432
|
+
if (term_len > 0) {
|
|
433
|
+
ENSURE_SPACE((size_t)term_len + 2 + (size_t)blanks_after_term);
|
|
434
|
+
memcpy(write, term_buffer, (size_t)term_len);
|
|
435
|
+
write += term_len;
|
|
436
|
+
remaining -= (size_t)term_len;
|
|
437
|
+
*write++ = '\n';
|
|
438
|
+
remaining--;
|
|
439
|
+
for (int bi = 0; bi < blanks_after_term; bi++) {
|
|
440
|
+
*write++ = '\n';
|
|
441
|
+
remaining--;
|
|
442
|
+
}
|
|
443
|
+
term_len = 0;
|
|
444
|
+
blanks_after_term = 0;
|
|
445
|
+
}
|
|
350
446
|
ENSURE_SPACE(line_length + 2);
|
|
351
447
|
memcpy(write, line_start, line_length);
|
|
352
448
|
write += line_length;
|
|
@@ -424,6 +520,7 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
424
520
|
write += 6;
|
|
425
521
|
remaining -= 6;
|
|
426
522
|
term_len = 0;
|
|
523
|
+
blanks_after_term = 0; /* blanks between term and : are normal DL spacing */
|
|
427
524
|
} else if (in_def_list) {
|
|
428
525
|
/* Another : definition for same term */
|
|
429
526
|
if (dd_open) {
|
|
@@ -476,13 +573,18 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
476
573
|
in_def_list = false;
|
|
477
574
|
}
|
|
478
575
|
if (term_len > 0) {
|
|
479
|
-
ENSURE_SPACE((size_t)term_len + 2);
|
|
576
|
+
ENSURE_SPACE((size_t)term_len + 2 + (size_t)blanks_after_term);
|
|
480
577
|
memcpy(write, term_buffer, (size_t)term_len);
|
|
481
578
|
write += term_len;
|
|
482
579
|
remaining -= (size_t)term_len;
|
|
483
580
|
*write++ = '\n';
|
|
484
581
|
remaining--;
|
|
582
|
+
for (int bi = 0; bi < blanks_after_term; bi++) {
|
|
583
|
+
*write++ = '\n';
|
|
584
|
+
remaining--;
|
|
585
|
+
}
|
|
485
586
|
term_len = 0;
|
|
587
|
+
blanks_after_term = 0;
|
|
486
588
|
}
|
|
487
589
|
/* Extract term (before ::) and definition (after ::) */
|
|
488
590
|
const char *term_start = line_start;
|
|
@@ -564,7 +666,8 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
564
666
|
if (is_blank) {
|
|
565
667
|
/* Blank line: keep def list open (next line might be : definition for same term) */
|
|
566
668
|
if (term_len > 0) {
|
|
567
|
-
/*
|
|
669
|
+
/* Remember blanks; restore them if this was not actually a term */
|
|
670
|
+
blanks_after_term++;
|
|
568
671
|
} else if (!in_def_list) {
|
|
569
672
|
ENSURE_SPACE(2);
|
|
570
673
|
*write++ = '\n';
|
|
@@ -579,18 +682,25 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
579
682
|
in_def_list = false;
|
|
580
683
|
}
|
|
581
684
|
if (term_len > 0) {
|
|
582
|
-
ENSURE_SPACE((size_t)term_len + 2);
|
|
685
|
+
ENSURE_SPACE((size_t)term_len + 2 + (size_t)blanks_after_term);
|
|
583
686
|
memcpy(write, term_buffer, (size_t)term_len);
|
|
584
687
|
write += term_len;
|
|
585
688
|
remaining -= (size_t)term_len;
|
|
586
689
|
*write++ = '\n';
|
|
587
690
|
remaining--;
|
|
691
|
+
for (int bi = 0; bi < blanks_after_term; bi++) {
|
|
692
|
+
*write++ = '\n';
|
|
693
|
+
remaining--;
|
|
694
|
+
}
|
|
588
695
|
term_len = 0;
|
|
696
|
+
blanks_after_term = 0;
|
|
589
697
|
}
|
|
590
698
|
const char *p = line_start;
|
|
591
699
|
while (p < line_end && (*p == ' ' || *p == '\t')) p++;
|
|
592
700
|
bool is_ref_def = (p < line_end && *p == '[' && memchr(p, ':', (size_t)(line_end - p)) != NULL);
|
|
593
|
-
if (is_ref_def ||
|
|
701
|
+
if (is_ref_def || is_atx_heading_line(line_start, line_length) ||
|
|
702
|
+
is_block_start_line(line_start, line_length) ||
|
|
703
|
+
line_length >= sizeof(term_buffer) - 1) {
|
|
594
704
|
ENSURE_SPACE(line_length + 2);
|
|
595
705
|
memcpy(write, line_start, line_length);
|
|
596
706
|
write += line_length;
|
|
@@ -601,6 +711,7 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
601
711
|
memcpy(term_buffer, line_start, line_length);
|
|
602
712
|
term_len = (int)line_length;
|
|
603
713
|
term_buffer[term_len] = '\0';
|
|
714
|
+
blanks_after_term = 0;
|
|
604
715
|
}
|
|
605
716
|
}
|
|
606
717
|
}
|
|
@@ -625,14 +736,17 @@ char *apex_process_definition_lists(const char *text, bool unsafe) {
|
|
|
625
736
|
write += 6;
|
|
626
737
|
}
|
|
627
738
|
if (in_def_list) {
|
|
628
|
-
memcpy(write, "</dl>\n",
|
|
629
|
-
write +=
|
|
739
|
+
memcpy(write, "</dl>\n\n", 7);
|
|
740
|
+
write += 7;
|
|
630
741
|
}
|
|
631
742
|
if (term_len > 0) {
|
|
632
|
-
ENSURE_SPACE((size_t)term_len + 2);
|
|
743
|
+
ENSURE_SPACE((size_t)term_len + 2 + (size_t)blanks_after_term);
|
|
633
744
|
memcpy(write, term_buffer, (size_t)term_len);
|
|
634
745
|
write += term_len;
|
|
635
746
|
*write++ = '\n';
|
|
747
|
+
for (int bi = 0; bi < blanks_after_term; bi++) {
|
|
748
|
+
*write++ = '\n';
|
|
749
|
+
}
|
|
636
750
|
}
|
|
637
751
|
|
|
638
752
|
*write = '\0';
|