aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Wellnhofer <wellnhofer@aevum.de>2014-11-18 18:20:49 +0100
committerNick Wellnhofer <wellnhofer@aevum.de>2014-11-18 18:43:04 +0100
commit41a73d5285368d19ac1ef17a7992bf13a352817c (patch)
treec9d1efd1d994e535a3eaeb36644b4e2b1cd10cb0 /src
parent2dcef8aa960623eb84fe32d2b8e71881591a91cb (diff)
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.
Diffstat (limited to 'src')
-rw-r--r--src/html/html.c14
1 files changed, 7 insertions, 7 deletions
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, "</a>");
break;
@@ -215,20 +215,20 @@ static void inlines_to_html(strbuf *html, cmark_node* ils)
case NODE_STRONG:
strbuf_puts(html, "<strong>");
- children = ils->first_child;
+ visit_children = true;
rstack = push_inline(rstack, ils->next, "</strong>");
break;
case NODE_EMPH:
strbuf_puts(html, "<em>");
- children = ils->first_child;
+ visit_children = true;
rstack = push_inline(rstack, ils->next, "</em>");
break;
default:
break;
}
- if (children) {
- ils = children;
+ if (visit_children) {
+ ils = ils->first_child;
} else {
ils = ils->next;
}