From b0a6c472f881a3e0a7b61722fb6fddbcc39e5139 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 19 Dec 2015 21:15:43 -0800 Subject: Changed API for CUSTOM_BLOCK and CUSTOM_INLINE. Instead of using their `as.literal` content, we now give each custom node *two* literal fields, one to be printed on entering the node (before rendering the children, if any), the other on exiting (after rendering children). This gives us the flexibility to have custom nodes with children. --- src/commonmark.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/commonmark.c') diff --git a/src/commonmark.c b/src/commonmark.c index 4fbe9fd..635794c 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -280,9 +280,13 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, break; case CMARK_NODE_HTML: + OUT(cmark_node_get_literal(node), false, LITERAL); + break; + case CMARK_NODE_CUSTOM_BLOCK: BLANKLINE(); - OUT(cmark_node_get_literal(node), false, LITERAL); + OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node), + false, LITERAL); BLANKLINE(); break; @@ -337,10 +341,14 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node, break; case CMARK_NODE_INLINE_HTML: - case CMARK_NODE_CUSTOM_INLINE: OUT(cmark_node_get_literal(node), false, LITERAL); break; + case CMARK_NODE_CUSTOM_INLINE: + OUT(entering ? cmark_node_get_on_enter(node) : cmark_node_get_on_exit(node), + false, LITERAL); + break; + case CMARK_NODE_STRONG: if (entering) { LIT("**"); -- cgit v1.2.3