cmark

My personal build of CMark ✏️

Commit
a5a55657ad8c1da1e17eda8e0a321612e61c311e
Parent
e31e2d2fe1d28223eee9f406b82d6f48552f5be7
Author
John MacFarlane <fiddlosopher@gmail.com>
Date

Rename NODE_STRING -> NODE_TEXT.

In JS, use 'Text' instead of 'Str'.

In spec, use "plain textual content" instead of "strings."

Diffstat

9 files changed, 31 insertions, 31 deletions

Status File Name N° Changes Insertions Deletions
Modified api_test/main.c 12 6 6
Modified js/lib/html-renderer.js 2 1 1
Modified js/lib/inlines.js 20 10 10
Modified spec.txt 4 2 2
Modified src/cmark.h 6 3 3
Modified src/html/html.c 4 2 2
Modified src/inlines.c 2 1 1
Modified src/node.c 8 4 4
Modified src/print.c 4 2 2
diff --git a/api_test/main.c b/api_test/main.c
@@ -21,7 +21,7 @@ static const cmark_node_type node_types[] = {
 	CMARK_NODE_HEADER,
 	CMARK_NODE_HRULE,
 	CMARK_NODE_REFERENCE_DEF,
-	CMARK_NODE_STRING,
+	CMARK_NODE_TEXT,
 	CMARK_NODE_SOFTBREAK,
 	CMARK_NODE_LINEBREAK,
 	CMARK_NODE_INLINE_CODE,
@@ -306,17 +306,17 @@ create_tree(test_batch_runner *runner)
 	OK(runner, cmark_node_prepend_child(p, emph), "prepend1");
 	INT_EQ(runner, cmark_node_check(doc, NULL), 0, "prepend1 consistent");
 
-	cmark_node *str1 = cmark_node_new(CMARK_NODE_STRING);
+	cmark_node *str1 = cmark_node_new(CMARK_NODE_TEXT);
 	cmark_node_set_string_content(str1, "Hello, ");
 	OK(runner, cmark_node_prepend_child(p, str1), "prepend2");
 	INT_EQ(runner, cmark_node_check(doc, NULL), 0, "prepend2 consistent");
 
-	cmark_node *str3 = cmark_node_new(CMARK_NODE_STRING);
+	cmark_node *str3 = cmark_node_new(CMARK_NODE_TEXT);
 	cmark_node_set_string_content(str3, "!");
 	OK(runner, cmark_node_append_child(p, str3), "append2");
 	INT_EQ(runner, cmark_node_check(doc, NULL), 0, "append2 consistent");
 
-	cmark_node *str2 = cmark_node_new(CMARK_NODE_STRING);
+	cmark_node *str2 = cmark_node_new(CMARK_NODE_TEXT);
 	cmark_node_set_string_content(str2, "world");
 	OK(runner, cmark_node_append_child(emph, str2), "append3");
 	INT_EQ(runner, cmark_node_check(doc, NULL), 0, "append3 consistent");
@@ -397,7 +397,7 @@ hierarchy(test_batch_runner *runner)
 		(1 << CMARK_NODE_HRULE) |
 		(1 << CMARK_NODE_REFERENCE_DEF);
 	int all_inlines =
-		(1 << CMARK_NODE_STRING) |
+		(1 << CMARK_NODE_TEXT) |
 		(1 << CMARK_NODE_SOFTBREAK) |
 		(1 << CMARK_NODE_LINEBREAK) |
 		(1 << CMARK_NODE_INLINE_CODE) |
@@ -417,7 +417,7 @@ hierarchy(test_batch_runner *runner)
 	test_content(runner, CMARK_NODE_HEADER,        all_inlines);
 	test_content(runner, CMARK_NODE_HRULE,         0);
 	test_content(runner, CMARK_NODE_REFERENCE_DEF, 0);
-	test_content(runner, CMARK_NODE_STRING,        0);
+	test_content(runner, CMARK_NODE_TEXT,	       0);
 	test_content(runner, CMARK_NODE_SOFTBREAK,     0);
 	test_content(runner, CMARK_NODE_LINEBREAK,     0);
 	test_content(runner, CMARK_NODE_INLINE_CODE,   0);
diff --git a/js/lib/html-renderer.js b/js/lib/html-renderer.js
@@ -23,7 +23,7 @@ var inTags = function(tag, attribs, contents, selfclosing) {
 var renderInline = function(inline) {
     var attrs;
     switch (inline.t) {
-    case 'Str':
+    case 'Text':
         return this.escape(inline.c);
     case 'Softbreak':
         return this.softbreak;
diff --git a/js/lib/inlines.js b/js/lib/inlines.js
@@ -149,7 +149,7 @@ var parseBackticks = function(inlines) {
     }
     // If we got here, we didn't match a closing backtick sequence.
     this.pos = afterOpenTicks;
-    inlines.push({ t: 'Str', c: ticks });
+    inlines.push({ t: 'Text', c: ticks });
     return true;
 };
 
@@ -165,10 +165,10 @@ var parseBackslash = function(inlines) {
             inlines.push({ t: 'Hardbreak' });
         } else if (reEscapable.test(subj.charAt(pos + 1))) {
             this.pos = this.pos + 2;
-            inlines.push({ t: 'Str', c: subj.charAt(pos + 1) });
+            inlines.push({ t: 'Text', c: subj.charAt(pos + 1) });
         } else {
             this.pos++;
-            inlines.push({t: 'Str', c: '\\'});
+            inlines.push({t: 'Text', c: '\\'});
         }
         return true;
     } else {
@@ -184,14 +184,14 @@ var parseAutolink = function(inlines) {
         dest = m.slice(1,-1);
         inlines.push(
                 {t: 'Link',
-                 label: [{ t: 'Str', c: dest }],
+                 label: [{ t: 'Text', c: dest }],
                  destination: 'mailto:' + encodeURI(unescape(dest)) });
         return true;
     } else if ((m = this.match(/^<(?:coap|doi|javascript|aaa|aaas|about|acap|cap|cid|crid|data|dav|dict|dns|file|ftp|geo|go|gopher|h323|http|https|iax|icap|im|imap|info|ipp|iris|iris.beep|iris.xpc|iris.xpcs|iris.lwz|ldap|mailto|mid|msrp|msrps|mtqp|mupdate|news|nfs|ni|nih|nntp|opaquelocktoken|pop|pres|rtsp|service|session|shttp|sieve|sip|sips|sms|snmp|soap.beep|soap.beeps|tag|tel|telnet|tftp|thismessage|tn3270|tip|tv|urn|vemmi|ws|wss|xcon|xcon-userid|xmlrpc.beep|xmlrpc.beeps|xmpp|z39.50r|z39.50s|adiumxtra|afp|afs|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|chrome|chrome-extension|com-eventbrite-attendee|content|cvs|dlna-playsingle|dlna-playcontainer|dtn|dvb|ed2k|facetime|feed|finger|fish|gg|git|gizmoproject|gtalk|hcp|icon|ipn|irc|irc6|ircs|itms|jar|jms|keyparc|lastfm|ldaps|magnet|maps|market|message|mms|ms-help|msnim|mumble|mvn|notes|oid|palm|paparazzi|platform|proxy|psyc|query|res|resource|rmi|rsync|rtmp|secondlife|sftp|sgn|skype|smb|soldat|spotify|ssh|steam|svn|teamspeak|things|udp|unreal|ut2004|ventrilo|view-source|webcal|wtai|wyciwyg|xfire|xri|ymsgr):[^<>\x00-\x20]*>/i))) {
         dest = m.slice(1,-1);
         inlines.push({
                   t: 'Link',
-                  label: [{ t: 'Str', c: dest }],
+                  label: [{ t: 'Text', c: dest }],
                   destination: encodeURI(unescape(dest)) });
         return true;
     } else {
@@ -256,7 +256,7 @@ var Strong = function(ils) {
 };
 
 var Str = function(s) {
-    return {t: 'Str', c: s};
+    return {t: 'Text', c: s};
 };
 
 // Attempt to parse emphasis or strong emphasis.
@@ -638,7 +638,7 @@ var parseCloseBracket = function(inlines) {
 var parseEntity = function(inlines) {
     var m;
     if ((m = this.match(reEntityHere))) {
-        inlines.push({ t: 'Str', c: entityToChar(m) });
+        inlines.push({ t: 'Text', c: entityToChar(m) });
         return true;
     } else {
         return false;
@@ -650,7 +650,7 @@ var parseEntity = function(inlines) {
 var parseString = function(inlines) {
     var m;
     if ((m = this.match(reMain))) {
-        inlines.push({ t: 'Str', c: m });
+        inlines.push({ t: 'Text', c: m });
         return true;
     } else {
         return false;
@@ -681,7 +681,7 @@ var parseImage = function(inlines) {
             inlines[inlines.length - 1].t = 'Image';
             return true;
         } else {
-            inlines.push({ t: 'Str', c: '!' });
+            inlines.push({ t: 'Text', c: '!' });
             return true;
         }
     } else {
@@ -797,7 +797,7 @@ var parseInline = function(inlines) {
     }
     if (!res) {
         this.pos += 1;
-        inlines.push({t: 'Str', c: fromCodePoint(c)});
+        inlines.push({t: 'Text', c: fromCodePoint(c)});
     }
 
     return true;
diff --git a/spec.txt b/spec.txt
@@ -6755,10 +6755,10 @@ line break or as a space.
 A renderer may also provide an option to render soft line breaks
 as hard line breaks.
 
-## Strings
+## Textual content
 
 Any characters not given an interpretation by the above rules will
-be parsed as string content.
+be parsed as plain textual content.
 
 .
 hello $.;'there
diff --git a/src/cmark.h b/src/cmark.h
@@ -27,7 +27,7 @@ typedef enum {
     CMARK_NODE_LAST_BLOCK  = CMARK_NODE_REFERENCE_DEF,
 
     // Inline
-    CMARK_NODE_STRING,
+    CMARK_NODE_TEXT,
     CMARK_NODE_SOFTBREAK,
     CMARK_NODE_LINEBREAK,
     CMARK_NODE_INLINE_CODE,
@@ -37,7 +37,7 @@ typedef enum {
     CMARK_NODE_LINK,
     CMARK_NODE_IMAGE,
 
-    CMARK_NODE_FIRST_INLINE = CMARK_NODE_STRING,
+    CMARK_NODE_FIRST_INLINE = CMARK_NODE_TEXT,
     CMARK_NODE_LAST_INLINE  = CMARK_NODE_IMAGE,
 } cmark_node_type;
 
@@ -204,7 +204,7 @@ char *cmark_markdown_to_html(const char *text, int len);
   #define NODE_HEADER		    CMARK_NODE_HEADER
   #define NODE_HRULE                CMARK_NODE_HRULE
   #define NODE_REFERENCE_DEF        CMARK_NODE_REFERENCE_DEF
-  #define NODE_STRING               CMARK_NODE_STRING
+  #define NODE_TEXT                 CMARK_NODE_TEXT
   #define NODE_SOFTBREAK            CMARK_NODE_SOFTBREAK
   #define NODE_LINEBREAK            CMARK_NODE_LINEBREAK
   #define NODE_INLINE_CODE          CMARK_NODE_INLINE_CODE
diff --git a/src/html/html.c b/src/html/html.c
@@ -47,7 +47,7 @@ static void inlines_to_plain_html(strbuf *html, cmark_node* node)
 
 	while (true) {
 		switch(cur->type) {
-		case NODE_STRING:
+		case NODE_TEXT:
 		case NODE_INLINE_CODE:
 		case NODE_INLINE_HTML:
 			escape_html(html, cur->as.literal.data, cur->as.literal.len);
@@ -191,7 +191,7 @@ static void node_to_html(strbuf *html, cmark_node *node)
 		case NODE_REFERENCE_DEF:
 			break;
 
-		case NODE_STRING:
+		case NODE_TEXT:
 			escape_html(html, cur->as.literal.data, cur->as.literal.len);
 			break;
 
diff --git a/src/inlines.c b/src/inlines.c
@@ -15,7 +15,7 @@
 
 
 // Macros for creating various kinds of simple.
-#define make_str(s) make_literal(CMARK_NODE_STRING, s)
+#define make_str(s) make_literal(CMARK_NODE_TEXT, s)
 #define make_code(s) make_literal(CMARK_NODE_INLINE_CODE, s)
 #define make_raw_html(s) make_literal(CMARK_NODE_INLINE_HTML, s)
 #define make_linebreak() make_simple(CMARK_NODE_LINEBREAK)
diff --git a/src/node.c b/src/node.c
@@ -59,7 +59,7 @@ S_type_string(cmark_node *node)
 	case CMARK_NODE_HEADER:	       return "HEADER";
 	case CMARK_NODE_HRULE:         return "HRULE";
 	case CMARK_NODE_REFERENCE_DEF: return "REFERENCE_DEF";
-	case CMARK_NODE_STRING:        return "STRING";
+	case CMARK_NODE_TEXT:          return "TEXT";
 	case CMARK_NODE_SOFTBREAK:     return "SOFTBREAK";
 	case CMARK_NODE_LINEBREAK:     return "LINEBREAK";
 	case CMARK_NODE_INLINE_CODE:   return "INLINE_CODE";
@@ -118,7 +118,7 @@ cmark_node_get_string_content(cmark_node *node) {
 	case NODE_HTML:
 		return cmark_strbuf_cstr(&node->string_content);
 
-	case NODE_STRING:
+	case NODE_TEXT:
 	case NODE_INLINE_HTML:
 	case NODE_INLINE_CODE:
 		return cmark_chunk_to_cstr(&node->as.literal);
@@ -138,7 +138,7 @@ cmark_node_set_string_content(cmark_node *node, const char *content) {
 		cmark_strbuf_sets(&node->string_content, content);
 		return 1;
 
-	case NODE_STRING:
+	case NODE_TEXT:
 	case NODE_INLINE_HTML:
 	case NODE_INLINE_CODE:
 		cmark_chunk_set_cstr(&node->as.literal, content);
@@ -622,7 +622,7 @@ void cmark_free_nodes(cmark_node *e)
 		case NODE_CODE_BLOCK:
 			strbuf_free(&e->as.code.info);
 			break;
-		case NODE_STRING:
+		case NODE_TEXT:
 		case NODE_INLINE_HTML:
 		case NODE_INLINE_CODE:
 			cmark_chunk_free(&e->as.literal);
diff --git a/src/print.c b/src/print.c
@@ -43,8 +43,8 @@ static void print_inlines(cmark_node* ils, int indent)
 			putchar(' ');
 		}
 		switch(ils->type) {
-		case NODE_STRING:
-			printf("str ");
+		case NODE_TEXT:
+			printf("text ");
 			print_str(ils->as.literal.data, ils->as.literal.len);
 			putchar('\n');
 			break;