Skip to content

Commit

Permalink
Merge pull request #336 from ioquatix/expose-footnote-def-literal
Browse files Browse the repository at this point in the history
Expose CMARK_NODE_FOOTNOTE_DEFINITION literal value.
  • Loading branch information
anticomputer committed Jul 20, 2023
2 parents 049a6e3 + 85d2eb9 commit c123e68
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/blocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,12 +1221,13 @@ static void open_new_blocks(cmark_parser *parser, cmark_node **container,
depth < MAX_LIST_DEPTH &&
(matched = scan_footnote_definition(input, parser->first_nonspace))) {
cmark_chunk c = cmark_chunk_dup(input, parser->first_nonspace + 2, matched - 2);
cmark_chunk_to_cstr(parser->mem, &c);

while (c.data[c.len - 1] != ']')
--c.len;
--c.len;

cmark_chunk_to_cstr(parser->mem, &c);

S_advance_offset(parser, input, parser->first_nonspace + matched - parser->offset, false);
*container = add_child(parser, *container, CMARK_NODE_FOOTNOTE_DEFINITION, parser->first_nonspace + matched + 1);
(*container)->as.literal = c;
Expand Down
1 change: 1 addition & 0 deletions src/node.c
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ const char *cmark_node_get_literal(cmark_node *node) {
case CMARK_NODE_HTML_INLINE:
case CMARK_NODE_CODE:
case CMARK_NODE_FOOTNOTE_REFERENCE:
case CMARK_NODE_FOOTNOTE_DEFINITION:
return cmark_chunk_to_cstr(NODE_MEM(node), &node->as.literal);

case CMARK_NODE_CODE_BLOCK:
Expand Down

0 comments on commit c123e68

Please sign in to comment.