diff --git a/src/html.c b/src/html.c
@@ -178,10 +178,13 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
case CMARK_NODE_CUSTOM_BLOCK:
cr(html);
- cmark_strbuf_put(
- html, (const unsigned char *)(entering ? cmark_node_get_on_enter(node)
- : cmark_node_get_on_exit(node)),
- node->as.literal.len);
+ if (entering) {
+ cmark_strbuf_put(html, node->as.custom.on_enter.data,
+ node->as.custom.on_enter.len);
+ } else {
+ cmark_strbuf_put(html, node->as.custom.on_exit.data,
+ node->as.custom.on_exit.len);
+ }
cr(html);
break;
@@ -243,10 +246,13 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
break;
case CMARK_NODE_CUSTOM_INLINE:
- cmark_strbuf_put(
- html, (const unsigned char *)(entering ? cmark_node_get_on_enter(node)
- : cmark_node_get_on_exit(node)),
- node->as.literal.len);
+ if (entering) {
+ cmark_strbuf_put(html, node->as.custom.on_enter.data,
+ node->as.custom.on_enter.len);
+ } else {
+ cmark_strbuf_put(html, node->as.custom.on_exit.data,
+ node->as.custom.on_exit.len);
+ }
break;
case CMARK_NODE_STRONG: