-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Apply upstream PR github/cmark-gfm#362
Fixes #23
- Loading branch information
Showing
6 changed files
with
77 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|