cmark

My personal build of CMark ✏️

Commit
de6c5fb2c45dfa2791074f7d99a27b23b2106dfc
Parent
a74295a1ea686611498a75dd45597d224ce99287
Author
John MacFarlane <jgm@berkeley.edu>
Date

CMARK_NODE_HEADER -> CMARK_NODE_HEADING.

Defined CMARK_NODE_HEADER to CMARK_NODE_HEADING to ease the transition.

Diffstat

9 files changed, 27 insertions, 23 deletions

Status File Name N° Changes Insertions Deletions
Modified api_test/main.c 8 4 4
Modified src/blocks.c 16 8 8
Modified src/cmark.h 6 5 1
Modified src/commonmark.c 2 1 1
Modified src/html.c 2 1 1
Modified src/latex.c 2 1 1
Modified src/man.c 2 1 1
Modified src/node.c 10 5 5
Modified src/xml.c 2 1 1
diff --git a/api_test/main.c b/api_test/main.c
@@ -19,7 +19,7 @@ static const cmark_node_type node_types[] = {
 	CMARK_NODE_CODE_BLOCK,
 	CMARK_NODE_HTML,
 	CMARK_NODE_PARAGRAPH,
-	CMARK_NODE_HEADER,
+	CMARK_NODE_HEADING,
 	CMARK_NODE_HRULE,
 	CMARK_NODE_TEXT,
 	CMARK_NODE_SOFTBREAK,
@@ -71,7 +71,7 @@ constructor(test_batch_runner *runner)
 		       "get_type %d", type);
 
 		switch (node->type) {
-		case CMARK_NODE_HEADER:
+		case CMARK_NODE_HEADING:
 			INT_EQ(runner, cmark_node_get_heading_level(node), 1,
 			       "default heading level is 1");
 			node->as.heading.level = 1;
@@ -515,7 +515,7 @@ hierarchy(test_batch_runner *runner)
 		(1 << CMARK_NODE_CODE_BLOCK) |
 		(1 << CMARK_NODE_HTML) |
 		(1 << CMARK_NODE_PARAGRAPH) |
-		(1 << CMARK_NODE_HEADER) |
+		(1 << CMARK_NODE_HEADING) |
 		(1 << CMARK_NODE_HRULE);
 	int all_inlines =
 		(1 << CMARK_NODE_TEXT) |
@@ -535,7 +535,7 @@ hierarchy(test_batch_runner *runner)
 	test_content(runner, CMARK_NODE_CODE_BLOCK ,   0);
 	test_content(runner, CMARK_NODE_HTML,          0);
 	test_content(runner, CMARK_NODE_PARAGRAPH,     all_inlines);
-	test_content(runner, CMARK_NODE_HEADER,        all_inlines);
+	test_content(runner, CMARK_NODE_HEADING,        all_inlines);
 	test_content(runner, CMARK_NODE_HRULE,         0);
 	test_content(runner, CMARK_NODE_TEXT,	       0);
 	test_content(runner, CMARK_NODE_SOFTBREAK,     0);
diff --git a/src/blocks.c b/src/blocks.c
@@ -120,7 +120,7 @@ static inline bool can_contain(cmark_node_type parent_type,
 
 static inline bool accepts_lines(cmark_node_type block_type) {
   return (block_type == CMARK_NODE_PARAGRAPH ||
-          block_type == CMARK_NODE_HEADER ||
+          block_type == CMARK_NODE_HEADING ||
           block_type == CMARK_NODE_CODE_BLOCK);
 }
 
@@ -208,7 +208,7 @@ static cmark_node *finalize(cmark_parser *parser, cmark_node *b) {
     b->end_column = parser->last_line_length;
   } else if (b->type == CMARK_NODE_DOCUMENT ||
              (b->type == CMARK_NODE_CODE_BLOCK && b->as.code.fenced) ||
-             (b->type == CMARK_NODE_HEADER && b->as.heading.setext)) {
+             (b->type == CMARK_NODE_HEADING && b->as.heading.setext)) {
     b->end_line = parser->line_number;
     b->end_column = parser->curline->size;
     if (b->end_column && parser->curline->ptr[b->end_column - 1] == '\n')
@@ -336,7 +336,7 @@ static void process_inlines(cmark_node *root, cmark_reference_map *refmap,
   while ((ev_type = cmark_iter_next(iter)) != CMARK_EVENT_DONE) {
     cur = cmark_iter_get_node(iter);
     if (ev_type == CMARK_EVENT_ENTER) {
-      if (cur->type == CMARK_NODE_PARAGRAPH || cur->type == CMARK_NODE_HEADER) {
+      if (cur->type == CMARK_NODE_PARAGRAPH || cur->type == CMARK_NODE_HEADING) {
         cmark_parse_inlines(cur, refmap, options);
       }
     }
@@ -685,7 +685,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
           }
         }
       }
-    } else if (container->type == CMARK_NODE_HEADER) {
+    } else if (container->type == CMARK_NODE_HEADING) {
 
       // a heading can never contain more than one line
       all_matched = false;
@@ -757,7 +757,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
                        parser->first_nonspace + matched - parser->offset,
                        false);
       container =
-          add_child(parser, container, CMARK_NODE_HEADER, parser->offset + 1);
+          add_child(parser, container, CMARK_NODE_HEADING, parser->offset + 1);
 
       bufsize_t hashpos =
           cmark_chunk_strchr(&input, '#', parser->first_nonspace);
@@ -805,7 +805,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
                     &container->string_content, '\n',
                     cmark_strbuf_len(&container->string_content) - 2) < 0)) {
 
-      container->type = CMARK_NODE_HEADER;
+      container->type = CMARK_NODE_HEADING;
       container->as.heading.level = lev;
       container->as.heading.setext = true;
       S_advance_offset(parser, &input, input.len - 1 - parser->offset, false);
@@ -901,7 +901,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
   // on an empty list item.
   container->last_line_blank =
       (parser->blank && container->type != CMARK_NODE_BLOCK_QUOTE &&
-       container->type != CMARK_NODE_HEADER &&
+       container->type != CMARK_NODE_HEADING &&
        container->type != CMARK_NODE_HRULE &&
        !(container->type == CMARK_NODE_CODE_BLOCK &&
          container->as.code.fenced) &&
@@ -980,7 +980,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
 
     } else if (accepts_lines(container->type)) {
 
-      if (container->type == CMARK_NODE_HEADER &&
+      if (container->type == CMARK_NODE_HEADING &&
           container->as.heading.setext == false) {
         chop_trailing_hashtags(&input);
       }
diff --git a/src/cmark.h b/src/cmark.h
@@ -42,7 +42,7 @@ typedef enum {
   CMARK_NODE_HTML,
   CMARK_NODE_CUSTOM_BLOCK,
   CMARK_NODE_PARAGRAPH,
-  CMARK_NODE_HEADER,
+  CMARK_NODE_HEADING,
   CMARK_NODE_HRULE,
 
   CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
@@ -64,6 +64,9 @@ typedef enum {
   CMARK_NODE_LAST_INLINE = CMARK_NODE_IMAGE,
 } cmark_node_type;
 
+/* For backwards compatibility: */
+#define CMARK_NODE_HEADER CMARK_NODE_HEADING
+
 typedef enum {
   CMARK_NO_LIST,
   CMARK_BULLET_LIST,
@@ -548,6 +551,7 @@ const char *cmark_version_string();
 #define NODE_HTML CMARK_NODE_HTML
 #define NODE_CUSTOM_BLOCK CMARK_NODE_CUSTOM_BLOCK
 #define NODE_PARAGRAPH CMARK_NODE_PARAGRAPH
+#define NODE_HEADING CMARK_NODE_HEADING
 #define NODE_HEADER CMARK_NODE_HEADER
 #define NODE_HRULE CMARK_NODE_HRULE
 #define NODE_TEXT CMARK_NODE_TEXT
diff --git a/src/commonmark.c b/src/commonmark.c
@@ -228,7 +228,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     }
     break;
 
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     if (entering) {
       for (i = cmark_node_get_heading_level(node); i > 0; i--) {
         LIT("#");
diff --git a/src/html.c b/src/html.c
@@ -127,7 +127,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
     }
     break;
 
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     if (entering) {
       cr(html);
       start_heading[2] = (char)('0' + node->as.heading.level);
diff --git a/src/latex.c b/src/latex.c
@@ -264,7 +264,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     }
     break;
 
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     if (entering) {
       switch (cmark_node_get_heading_level(node)) {
       case 1:
diff --git a/src/man.c b/src/man.c
@@ -120,7 +120,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     }
     break;
 
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     if (entering) {
       CR();
       LIT(cmark_node_get_heading_level(node) == 1 ? ".SH" : ".SS");
diff --git a/src/node.c b/src/node.c
@@ -53,7 +53,7 @@ static bool S_can_contain(cmark_node *node, cmark_node *child) {
     return child->type == CMARK_NODE_ITEM;
 
   case CMARK_NODE_PARAGRAPH:
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
   case CMARK_NODE_EMPH:
   case CMARK_NODE_STRONG:
   case CMARK_NODE_LINK:
@@ -73,7 +73,7 @@ cmark_node *cmark_node_new(cmark_node_type type) {
   node->type = type;
 
   switch (node->type) {
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     node->as.heading.level = 1;
     break;
 
@@ -172,7 +172,7 @@ const char *cmark_node_get_type_string(cmark_node *node) {
     return "raw_block";
   case CMARK_NODE_PARAGRAPH:
     return "paragraph";
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     return "heading";
   case CMARK_NODE_HRULE:
     return "hrule";
@@ -309,7 +309,7 @@ int cmark_node_get_heading_level(cmark_node *node) {
   }
 
   switch (node->type) {
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     return node->as.heading.level;
 
   default:
@@ -325,7 +325,7 @@ int cmark_node_set_heading_level(cmark_node *node, int level) {
   }
 
   switch (node->type) {
-  case CMARK_NODE_HEADER:
+  case CMARK_NODE_HEADING:
     node->as.heading.level = level;
     return 1;
 
diff --git a/src/xml.c b/src/xml.c
@@ -86,7 +86,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
               (cmark_node_get_list_tight(node) ? "true" : "false"));
       cmark_strbuf_puts(xml, buffer);
       break;
-    case CMARK_NODE_HEADER:
+    case CMARK_NODE_HEADING:
       sprintf(buffer, " level=\"%d\"", node->as.heading.level);
       cmark_strbuf_puts(xml, buffer);
       break;