From 4570eb2bff2e1b71fa5b6408abbc69c98ff5ff24 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 22 Nov 2014 22:39:26 -0800 Subject: Revert "Remove distinction btw atx and setext header in AST." This reverts commit a71423f6ee1b77d9f79d42599ea00b4ca99f5da0. Not quite sure about this change, so reverting for now. Note that we still have a distinction between fenced and indented code blocks in the AST. These two distinctions seem to stand or fall together. --- src/blocks.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/blocks.c') diff --git a/src/blocks.c b/src/blocks.c index 57f6756..2a6cdd8 100644 --- a/src/blocks.c +++ b/src/blocks.c @@ -97,9 +97,9 @@ static inline bool can_contain(cmark_node_type parent_type, cmark_node_type chil static inline bool accepts_lines(cmark_node_type block_type) { return (block_type == NODE_PARAGRAPH || - block_type == NODE_HEADER || - block_type == NODE_INDENTED_CODE || - block_type == NODE_FENCED_CODE); + block_type == NODE_ATX_HEADER || + block_type == NODE_INDENTED_CODE || + block_type == NODE_FENCED_CODE); } static void add_line(cmark_node* cmark_node, chunk *ch, int offset) @@ -293,7 +293,8 @@ static void process_inlines(cmark_node* cur, reference_map *refmap) while (cur != NULL) { switch (cur->type) { case NODE_PARAGRAPH: - case NODE_HEADER: + case NODE_ATX_HEADER: + case NODE_SETEXT_HEADER: parse_inlines(cur, refmap); break; @@ -547,7 +548,8 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer, all_matched = false; } - } else if (container->type == NODE_HEADER) { + } else if (container->type == NODE_ATX_HEADER || + container->type == NODE_SETEXT_HEADER) { // a header can never contain more than one line all_matched = false; @@ -623,7 +625,7 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer, } else if ((matched = scan_atx_header_start(&input, first_nonspace))) { offset = first_nonspace + matched; - container = add_child(parser, container, NODE_HEADER, parser->line_number, offset + 1); + container = add_child(parser, container, NODE_ATX_HEADER, parser->line_number, offset + 1); int hashpos = chunk_strchr(&input, '#', first_nonspace); int level = 0; @@ -653,7 +655,7 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer, strbuf_strrchr(&container->string_content, '\n', strbuf_len(&container->string_content) - 2) < 0) { - container->type = NODE_HEADER; + container->type = NODE_SETEXT_HEADER; container->as.header.level = lev; offset = input.len - 1; @@ -730,7 +732,7 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer, // on an empty list item. container->last_line_blank = (blank && container->type != NODE_BLOCK_QUOTE && - container->type != NODE_HEADER && + container->type != NODE_SETEXT_HEADER && container->type != NODE_FENCED_CODE && !(container->type == NODE_LIST_ITEM && container->first_child == NULL && @@ -789,7 +791,7 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer, // ??? do nothing - } else if (container->type == NODE_HEADER) { + } else if (container->type == NODE_ATX_HEADER) { chop_trailing_hashtags(&input); add_line(container, &input, first_nonspace); @@ -800,8 +802,7 @@ void cmark_process_line(cmark_doc_parser *parser, const char *buffer, add_line(container, &input, first_nonspace); - } else if (container->type != NODE_HRULE && - container->type != NODE_HEADER) { + } else if (container->type != NODE_HRULE && container->type != NODE_SETEXT_HEADER) { // create paragraph container for line container = add_child(parser, container, NODE_PARAGRAPH, parser->line_number, first_nonspace + 1); -- cgit v1.2.3