diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2014-11-18 00:12:27 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-11-17 21:43:47 -0800 |
commit | 59fd5633da5395cbd3627af4a2ab855dc43ce1e0 (patch) | |
tree | 89da7422572556dc2ac911a78889431f14db107b /src/blocks.c | |
parent | c38944d4565b6266b3ab1fd6fd576710fdec420b (diff) |
Set prev, parent and last_child for inlines
Diffstat (limited to 'src/blocks.c')
-rw-r--r-- | src/blocks.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/blocks.c b/src/blocks.c index cf5e08c..0e68259 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -283,6 +283,19 @@ typedef struct BlockStack { cmark_node *next_sibling; } block_stack; +static void fix_parents(cmark_node *node) { + cmark_node *cur = node->first_child; + if (cur == NULL) { + return; + } + while (cur->next != NULL) { + cur->parent = node; + cur = cur->next; + } + cur->parent = node; + node->last_child = cur; +} + // Walk through cmark_node and all children, recursively, parsing // string content into inline content where appropriate. static void process_inlines(cmark_node* cur, reference_map *refmap) @@ -296,6 +309,7 @@ static void process_inlines(cmark_node* cur, reference_map *refmap) case NODE_ATX_HEADER: case NODE_SETEXT_HEADER: cur->first_child = parse_inlines(&cur->string_content, refmap); + fix_parents(cur); break; default: @@ -817,6 +831,11 @@ cmark_node *cmark_finish(cmark_doc_parser *parser) { finalize_document(parser); strbuf_free(parser->curline); +#if CMARK_DEBUG_NODES + if (cmark_node_check(parser->root)) { + abort(); + } +#endif return parser->root; } |