From 1b6a4ce8ab921ddc98581abd395428e2cadd0c22 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 23 Nov 2014 07:08:57 -0800 Subject: 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. --- src/html/html.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/html') 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[] = ""; 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, "
");
 			}
@@ -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, "
\n"); break; -- cgit v1.2.3