cmark

My personal build of CMark ✏️

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

Rename hrule -> thematic_break.

CMARK_NODE_HRULE -> CMARK_NODE_THEMATIC_BREAK.

However we've defined the former as the latter to keep backwards compatibility.

See jgm/CommonMark 8fa94cb460f5e516b0e57adca33f50a669d51f6c

Diffstat

13 files changed, 25 insertions, 23 deletions

Status File Name N° Changes Insertions Deletions
Modified api_test/main.c 6 3 3
Modified man/man3/cmark.3 2 1 1
Modified src/blocks.c 6 3 3
Modified src/cmark.h 8 5 3
Modified src/commonmark.c 2 1 1
Modified src/html.c 2 1 1
Modified src/iterator.c 2 1 1
Modified src/latex.c 2 1 1
Modified src/man.c 2 1 1
Modified src/node.c 4 2 2
Modified src/scanners.c 4 2 2
Modified src/scanners.h 4 2 2
Modified src/scanners.re 4 2 2
diff --git a/api_test/main.c b/api_test/main.c
@@ -20,7 +20,7 @@ static const cmark_node_type node_types[] = {
 	CMARK_NODE_HTML,
 	CMARK_NODE_PARAGRAPH,
 	CMARK_NODE_HEADING,
-	CMARK_NODE_HRULE,
+	CMARK_NODE_THEMATIC_BREAK,
 	CMARK_NODE_TEXT,
 	CMARK_NODE_SOFTBREAK,
 	CMARK_NODE_LINEBREAK,
@@ -516,7 +516,7 @@ hierarchy(test_batch_runner *runner)
 		(1 << CMARK_NODE_HTML) |
 		(1 << CMARK_NODE_PARAGRAPH) |
 		(1 << CMARK_NODE_HEADING) |
-		(1 << CMARK_NODE_HRULE);
+		(1 << CMARK_NODE_THEMATIC_BREAK);
 	int all_inlines =
 		(1 << CMARK_NODE_TEXT) |
 		(1 << CMARK_NODE_SOFTBREAK) |
@@ -536,7 +536,7 @@ hierarchy(test_batch_runner *runner)
 	test_content(runner, CMARK_NODE_HTML,          0);
 	test_content(runner, CMARK_NODE_PARAGRAPH,     all_inlines);
 	test_content(runner, CMARK_NODE_HEADING,        all_inlines);
-	test_content(runner, CMARK_NODE_HRULE,         0);
+	test_content(runner, CMARK_NODE_THEMATIC_BREAK,         0);
 	test_content(runner, CMARK_NODE_TEXT,	       0);
 	test_content(runner, CMARK_NODE_SOFTBREAK,     0);
 	test_content(runner, CMARK_NODE_LINEBREAK,     0);
diff --git a/man/man3/cmark.3 b/man/man3/cmark.3
@@ -112,7 +112,7 @@ are nodes of type:
 .IP \[bu] 2
 CMARK_NODE_HTML
 .IP \[bu] 2
-CMARK_NODE_HRULE
+CMARK_NODE_THEMATIC_BREAK
 .IP \[bu] 2
 CMARK_NODE_CODE_BLOCK
 .IP \[bu] 2
diff --git a/src/blocks.c b/src/blocks.c
@@ -812,10 +812,10 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
 
     } else if (!indented &&
                !(container->type == CMARK_NODE_PARAGRAPH && !all_matched) &&
-               (matched = scan_hrule(&input, parser->first_nonspace))) {
+               (matched = scan_thematic_break(&input, parser->first_nonspace))) {
 
       // it's only now that we know the line is not part of a setext heading:
-      container = add_child(parser, container, CMARK_NODE_HRULE,
+      container = add_child(parser, container, CMARK_NODE_THEMATIC_BREAK,
                             parser->first_nonspace + 1);
       S_advance_offset(parser, &input, input.len - 1 - parser->offset, false);
 
@@ -902,7 +902,7 @@ static void S_process_line(cmark_parser *parser, const unsigned char *buffer,
   container->last_line_blank =
       (parser->blank && container->type != CMARK_NODE_BLOCK_QUOTE &&
        container->type != CMARK_NODE_HEADING &&
-       container->type != CMARK_NODE_HRULE &&
+       container->type != CMARK_NODE_THEMATIC_BREAK &&
        !(container->type == CMARK_NODE_CODE_BLOCK &&
          container->as.code.fenced) &&
        !(container->type == CMARK_NODE_ITEM && container->first_child == NULL &&
diff --git a/src/cmark.h b/src/cmark.h
@@ -43,10 +43,10 @@ typedef enum {
   CMARK_NODE_CUSTOM_BLOCK,
   CMARK_NODE_PARAGRAPH,
   CMARK_NODE_HEADING,
-  CMARK_NODE_HRULE,
+  CMARK_NODE_THEMATIC_BREAK,
 
   CMARK_NODE_FIRST_BLOCK = CMARK_NODE_DOCUMENT,
-  CMARK_NODE_LAST_BLOCK = CMARK_NODE_HRULE,
+  CMARK_NODE_LAST_BLOCK = CMARK_NODE_THEMATIC_BREAK,
 
   /* Inline */
   CMARK_NODE_TEXT,
@@ -66,6 +66,7 @@ typedef enum {
 
 /* For backwards compatibility: */
 #define CMARK_NODE_HEADER CMARK_NODE_HEADING
+#define CMARK_NODE_HRULE CMARK_NODE_THEMATIC_BREAK
 
 typedef enum {
   CMARK_NO_LIST,
@@ -163,7 +164,7 @@ CMARK_EXPORT cmark_node *cmark_node_last_child(cmark_node *node);
  * of type:
  *
  * * CMARK_NODE_HTML
- * * CMARK_NODE_HRULE
+ * * CMARK_NODE_THEMATIC_BREAK
  * * CMARK_NODE_CODE_BLOCK
  * * CMARK_NODE_TEXT
  * * CMARK_NODE_SOFTBREAK
@@ -553,6 +554,7 @@ const char *cmark_version_string();
 #define NODE_PARAGRAPH CMARK_NODE_PARAGRAPH
 #define NODE_HEADING CMARK_NODE_HEADING
 #define NODE_HEADER CMARK_NODE_HEADER
+#define NODE_THEMATIC_BREAK CMARK_NODE_THEMATIC_BREAK
 #define NODE_HRULE CMARK_NODE_HRULE
 #define NODE_TEXT CMARK_NODE_TEXT
 #define NODE_SOFTBREAK CMARK_NODE_SOFTBREAK
diff --git a/src/commonmark.c b/src/commonmark.c
@@ -292,7 +292,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     BLANKLINE();
     break;
 
-  case CMARK_NODE_HRULE:
+  case CMARK_NODE_THEMATIC_BREAK:
     BLANKLINE();
     LIT("-----");
     BLANKLINE();
diff --git a/src/html.c b/src/html.c
@@ -188,7 +188,7 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type,
     cr(html);
     break;
 
-  case CMARK_NODE_HRULE:
+  case CMARK_NODE_THEMATIC_BREAK:
     cr(html);
     cmark_strbuf_puts(html, "<hr");
     S_render_sourcepos(node, html, options);
diff --git a/src/iterator.c b/src/iterator.c
@@ -7,7 +7,7 @@
 #include "iterator.h"
 
 static const int S_leaf_mask =
-    (1 << CMARK_NODE_HTML) | (1 << CMARK_NODE_HRULE) |
+    (1 << CMARK_NODE_HTML) | (1 << CMARK_NODE_THEMATIC_BREAK) |
     (1 << CMARK_NODE_CODE_BLOCK) | (1 << CMARK_NODE_TEXT) |
     (1 << CMARK_NODE_SOFTBREAK) | (1 << CMARK_NODE_LINEBREAK) |
     (1 << CMARK_NODE_CODE) | (1 << CMARK_NODE_INLINE_HTML);
diff --git a/src/latex.c b/src/latex.c
@@ -310,7 +310,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     CR();
     break;
 
-  case CMARK_NODE_HRULE:
+  case CMARK_NODE_THEMATIC_BREAK:
     BLANKLINE();
     LIT("\\begin{center}\\rule{0.5\\linewidth}{\\linethickness}\\end{center}");
     BLANKLINE();
diff --git a/src/man.c b/src/man.c
@@ -149,7 +149,7 @@ static int S_render_node(cmark_renderer *renderer, cmark_node *node,
     CR();
     break;
 
-  case CMARK_NODE_HRULE:
+  case CMARK_NODE_THEMATIC_BREAK:
     CR();
     LIT(".PP\n  *  *  *  *  *");
     CR();
diff --git a/src/node.c b/src/node.c
@@ -174,8 +174,8 @@ const char *cmark_node_get_type_string(cmark_node *node) {
     return "paragraph";
   case CMARK_NODE_HEADING:
     return "heading";
-  case CMARK_NODE_HRULE:
-    return "hrule";
+  case CMARK_NODE_THEMATIC_BREAK:
+    return "thematic_break";
   case CMARK_NODE_TEXT:
     return "text";
   case CMARK_NODE_SOFTBREAK:
diff --git a/src/scanners.c b/src/scanners.c
@@ -25495,10 +25495,10 @@ bufsize_t _scan_setext_heading_line(const unsigned char *p) {
   }
 }
 
-// Scan a horizontal rule line: "...three or more hyphens, asterisks,
+// Scan a thematic break line: "...three or more hyphens, asterisks,
 // or underscores on a line by themselves. If you wish, you may use
 // spaces between the hyphens or asterisks."
-bufsize_t _scan_hrule(const unsigned char *p) {
+bufsize_t _scan_thematic_break(const unsigned char *p) {
   const unsigned char *marker = NULL;
   const unsigned char *start = p;
 
diff --git a/src/scanners.h b/src/scanners.h
@@ -23,7 +23,7 @@ bufsize_t _scan_link_title(const unsigned char *p);
 bufsize_t _scan_spacechars(const unsigned char *p);
 bufsize_t _scan_atx_heading_start(const unsigned char *p);
 bufsize_t _scan_setext_heading_line(const unsigned char *p);
-bufsize_t _scan_hrule(const unsigned char *p);
+bufsize_t _scan_thematic_break(const unsigned char *p);
 bufsize_t _scan_open_code_fence(const unsigned char *p);
 bufsize_t _scan_close_code_fence(const unsigned char *p);
 bufsize_t _scan_entity(const unsigned char *p);
@@ -45,7 +45,7 @@ bufsize_t _scan_dangerous_url(const unsigned char *p);
 #define scan_spacechars(c, n) _scan_at(&_scan_spacechars, c, n)
 #define scan_atx_heading_start(c, n) _scan_at(&_scan_atx_heading_start, c, n)
 #define scan_setext_heading_line(c, n) _scan_at(&_scan_setext_heading_line, c, n)
-#define scan_hrule(c, n) _scan_at(&_scan_hrule, c, n)
+#define scan_thematic_break(c, n) _scan_at(&_scan_thematic_break, c, n)
 #define scan_open_code_fence(c, n) _scan_at(&_scan_open_code_fence, c, n)
 #define scan_close_code_fence(c, n) _scan_at(&_scan_close_code_fence, c, n)
 #define scan_entity(c, n) _scan_at(&_scan_entity, c, n)
diff --git a/src/scanners.re b/src/scanners.re
@@ -270,10 +270,10 @@ bufsize_t _scan_setext_heading_line(const unsigned char *p)
 */
 }
 
-// Scan a horizontal rule line: "...three or more hyphens, asterisks,
+// Scan a thematic break line: "...three or more hyphens, asterisks,
 // or underscores on a line by themselves. If you wish, you may use
 // spaces between the hyphens or asterisks."
-bufsize_t _scan_hrule(const unsigned char *p)
+bufsize_t _scan_thematic_break(const unsigned char *p)
 {
   const unsigned char *marker = NULL;
   const unsigned char *start = p;