Skip to content

Commit

Permalink
Apply upstream PR github/cmark-gfm#362
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
jeroen committed Oct 8, 2024
1 parent eb01599 commit be62b2b
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 1 deletion.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: commonmark
Type: Package
Title: High Performance CommonMark and Github Markdown Rendering in R
Version: 1.9.2
Version: 1.9.3
Authors@R: c(
person("Jeroen", "Ooms", ,"jeroenooms@gmail.com", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4035-0289")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.9.3
- Apply upstream PR https://github.com/github/cmark-gfm/pull/362

1.9.1
- Update libcmark-gfm to 0.29.0.gfm.13

Expand Down
4 changes: 4 additions & 0 deletions src/cmark/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,10 @@ const char *cmark_node_get_type_string(cmark_node *node) {
return "link";
case CMARK_NODE_IMAGE:
return "image";
case CMARK_NODE_FOOTNOTE_REFERENCE:
return "fnref";
case CMARK_NODE_FOOTNOTE_DEFINITION:
return "fn";
}

return "<unknown>";
Expand Down
19 changes: 19 additions & 0 deletions src/cmark/xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,25 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
escape_xml(xml, node->as.link.title.data, node->as.link.title.len);
cmark_strbuf_putc(xml, '"');
break;
case CMARK_NODE_FOOTNOTE_DEFINITION:
cmark_strbuf_puts(xml, " id=\"fn-");
escape_xml(xml, node->as.literal.data, node->as.literal.len);
cmark_strbuf_putc(xml, '"');
break;
case CMARK_NODE_FOOTNOTE_REFERENCE:
cmark_strbuf_puts(xml, " id=\"fnref-");
escape_xml(xml, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
if (node->footnote.ref_ix > 1) {
char n[32];
snprintf(n, sizeof(n), "%d", node->footnote.ref_ix);
cmark_strbuf_puts(xml, "-");
cmark_strbuf_puts(xml, n);
}
cmark_strbuf_putc(xml, '"');
cmark_strbuf_puts(xml, " destination=\"fn-");
escape_xml(xml, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
cmark_strbuf_putc(xml, '"');
break;
default:
break;
}
Expand Down
45 changes: 45 additions & 0 deletions src/patches/362.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/src/node.c b/src/node.c
index e7a9606d5..c7e62d25b 100644
--- a/src/node.c
+++ b/src/node.c
@@ -288,6 +288,10 @@ const char *cmark_node_get_type_string(cmark_node *node) {
return "link";
case CMARK_NODE_IMAGE:
return "image";
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
+ return "fnref";
+ case CMARK_NODE_FOOTNOTE_DEFINITION:
+ return "fn";
}

return "<unknown>";
diff --git a/src/xml.c b/src/xml.c
index 5753e5ab9..c9a79cfd6 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -134,6 +134,25 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
escape_xml(xml, node->as.link.title.data, node->as.link.title.len);
cmark_strbuf_putc(xml, '"');
break;
+ case CMARK_NODE_FOOTNOTE_DEFINITION:
+ cmark_strbuf_puts(xml, " id=\"fn-");
+ escape_xml(xml, node->as.literal.data, node->as.literal.len);
+ cmark_strbuf_putc(xml, '"');
+ break;
+ case CMARK_NODE_FOOTNOTE_REFERENCE:
+ cmark_strbuf_puts(xml, " id=\"fnref-");
+ escape_xml(xml, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
+ if (node->footnote.ref_ix > 1) {
+ char n[32];
+ snprintf(n, sizeof(n), "%d", node->footnote.ref_ix);
+ cmark_strbuf_puts(xml, "-");
+ cmark_strbuf_puts(xml, n);
+ }
+ cmark_strbuf_putc(xml, '"');
+ cmark_strbuf_puts(xml, " destination=\"fn-");
+ escape_xml(xml, node->parent_footnote_def->as.literal.data, node->parent_footnote_def->as.literal.len);
+ cmark_strbuf_putc(xml, '"');
+ break;
default:
break;
}
5 changes: 5 additions & 0 deletions src/patches/apply.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

# Upstream PR: https://github.com/github/cmark-gfm/pull/362
patch -p2 -d ../cmark < 362.diff

0 comments on commit be62b2b

Please sign in to comment.