cmark

My personal build of CMark ✏️

Commit
dd1c58355f69a5fb3ab6fc90a32f48c8a9913176
Parent
b50a2cd618802543e01f46bffb4b19d5bd5b4ba6
Author
John MacFarlane <jgm@berkeley.edu>
Date

Rename CMARK_NODE_LIST_ITEM -> CMARK_NODE_ITEM.

Diffstat

8 files changed, 21 insertions, 21 deletions

Status File Name N° Changes Insertions Deletions
Modified CommonMark.dtd 4 2 2
Modified api_test/main.c 6 3 3
Modified src/blocks.c 12 6 6
Modified src/cmark.h 4 2 2
Modified src/html.c 2 1 1
Modified src/man.c 4 2 2
Modified src/node.c 8 4 4
Modified src/print.c 2 1 1
diff --git a/CommonMark.dtd b/CommonMark.dtd
@@ -3,13 +3,13 @@
 (block_quote|list|code_block|html|paragraph|header|hrule)*>
 <!ELEMENT block_quote
 (block_quote|list|code_block|html|paragraph|header|hrule)*>
-<!ELEMENT list (list_item)+>
+<!ELEMENT list (item)+>
 <!ATTLIST list
           type (bullet|ordered) #REQUIRED
           start CDATA #IMPLIED
           tight (true|false) #REQUIRED
           delimiter (period|paren) #IMPLIED>
