diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-12-14 14:03:08 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-12-14 14:03:57 -0800 |
commit | e9e4fa11de887c3e558310d3ef3bc6215510f6f4 (patch) | |
tree | f96b463213727d0f477a82eae73066ac1fff43ef /src/html.c | |
parent | 37554bbb7901b7116e1a5006f331968444141b76 (diff) |
Use chunk for fenced code info, instead of strbuf.
Diffstat (limited to 'src/html.c')
-rw-r--r-- | src/html.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -47,7 +47,6 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate) strbuf *html = state->html; char start_header[] = "<h0>"; char end_header[] = "</h0>"; - strbuf *info; bool tight; bool entering = (ev_type == CMARK_EVENT_ENTER); @@ -136,20 +135,21 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate) break; case CMARK_NODE_CODE_BLOCK: - info = &node->as.code.info; cr(html); if (&node->as.code.fence_length == 0 - || strbuf_len(info) == 0) { + || node->as.code.info.len == 0) { strbuf_puts(html, "<pre><code>"); } else { - int first_tag = strbuf_strchr(info, ' ', 0); - if (first_tag < 0) - first_tag = strbuf_len(info); + int first_tag = 0; + while (first_tag < node->as.code.info.len && + node->as.code.info.data[first_tag] != ' ') { + first_tag += 1; + } strbuf_puts(html, "<pre><code class=\"language-"); - escape_html(html, info->ptr, first_tag); + escape_html(html, node->as.code.info.data, first_tag); strbuf_puts(html, "\">"); } |