diff --git a/src/patches/apply.sh b/src/patches/apply.sh index 9af4f82..20f2127 100755 --- a/src/patches/apply.sh +++ b/src/patches/apply.sh @@ -2,4 +2,5 @@ # Upstream PR: https://github.com/github/cmark-gfm/pull/362 patch -p2 -d ../cmark < 362.diff - +# Support footnotes for LaTeX: https://github.com/r-lib/commonmark/pull/32 +patch -p2 -d ../cmark < latex-footnotes.diff diff --git a/src/patches/latex-footnotes.diff b/src/patches/latex-footnotes.diff new file mode 100644 index 0000000..3aa71e0 --- /dev/null +++ b/src/patches/latex-footnotes.diff @@ -0,0 +1,26 @@ +diff --git a/src/cmark/latex.c b/src/cmark/latex.c +index 1a6367a..5fab7ee 100644 +--- a/src/cmark/latex.c ++++ b/src/cmark/latex.c +@@ -447,8 +447,20 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, + break; + + case CMARK_NODE_FOOTNOTE_DEFINITION: ++ if (entering) { ++ LIT("\\footnotetext["); ++ OUT(cmark_chunk_to_cstr(renderer->mem, &node->as.literal), false, LITERAL); ++ LIT("]{"); ++ } else { ++ LIT("}"); ++ } ++ break; + case CMARK_NODE_FOOTNOTE_REFERENCE: +- // TODO ++ if (entering) { ++ LIT("\\footnotemark["); ++ OUT(cmark_chunk_to_cstr(renderer->mem, &node->parent_footnote_def->as.literal), false, LITERAL); ++ LIT("]"); ++ } + break; + + default: