Skip to content

Commit 1f026ef

Browse files
committed
Fix for footnotes being confused for link references.
When two footnote references are adjacent, the handle_close_bracket function will first try to match the closing bracket to a link reference. Now we reset the subject's state, so that the parser correctly picks up both footnote references.
1 parent 85d8952 commit 1f026ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/inlines.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,6 +1141,13 @@ static cmark_node *handle_close_bracket(cmark_parser *parser, subject *subj) {
11411141
!opener->inl_text->next->next) {
11421142
cmark_chunk *literal = &opener->inl_text->next->as.literal;
11431143
if (literal->len > 1 && literal->data[0] == '^') {
1144+
1145+
// Before we got this far, the `handle_close_bracket` function may have
1146+
// advanced the current state beyond our footnote's actual closing
1147+
// bracket, ie if it went looking for a `link_label`.
1148+
// Let's just rewind the subject's position:
1149+
subj->pos = initial_pos;
1150+
11441151
inl = make_simple(subj->mem, CMARK_NODE_FOOTNOTE_REFERENCE);
11451152
inl->as.literal = cmark_chunk_dup(literal, 1, literal->len - 1);
11461153
inl->start_line = inl->end_line = subj->line;

0 commit comments

Comments
 (0)