summaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/html.c b/src/html.c
index 1ccb57a..f719405 100644
--- a/src/html.c
+++ b/src/html.c
@@ -271,12 +271,18 @@ char *cmark_render_html(cmark_node *root)
{
char *result;
strbuf html = GH_BUF_INIT;
+ cmark_event_type ev_type;
+ cmark_node *cur;
struct render_state state = { &html, NULL };
- if (cmark_walk(root, S_render_node, &state)) {
- result = (char *)strbuf_detach(&html);
- strbuf_free(&html);
- return result;
- } else {
- return NULL;
+ cmark_iter *iter = cmark_iter_new(root);
+
+ while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
+ cur = cmark_iter_get_node(iter);
+ S_render_node(cur, ev_type, &state);
}
+ result = (char *)strbuf_detach(&html);
+
+ cmark_iter_free(iter);
+ strbuf_free(&html);
+ return result;
}