markly 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78cfc5814d3b2666b77795de6b7e19ab99acf8b63ae6925bbb6158a69063fdda
4
- data.tar.gz: e063c28a6019b7623df0db94b2393e226d9e45c425d9230f77392a7097df0a9e
3
+ metadata.gz: e62908560f536f22b024d0fc29c02ee109a99aa6b4216d58e82fc97d7525171a
4
+ data.tar.gz: b6b7eae8d1579556a4461aa9d338cb1d86433fdcb20c6ac70983d0cdedeead6e
5
5
  SHA512:
6
- metadata.gz: 8e3ee35349c3aeafb8cb18cd586b564040c1db886c13dabcc2432628f6a692fd65d0c59c57ab0065f5ebdb6b8635e4bb3c7c6be598170c81164dcbf955324efe
7
- data.tar.gz: 818216b44c592bf1882ab799959aa6ec5d5cdf7c5ed8ead5f38fd8f5252226cb38192affb3a2dd22f5c30c6fd07d985d87b5b477d865aca41822e43e21d79c85
6
+ metadata.gz: daee4db1b759180ea27886da828fa1301aac0adb1833203b80b635ee815e61bebb8caedad03853cd4d4231de748781cefa6d341d3172d3a387e170cbd806cc47
7
+ data.tar.gz: a0f79ef83f73d32c8b1b14a21c13ad3c20574abed043e29cb0057c31c9b85ccb051244462efb0dfd508a3315232083de3bafefa0dc4d24fd5106bc966721bcdf
data/ext/markly/blocks.c CHANGED
@@ -468,7 +468,6 @@ static void process_footnotes(cmark_parser *parser) {
468
468
  while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
469
469
  cur = cmark_iter_get_node(iter);
470
470
  if (ev_type == CMARK_EVENT_EXIT && cur->type == CMARK_NODE_FOOTNOTE_DEFINITION) {
471
- cmark_node_unlink(cur);
472
471
  cmark_footnote_create(map, cur);
473
472
  }
474
473
  }
@@ -485,6 +484,15 @@ static void process_footnotes(cmark_parser *parser) {
485
484
  if (!footnote->ix)
486
485
  footnote->ix = ++ix;
487
486
 
487
+ // store a reference to this footnote reference's footnote definition
488
+ // this is used by renderers when generating label ids
489
+ cur->parent_footnote_def = footnote->node;
490
+
491
+ // keep track of a) count of how many times this footnote def has been
492
+ // referenced, and b) which reference index this footnote ref is at.
493
+ // this is used by renderers when generating links and backreferences.
494
+ cur->footnote.ref_ix = ++footnote->node->footnote.def_count;
495
+
488
496
  char n[32];
489
497
  snprintf(n, sizeof(n), "%d", footnote->ix);
490
498
  cmark_chunk_free(parser->mem, &cur->as.literal);
@@ -515,13 +523,16 @@ static void process_footnotes(cmark_parser *parser) {
515
523
  qsort(map->sorted, map->size, sizeof(cmark_map_entry *), sort_footnote_by_ix);
516
524
  for (unsigned int i = 0; i < map->size; ++i) {
517
525
  cmark_footnote *footnote = (cmark_footnote *)map->sorted[i];
518
- if (!footnote->ix)
526
+ if (!footnote->ix) {
527
+ cmark_node_unlink(footnote->node);
519
528
  continue;
529
+ }
520
530
  cmark_node_append_child(parser->root, footnote->node);
521
531
  footnote->node = NULL;
522
532
  }
523
533
  }
524
534
 
535
+ cmark_unlink_footnotes_map(map);
525
536
  cmark_map_free(map);
526
537
  }
527
538
 
@@ -1,7 +1,7 @@
1
1
  #ifndef CMARK_GFM_VERSION_H
2
2
  #define CMARK_GFM_VERSION_H
3
3
 
4
- #define CMARK_GFM_VERSION ((0 << 24) | (29 << 16) | (0 << 8) | 0)
5
- #define CMARK_GFM_VERSION_STRING "0.29.0.gfm.0"
4
+ #define CMARK_GFM_VERSION ((0 << 24) | (29 << 16) | (0 << 8) | 2)
5
+ #define CMARK_GFM_VERSION_STRING "0.29.0.gfm.2"
6
6
 
7
7
  #endif
@@ -477,7 +477,13 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
477
477
  case CMARK_NODE_FOOTNOTE_REFERENCE:
478
478
  if (entering) {
479
479
  LIT("[^");
480
- OUT(cmark_chunk_to_cstr(renderer->mem, &node->as.literal), false, LITERAL);
480
+
481
+ char *footnote_label = renderer->mem->calloc(node->parent_footnote_def->as.literal.len + 1, sizeof(char));
482
+ memmove(footnote_label, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
483
+
484
+ OUT(footnote_label, false, LITERAL);
485
+ renderer->mem->free(footnote_label);
486
+
481
487
  LIT("]");
482
488
  }
483
489
  break;
@@ -486,9 +492,13 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
486
492
  if (entering) {
487
493
  renderer->footnote_ix += 1;
488
494
  LIT("[^");
489
- char n[32];
490
- snprintf(n, sizeof(n), "%d", renderer->footnote_ix);
491
- OUT(n, false, LITERAL);
495
+
496
+ char *footnote_label = renderer->mem->calloc(node->as.literal.len + 1, sizeof(char));
497
+ memmove(footnote_label, node->as.literal.data, node->as.literal.len);
498
+
499
+ OUT(footnote_label, false, LITERAL);
500
+ renderer->mem->free(footnote_label);
501
+
492
502
  LIT("]:\n");
493
503
 
494
504
  cmark_strbuf_puts(renderer->prefix, " ");