| 42 | } |
| 43 | |
| 44 | static int S_render_node(cmark_node *node, cmark_event_type ev_type, |
| 45 | struct render_state *state, int options) { |
| 46 | cmark_node *parent; |
| 47 | cmark_node *grandparent; |
| 48 | cmark_strbuf *html = state->html; |
| 49 | char start_heading[] = "<h0"; |
| 50 | char end_heading[] = "</h0"; |
| 51 | bool tight; |
| 52 | char buffer[BUFFER_SIZE]; |
| 53 | |
| 54 | bool entering = (ev_type == CMARK_EVENT_ENTER); |
| 55 | |
| 56 | if (state->plain == node) { // back at original node |
| 57 | state->plain = NULL; |
| 58 | } |
| 59 | |
| 60 | if (state->plain != NULL) { |
| 61 | switch (node->type) { |
| 62 | case CMARK_NODE_TEXT: |
| 63 | case CMARK_NODE_CODE: |
| 64 | case CMARK_NODE_HTML_INLINE: |
| 65 | escape_html(html, node->data, node->len); |
| 66 | break; |
| 67 | |
| 68 | case CMARK_NODE_LINEBREAK: |
| 69 | case CMARK_NODE_SOFTBREAK: |
| 70 | cmark_strbuf_putc(html, ' '); |
| 71 | break; |
| 72 | |
| 73 | default: |
| 74 | break; |
| 75 | } |
| 76 | return 1; |
| 77 | } |
| 78 | |
| 79 | switch (node->type) { |
| 80 | case CMARK_NODE_DOCUMENT: |
| 81 | break; |
| 82 | |
| 83 | case CMARK_NODE_BLOCK_QUOTE: |
| 84 | if (entering) { |
| 85 | cr(html); |
| 86 | cmark_strbuf_puts(html, "<blockquote"); |
| 87 | S_render_sourcepos(node, html, options); |
| 88 | cmark_strbuf_puts(html, ">\n"); |
| 89 | } else { |
| 90 | cr(html); |
| 91 | cmark_strbuf_puts(html, "</blockquote>\n"); |
| 92 | } |
| 93 | break; |
| 94 | |
| 95 | case CMARK_NODE_LIST: { |
| 96 | cmark_list_type list_type = (cmark_list_type)node->as.list.list_type; |
| 97 | int start = node->as.list.start; |
| 98 | |
| 99 | if (entering) { |
| 100 | cr(html); |
| 101 | if (list_type == CMARK_BULLET_LIST) { |
no test coverage detected