summaryrefslogtreecommitdiff
path: root/src/html/html.c
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2014-11-23 07:08:57 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2014-11-23 07:08:57 -0800
commit1b6a4ce8ab921ddc98581abd395428e2cadd0c22 (patch)
tree51cf1a80b7d48351ec1c17046e5cae3d86baa18d /src/html/html.c
parent8ba087276c6cae9e1efde656ae973b4f714c88be (diff)
Do not distinguish btw fenced and indented code in AST.
Use a single CMARK_NODE_CODE_BLOCK tag for both. Distinguish them when needed for parsing by looking at the fence_length attribute, which is 0 for indented blocks.
Diffstat (limited to 'src/html/html.c')
-rw-r--r--src/html/html.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/html/html.c b/src/html/html.c
index e6971f8..27d1f0e 100644
--- a/src/html/html.c
+++ b/src/html/html.c
@@ -88,6 +88,7 @@ static void node_to_html(strbuf *html, cmark_node *node)
char start_header[] = "<h0>";
bool tight = false;
bool visit_children;
+ strbuf *info;
if (node == NULL) {
return;
@@ -155,12 +156,11 @@ static void node_to_html(strbuf *html, cmark_node *node)
strbuf_puts(html, start_header);
break;
- case NODE_INDENTED_CODE:
- case NODE_FENCED_CODE: {
- strbuf *info = &cur->as.code.info;
+ case NODE_CODE_BLOCK:
+ info = &cur->as.code.info;
cr(html);
- if (cur->type != NODE_FENCED_CODE
+ if (&cur->as.code.fence_length == 0
|| strbuf_len(info) == 0) {
strbuf_puts(html, "<pre><code>");
}
@@ -177,7 +177,6 @@ static void node_to_html(strbuf *html, cmark_node *node)
escape_html(html, cur->string_content.ptr, cur->string_content.size);
break;
- }
case NODE_HTML:
cr(html);
@@ -320,8 +319,7 @@ finish_node(strbuf *html, cmark_node *node, bool tight)
strbuf_puts(html, end_header);
break;
- case NODE_INDENTED_CODE:
- case NODE_FENCED_CODE:
+ case NODE_CODE_BLOCK:
strbuf_puts(html, "</code></pre>\n");
break;