diff options
Diffstat (limited to 'src/html.c')
-rw-r--r-- | src/html.c | 46 |
1 files changed, 34 insertions, 12 deletions
@@ -44,8 +44,8 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, cmark_node *parent; cmark_node *grandparent; cmark_strbuf *html = state->html; - char start_header[] = "<h0"; - char end_header[] = "</h0"; + char start_heading[] = "<h0"; + char end_heading[] = "</h0"; bool tight; const size_t BUFFER_SIZE = 100; char buffer[BUFFER_SIZE]; @@ -60,7 +60,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, switch (node->type) { case CMARK_NODE_TEXT: case CMARK_NODE_CODE: - case CMARK_NODE_INLINE_HTML: + case CMARK_NODE_HTML_INLINE: escape_html(html, node->as.literal.data, node->as.literal.len); break; @@ -129,16 +129,16 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, } break; - case CMARK_NODE_HEADER: + case CMARK_NODE_HEADING: if (entering) { cr(html); - start_header[2] = (char)('0' + node->as.header.level); - cmark_strbuf_puts(html, start_header); + start_heading[2] = (char)('0' + node->as.heading.level); + cmark_strbuf_puts(html, start_heading); S_render_sourcepos(node, html, options); cmark_strbuf_putc(html, '>'); } else { - end_header[3] = (char)('0' + node->as.header.level); - cmark_strbuf_puts(html, end_header); + end_heading[3] = (char)('0' + node->as.heading.level); + cmark_strbuf_puts(html, end_heading); cmark_strbuf_puts(html, ">\n"); } break; @@ -146,7 +146,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, case CMARK_NODE_CODE_BLOCK: cr(html); - if (!node->as.code.fenced || node->as.code.info.len == 0) { + if (node->as.code.info.len == 0) { cmark_strbuf_puts(html, "<pre"); S_render_sourcepos(node, html, options); cmark_strbuf_puts(html, "><code>"); @@ -168,7 +168,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, cmark_strbuf_puts(html, "</code></pre>\n"); break; - case CMARK_NODE_HTML: + case CMARK_NODE_HTML_BLOCK: cr(html); if (options & CMARK_OPT_SAFE) { cmark_strbuf_puts(html, "<!-- raw HTML omitted -->"); @@ -178,7 +178,19 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, cr(html); break; - case CMARK_NODE_HRULE: + case CMARK_NODE_CUSTOM_BLOCK: + cr(html); + 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; + + case CMARK_NODE_THEMATIC_BREAK: cr(html); cmark_strbuf_puts(html, "<hr"); S_render_sourcepos(node, html, options); @@ -227,7 +239,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, cmark_strbuf_puts(html, "</code>"); break; - case CMARK_NODE_INLINE_HTML: + case CMARK_NODE_HTML_INLINE: if (options & CMARK_OPT_SAFE) { cmark_strbuf_puts(html, "<!-- raw HTML omitted -->"); } else { @@ -235,6 +247,16 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, } break; + case CMARK_NODE_CUSTOM_INLINE: + 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: if (entering) { cmark_strbuf_puts(html, "<strong>"); |