From 41a73d5285368d19ac1ef17a7992bf13a352817c Mon Sep 17 00:00:00 2001 From: Nick Wellnhofer Date: Tue, 18 Nov 2014 18:20:49 +0100 Subject: Make render_html support nodes with no children For empty inline nodes like EMPH, the parser always creates a child containing an empty string. Using the tree manipulation API, nodes with no children can be created. Adjust render_html to cope. --- src/html/html.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/html') diff --git a/src/html/html.c b/src/html/html.c index 11db0de..8110f87 100644 --- a/src/html/html.c +++ b/src/html/html.c @@ -152,11 +152,11 @@ static void inlines_to_plain_html(strbuf *html, cmark_node* ils) // Convert an inline list to HTML. Returns 0 on success, and sets result. static void inlines_to_html(strbuf *html, cmark_node* ils) { - cmark_node* children; + bool visit_children; render_stack* rstack = NULL; while(ils != NULL) { - children = NULL; + visit_children = false; switch(ils->type) { case NODE_STRING: escape_html(html, ils->as.literal.data, ils->as.literal.len); @@ -193,7 +193,7 @@ static void inlines_to_html(strbuf *html, cmark_node* ils) } strbuf_puts(html, "\">"); - children = ils->first_child; + visit_children = true; rstack = push_inline(rstack, ils->next, ""); break; @@ -215,20 +215,20 @@ static void inlines_to_html(strbuf *html, cmark_node* ils) case NODE_STRONG: strbuf_puts(html, ""); - children = ils->first_child; + visit_children = true; rstack = push_inline(rstack, ils->next, ""); break; case NODE_EMPH: strbuf_puts(html, ""); - children = ils->first_child; + visit_children = true; rstack = push_inline(rstack, ils->next, ""); break; default: break; } - if (children) { - ils = children; + if (visit_children) { + ils = ils->first_child; } else { ils = ils->next; } -- cgit v1.2.3