-<!ELEMENT list_item
+<!ELEMENT item
 (block_quote|list|code_block|html|paragraph|header|hrule)*>
 <!ELEMENT code_block (#PCDATA)>
 <!ATTLIST code_block
diff --git a/api_test/main.c b/api_test/main.c
@@ -17,7 +17,7 @@ static const cmark_node_type node_types[] = {
 	CMARK_NODE_DOCUMENT,
 	CMARK_NODE_BLOCK_QUOTE,
 	CMARK_NODE_LIST,
-	CMARK_NODE_LIST_ITEM,
+	CMARK_NODE_ITEM,
 	CMARK_NODE_CODE_BLOCK,
 	CMARK_NODE_HTML,
 	CMARK_NODE_PARAGRAPH,
@@ -413,7 +413,7 @@ hierarchy(test_batch_runner *runner)
 			    ? CMARK_NODE_LAST_BLOCK : CMARK_NODE_LAST_INLINE;
 	OK(runner, max_node_type < 32, "all node types < 32");
 
-	int list_item_flag = 1 << CMARK_NODE_LIST_ITEM;
+	int list_item_flag = 1 << CMARK_NODE_ITEM;
 	int top_level_blocks =
 		(1 << CMARK_NODE_BLOCK_QUOTE) |
 		(1 << CMARK_NODE_LIST) |
@@ -436,7 +436,7 @@ hierarchy(test_batch_runner *runner)
 	test_content(runner, CMARK_NODE_DOCUMENT,      top_level_blocks);
 	test_content(runner, CMARK_NODE_BLOCK_QUOTE,   top_level_blocks);
 	test_content(runner, CMARK_NODE_LIST,          list_item_flag);
-	test_content(runner, CMARK_NODE_LIST_ITEM,     top_level_blocks);
+	test_content(runner, CMARK_NODE_ITEM,          top_level_blocks);
 	test_content(runner, CMARK_NODE_CODE_BLOCK ,   0);
 	test_content(runner, CMARK_NODE_HTML,          0);
 	test_content(runner, CMARK_NODE_PARAGRAPH,     all_inlines);
diff --git a/src/blocks.c b/src/blocks.c
@@ -104,8 +104,8 @@ static inline bool can_contain(cmark_node_type parent_type, cmark_node_type chil
 {
 	return ( parent_type == NODE_DOCUMENT ||
 			parent_type == NODE_BLOCK_QUOTE ||
-			parent_type == NODE_LIST_ITEM ||
-			(parent_type == NODE_LIST && child_type == NODE_LIST_ITEM) );
+			parent_type == NODE_ITEM ||
+			(parent_type == NODE_LIST && child_type == NODE_ITEM) );
 }
 
 static inline bool accepts_lines(cmark_node_type block_type)
@@ -149,7 +149,7 @@ static bool ends_with_blank_line(cmark_node* cmark_node)
 	if (cmark_node->last_line_blank) {
 		return true;
 	}
-	if ((cmark_node->type == NODE_LIST || cmark_node->type == NODE_LIST_ITEM) && cmark_node->last_child) {
+	if ((cmark_node->type == NODE_LIST || cmark_node->type == NODE_ITEM) && cmark_node->last_child) {
 		return ends_with_blank_line(cmark_node->last_child);
 	} else {
 		return false;
@@ -558,7 +558,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 				all_matched = false;
 			}
 
-		} else if (container->type == NODE_LIST_ITEM) {
+		} else if (container->type == NODE_ITEM) {
 
 			if (indent >= container->as.list.marker_offset +
 					container->as.list.padding) {
@@ -741,7 +741,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 			}
 
 			// add the list item
-			container = add_child(parser, container, NODE_LIST_ITEM, parser->line_number,
+			container = add_child(parser, container, NODE_ITEM, parser->line_number,
 					first_nonspace + 1);
 			/* TODO: static */
 			memcpy(&container->as.list, data, sizeof(*data));
@@ -775,7 +775,7 @@ S_process_line(cmark_parser *parser, const unsigned char *buffer, size_t bytes)
 			container->type != NODE_HEADER &&
 			!(container->type == NODE_CODE_BLOCK &&
 				container->as.code.fenced) &&
-			!(container->type == NODE_LIST_ITEM &&
+			!(container->type == NODE_ITEM &&
 				container->first_child == NULL &&
 				container->start_line == parser->line_number));
 
diff --git a/src/cmark.h b/src/cmark.h
@@ -40,7 +40,7 @@ typedef enum {
 	CMARK_NODE_DOCUMENT,
 	CMARK_NODE_BLOCK_QUOTE,
 	CMARK_NODE_LIST,
-	CMARK_NODE_LIST_ITEM,
+	CMARK_NODE_ITEM,
 	CMARK_NODE_CODE_BLOCK,
 	CMARK_NODE_HTML,
 	CMARK_NODE_PARAGRAPH,
@@ -426,7 +426,7 @@ char *cmark_render_man(cmark_node *root);
   #define NODE_DOCUMENT             CMARK_NODE_DOCUMENT
   #define NODE_BLOCK_QUOTE          CMARK_NODE_BLOCK_QUOTE
   #define NODE_LIST                 CMARK_NODE_LIST
-  #define NODE_LIST_ITEM            CMARK_NODE_LIST_ITEM
+  #define NODE_ITEM                 CMARK_NODE_ITEM
   #define NODE_CODE_BLOCK           CMARK_NODE_CODE_BLOCK
   #define NODE_HTML                 CMARK_NODE_HTML
   #define NODE_PARAGRAPH            CMARK_NODE_PARAGRAPH
diff --git a/src/html.c b/src/html.c
@@ -113,7 +113,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		break;
 	}
 
-	case CMARK_NODE_LIST_ITEM:
+	case CMARK_NODE_ITEM:
 		if (entering) {
 			cr(html);
 			cmark_strbuf_puts(html, "<li>");
diff --git a/src/man.c b/src/man.c
@@ -93,7 +93,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 	case CMARK_NODE_LIST:
 		break;
 
-	case CMARK_NODE_LIST_ITEM:
+	case CMARK_NODE_ITEM:
 		if (entering) {
 			cr(man);
 			cmark_strbuf_puts(man, ".IP ");
@@ -150,7 +150,7 @@ S_render_node(cmark_node *node, cmark_event_type ev_type, void *vstate)
 		if (entering) {
 			// no blank line if first paragraph in list:
 			if (node->parent &&
-			    node->parent->type == CMARK_NODE_LIST_ITEM &&
+			    node->parent->type == CMARK_NODE_ITEM &&
 			    node->prev == NULL) {
 				// no blank line or .PP
 			} else {
diff --git a/src/node.c b/src/node.c
@@ -98,7 +98,7 @@ cmark_node_get_type_string(cmark_node *node)
 	case CMARK_NODE_DOCUMENT:      return "document";
 	case CMARK_NODE_BLOCK_QUOTE:   return "block_quote";
 	case CMARK_NODE_LIST:          return "list";
-	case CMARK_NODE_LIST_ITEM:     return "list_item";
+	case CMARK_NODE_ITEM:          return "item";
 	case CMARK_NODE_CODE_BLOCK:    return "code_block";
 	case CMARK_NODE_HTML:          return "html";
 	case CMARK_NODE_PARAGRAPH:     return "paragraph";
@@ -518,12 +518,12 @@ S_can_contain(cmark_node *node, cmark_node *child)
 	switch (node->type) {
 	case CMARK_NODE_DOCUMENT:
 	case CMARK_NODE_BLOCK_QUOTE:
-	case CMARK_NODE_LIST_ITEM:
+	case CMARK_NODE_ITEM:
 		return S_is_block(child)
-		       && child->type != CMARK_NODE_LIST_ITEM;
+		       && child->type != CMARK_NODE_ITEM;
 
 	case CMARK_NODE_LIST:
-		return child->type == CMARK_NODE_LIST_ITEM;
+		return child->type == CMARK_NODE_ITEM;
 
 	case CMARK_NODE_PARAGRAPH:
 	case CMARK_NODE_HEADER:
diff --git a/src/print.c b/src/print.c
@@ -51,7 +51,7 @@ static void render_nodes(cmark_strbuf* buffer, cmark_node* node, int indent)
 		case NODE_BLOCK_QUOTE:
 			cmark_strbuf_printf(buffer, "block_quote\n");
 			break;
-		case NODE_LIST_ITEM:
+		case NODE_ITEM:
 			cmark_strbuf_printf(buffer, "list_item\n");
 			break;
 		case NODE_LIST: