diff --git a/DESCRIPTION b/DESCRIPTION index 7b253d0..c16582c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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")), diff --git a/NEWS b/NEWS index 775c89a..59be9da 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/src/cmark/node.c b/src/cmark/node.c index e7a9606..c7e62d2 100644 --- a/src/cmark/node.c +++ b/src/cmark/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 ""; diff --git a/src/cmark/xml.c b/src/cmark/xml.c index 5753e5a..c9a79cf 100644 --- a/src/cmark/xml.c +++ b/src/cmark/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; } diff --git a/src/patches/362.diff b/src/patches/362.diff new file mode 100644 index 0000000..6ae0107 --- /dev/null +++ b/src/patches/362.diff @@ -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 ""; +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; + } diff --git a/src/patches/apply.sh b/src/patches/apply.sh new file mode 100755 index 0000000..9af4f82 --- /dev/null +++ b/src/patches/apply.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +# Upstream PR: https://github.com/github/cmark-gfm/pull/362 +patch -p2 -d ../cmark < 362.diff +