Skip to content

Commit

Permalink
git diff be62b2b c3be50e > src/patches/latex-footnotes.diff
Browse files Browse the repository at this point in the history
  • Loading branch information
yihui committed Oct 11, 2024
1 parent c3be50e commit 3c4600e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/patches/apply.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
26 changes: 26 additions & 0 deletions src/patches/latex-footnotes.diff
Original file line number Diff line number Diff line change
@@ -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:

0 comments on commit 3c4600e

Please sign in to comment.