summaryrefslogtreecommitdiff
path: root/src/html.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-12-14 14:03:08 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-12-14 14:03:57 -0800
commite9e4fa11de887c3e558310d3ef3bc6215510f6f4 (patch)
treef96b463213727d0f477a82eae73066ac1fff43ef /src/html.c
parent37554bbb7901b7116e1a5006f331968444141b76 (diff)
Use chunk for fenced code info, instead of strbuf.
Diffstat (limited to 'src/html.c')
-rw-r--r--src/html.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/html.c b/src/html.c
index 23812df..34552bf 100644
--- a/src/html.c
+++ b/src/html.c
@@ -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, "\">");
}