apex-ruby 1.0.49 → 1.0.50
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/ext/apex_ext/apex_src/include/apex/apex.h +3 -2
- data/ext/apex_ext/apex_src/src/apex.c +8 -1
- data/ext/apex_ext/apex_src/src/extensions/header_ids.c +20 -9
- data/ext/apex_ext/apex_src/src/extensions/header_ids.h +5 -2
- data/ext/apex_ext/apex_src/src/extensions/metadata.c +7 -0
- data/lib/apex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 367266e3dc20e1bea48dcfbb506dabacc5e8ec7ed95dd339d7075ce67047abc3
|
|
4
|
+
data.tar.gz: f6d7518abf56c2e3acd69984b3b0f6573953540172f5e6e8c6c2c7036641bdd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: afbccd44654b5b4356287e7390a8edcfd70b4dbb77767fab36e00cafddaed29ca5f61f312c97ad9a3a23679f2ab4c601d5d524cbca7e2de85a31e6106557b89b
|
|
7
|
+
data.tar.gz: 27a642972a593ef8a8d539b9307da09661dec090adbabb69032334d82eded42d3889c52168590e7f1af838fe62d08635607d2b43bcddd5cd61c0050ba9d02083
|
|
@@ -21,8 +21,8 @@ typedef struct cmark_node cmark_node;
|
|
|
21
21
|
|
|
22
22
|
#define APEX_VERSION_MAJOR 1
|
|
23
23
|
#define APEX_VERSION_MINOR 1
|
|
24
|
-
#define APEX_VERSION_PATCH
|
|
25
|
-
#define APEX_VERSION_STRING "1.1.
|
|
24
|
+
#define APEX_VERSION_PATCH 58
|
|
25
|
+
#define APEX_VERSION_STRING "1.1.58"
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Processor compatibility modes
|
|
@@ -199,6 +199,7 @@ typedef struct apex_options {
|
|
|
199
199
|
/* Header ID generation */
|
|
200
200
|
bool generate_header_ids; /* Generate IDs for headers */
|
|
201
201
|
bool header_anchors; /* Generate <a> anchor tags instead of header IDs */
|
|
202
|
+
bool mmd_header_ids; /* Trailing [id] on a heading is a MultiMarkdown header id */
|
|
202
203
|
int id_format; /* 0=GFM (with dashes), 1=MMD (no dashes) */
|
|
203
204
|
|
|
204
205
|
/* TOC depth defaults (used by -t toc and by HTML TOC markers without an explicit range) */
|
|
@@ -3030,6 +3030,7 @@ apex_options apex_options_default(void) {
|
|
|
3030
3030
|
/* Header IDs */
|
|
3031
3031
|
opts.generate_header_ids = true;
|
|
3032
3032
|
opts.header_anchors = false; /* Use header IDs by default, not anchor tags */
|
|
3033
|
+
opts.mmd_header_ids = true; /* Unified default: trailing [id] is a header id */
|
|
3033
3034
|
opts.id_format = 0; /* GFM format (with dashes) */
|
|
3034
3035
|
opts.toc_min = 1;
|
|
3035
3036
|
opts.toc_max = 3;
|
|
@@ -3176,6 +3177,7 @@ apex_options apex_options_for_mode(apex_mode_t mode) {
|
|
|
3176
3177
|
opts.unsafe = false; /* CommonMark mode: replace HTML comments with "raw HTML omitted" */
|
|
3177
3178
|
opts.hardbreaks = false;
|
|
3178
3179
|
opts.id_format = 0; /* GFM format (default) */
|
|
3180
|
+
opts.mmd_header_ids = false;
|
|
3179
3181
|
opts.relaxed_tables = false; /* CommonMark has no tables */
|
|
3180
3182
|
opts.per_cell_alignment = false; /* CommonMark: no per-cell alignment */
|
|
3181
3183
|
opts.allow_mixed_list_markers = false; /* CommonMark: current behavior (separate lists) */
|
|
@@ -3214,6 +3216,7 @@ apex_options apex_options_for_mode(apex_mode_t mode) {
|
|
|
3214
3216
|
opts.unsafe = false; /* GFM mode: replace HTML comments with "raw HTML omitted" */
|
|
3215
3217
|
opts.hardbreaks = true; /* GFM treats newlines as hard breaks */
|
|
3216
3218
|
opts.id_format = 0; /* GFM format */
|
|
3219
|
+
opts.mmd_header_ids = false;
|
|
3217
3220
|
opts.relaxed_tables = false; /* GFM uses standard table syntax */
|
|
3218
3221
|
opts.per_cell_alignment = false; /* GFM: no per-cell alignment */
|
|
3219
3222
|
opts.allow_mixed_list_markers = false; /* GFM: current behavior (separate lists) */
|
|
@@ -3253,6 +3256,7 @@ apex_options apex_options_for_mode(apex_mode_t mode) {
|
|
|
3253
3256
|
opts.enable_metadata_transforms = false;
|
|
3254
3257
|
opts.hardbreaks = false;
|
|
3255
3258
|
opts.id_format = 1; /* MMD format */
|
|
3259
|
+
opts.mmd_header_ids = true;
|
|
3256
3260
|
opts.allow_mixed_list_markers = true; /* MultiMarkdown: inherit type from first item */
|
|
3257
3261
|
opts.allow_alpha_lists = false; /* MultiMarkdown: no alpha lists */
|
|
3258
3262
|
opts.enable_citations = true; /* MultiMarkdown: citations enabled (if bibliography provided) */
|
|
@@ -3293,6 +3297,7 @@ apex_options apex_options_for_mode(apex_mode_t mode) {
|
|
|
3293
3297
|
opts.enable_metadata_transforms = false;
|
|
3294
3298
|
opts.hardbreaks = false;
|
|
3295
3299
|
opts.id_format = 2; /* Kramdown format */
|
|
3300
|
+
opts.mmd_header_ids = false;
|
|
3296
3301
|
opts.relaxed_tables = true; /* Kramdown supports relaxed tables */
|
|
3297
3302
|
opts.per_cell_alignment = false; /* Kramdown: no per-cell alignment */
|
|
3298
3303
|
opts.allow_mixed_list_markers = false; /* Kramdown: current behavior (separate lists) */
|
|
@@ -3312,6 +3317,7 @@ apex_options apex_options_for_mode(apex_mode_t mode) {
|
|
|
3312
3317
|
opts.enable_wiki_links = false; /* Disabled by default - use --wikilinks to enable */
|
|
3313
3318
|
opts.enable_math = true;
|
|
3314
3319
|
opts.id_format = 0; /* GFM format (default, can be overridden with --id-format) */
|
|
3320
|
+
opts.mmd_header_ids = true;
|
|
3315
3321
|
opts.relaxed_tables = true; /* Unified mode supports relaxed tables */
|
|
3316
3322
|
opts.per_cell_alignment = true; /* Unified mode: per-cell alignment enabled by default */
|
|
3317
3323
|
opts.allow_mixed_list_markers = true; /* Unified: inherit type from first item */
|
|
@@ -3351,6 +3357,7 @@ apex_options apex_options_for_mode(apex_mode_t mode) {
|
|
|
3351
3357
|
opts.enable_wiki_links = false;
|
|
3352
3358
|
opts.enable_marked_extensions = false;
|
|
3353
3359
|
opts.enable_py_callouts = false;
|
|
3360
|
+
opts.mmd_header_ids = false;
|
|
3354
3361
|
opts.enable_indices = false;
|
|
3355
3362
|
opts.enable_mmark_index_syntax = false;
|
|
3356
3363
|
opts.enable_textindex_syntax = false;
|
|
@@ -6202,7 +6209,7 @@ char *apex_markdown_to_html(const char *markdown, size_t len, const apex_options
|
|
|
6202
6209
|
while ((event = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
|
|
6203
6210
|
cmark_node *node = cmark_iter_get_node(iter);
|
|
6204
6211
|
if (event == CMARK_EVENT_ENTER && cmark_node_get_type(node) == CMARK_NODE_HEADING) {
|
|
6205
|
-
apex_process_manual_header_id(node);
|
|
6212
|
+
apex_process_manual_header_id(node, options->mmd_header_ids);
|
|
6206
6213
|
}
|
|
6207
6214
|
}
|
|
6208
6215
|
cmark_iter_free(iter);
|
|
@@ -472,6 +472,8 @@ char *apex_extract_heading_text(cmark_node *heading_node) {
|
|
|
472
472
|
return text;
|
|
473
473
|
}
|
|
474
474
|
|
|
475
|
+
static bool is_valid_mmd_id(const char *s);
|
|
476
|
+
|
|
475
477
|
/**
|
|
476
478
|
* Extract manual header ID from heading text
|
|
477
479
|
* Supports:
|
|
@@ -484,7 +486,8 @@ char *apex_extract_heading_text(cmark_node *heading_node) {
|
|
|
484
486
|
* @param manual_id_out Output parameter for extracted ID (must be freed by caller)
|
|
485
487
|
* @return true if manual ID was found and extracted
|
|
486
488
|
*/
|
|
487
|
-
bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out
|
|
489
|
+
bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out,
|
|
490
|
+
bool mmd_header_ids) {
|
|
488
491
|
if (!heading_text || !*heading_text || !manual_id_out) {
|
|
489
492
|
return false;
|
|
490
493
|
}
|
|
@@ -493,8 +496,9 @@ bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out) {
|
|
|
493
496
|
size_t len = strlen(text);
|
|
494
497
|
if (len == 0) return false;
|
|
495
498
|
|
|
496
|
-
/* Try MultiMarkdown format: [id] at the end
|
|
497
|
-
|
|
499
|
+
/* Try MultiMarkdown format: [id] at the end. A space inside the brackets
|
|
500
|
+
* means the text belongs in the heading, not in the id. */
|
|
501
|
+
const char *mmd_start = mmd_header_ids ? strrchr(text, '[') : NULL;
|
|
498
502
|
if (mmd_start) {
|
|
499
503
|
const char *mmd_end = strchr(mmd_start, ']');
|
|
500
504
|
if (mmd_end && mmd_end > mmd_start + 1) {
|
|
@@ -512,10 +516,16 @@ bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out) {
|
|
|
512
516
|
/* Extract ID */
|
|
513
517
|
size_t id_len = mmd_end - mmd_start - 1;
|
|
514
518
|
if (id_len > 0) {
|
|
515
|
-
*
|
|
516
|
-
if (
|
|
517
|
-
memcpy(
|
|
518
|
-
|
|
519
|
+
char *candidate = malloc(id_len + 1);
|
|
520
|
+
if (candidate) {
|
|
521
|
+
memcpy(candidate, mmd_start + 1, id_len);
|
|
522
|
+
candidate[id_len] = '\0';
|
|
523
|
+
}
|
|
524
|
+
/* Whitespace or % is heading text (or a metadata variable), not an id. */
|
|
525
|
+
if (!candidate || !is_valid_mmd_id(candidate)) {
|
|
526
|
+
free(candidate);
|
|
527
|
+
} else {
|
|
528
|
+
*manual_id_out = candidate;
|
|
519
529
|
|
|
520
530
|
/* Remove [id] from text */
|
|
521
531
|
size_t prefix_len = mmd_start - text;
|
|
@@ -623,7 +633,7 @@ static bool is_valid_mmd_id(const char *s) {
|
|
|
623
633
|
* a link. If the heading is ONLY [id] (e.g. "# [mermaid]"), keep it as a link
|
|
624
634
|
* to avoid empty headings.
|
|
625
635
|
*/
|
|
626
|
-
bool apex_process_manual_header_id(cmark_node *heading_node) {
|
|
636
|
+
bool apex_process_manual_header_id(cmark_node *heading_node, bool mmd_header_ids) {
|
|
627
637
|
if (!heading_node || cmark_node_get_type(heading_node) != CMARK_NODE_HEADING) {
|
|
628
638
|
return false;
|
|
629
639
|
}
|
|
@@ -645,7 +655,7 @@ bool apex_process_manual_header_id(cmark_node *heading_node) {
|
|
|
645
655
|
if (!text_copy) continue;
|
|
646
656
|
|
|
647
657
|
char *manual_id = NULL;
|
|
648
|
-
bool found = apex_extract_manual_header_id(&text_copy, &manual_id);
|
|
658
|
+
bool found = apex_extract_manual_header_id(&text_copy, &manual_id, mmd_header_ids);
|
|
649
659
|
|
|
650
660
|
if (found && manual_id) {
|
|
651
661
|
/* Discard previous match - we want the rightmost */
|
|
@@ -690,6 +700,7 @@ bool apex_process_manual_header_id(cmark_node *heading_node) {
|
|
|
690
700
|
|
|
691
701
|
/* Edge case: [id] was parsed as a link (ref existed). If it's the last
|
|
692
702
|
* element and there's other content, treat as MMD heading ID. */
|
|
703
|
+
if (!mmd_header_ids) return false;
|
|
693
704
|
cmark_node *last = NULL;
|
|
694
705
|
cmark_node *child = cmark_node_first_child(heading_node);
|
|
695
706
|
while (child) {
|
|
@@ -42,9 +42,11 @@ char *apex_extract_heading_text(cmark_node *heading_node);
|
|
|
42
42
|
*
|
|
43
43
|
* @param heading_text Heading text (will be modified to remove ID syntax)
|
|
44
44
|
* @param manual_id_out Output parameter for extracted ID (must be freed by caller)
|
|
45
|
+
* @param mmd_header_ids When true, a trailing [id] with no whitespace is a header id
|
|
45
46
|
* @return true if manual ID was found and extracted
|
|
46
47
|
*/
|
|
47
|
-
bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out
|
|
48
|
+
bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out,
|
|
49
|
+
bool mmd_header_ids);
|
|
48
50
|
|
|
49
51
|
/**
|
|
50
52
|
* Process manual header IDs in a heading node
|
|
@@ -52,9 +54,10 @@ bool apex_extract_manual_header_id(char **heading_text, char **manual_id_out);
|
|
|
52
54
|
* Updates the heading text node to remove the manual ID syntax
|
|
53
55
|
*
|
|
54
56
|
* @param heading_node The heading AST node
|
|
57
|
+
* @param mmd_header_ids When true, a trailing [id] with no whitespace is a header id
|
|
55
58
|
* @return true if manual ID was found and processed
|
|
56
59
|
*/
|
|
57
|
-
bool apex_process_manual_header_id(cmark_node *heading_node);
|
|
60
|
+
bool apex_process_manual_header_id(cmark_node *heading_node, bool mmd_header_ids);
|
|
58
61
|
|
|
59
62
|
#endif
|
|
60
63
|
|
|
@@ -2811,6 +2811,13 @@ void apex_apply_metadata_to_options(apex_metadata_item *metadata, apex_options *
|
|
|
2811
2811
|
} else if (is_false_value(value)) {
|
|
2812
2812
|
options->enable_file_includes = false;
|
|
2813
2813
|
}
|
|
2814
|
+
} else if (strcasecmp(key, "mmd-header-ids") == 0 || strcasecmp(key, "mmd_header_ids") == 0 ||
|
|
2815
|
+
strcasecmp(key, "mmd-header-id") == 0) {
|
|
2816
|
+
if (is_true_value(value)) {
|
|
2817
|
+
options->mmd_header_ids = true;
|
|
2818
|
+
} else if (is_false_value(value)) {
|
|
2819
|
+
options->mmd_header_ids = false;
|
|
2820
|
+
}
|
|
2814
2821
|
} else if (strcasecmp(key, "relaxed-tables") == 0 || strcasecmp(key, "relaxed_tables") == 0) {
|
|
2815
2822
|
if (is_true_value(value)) {
|
|
2816
2823
|
options->relaxed_tables = true;
|
data/lib/apex/version.rb
CHANGED