cmark

My personal build of CMark ✏️

Commit
4e3b2cf8af9872fb1bfc29bfa6b9d24b5c063ff1
Parent
6ba6d3374bf168a9a7fa106ad8428da96024d16f
Author
John MacFarlane <jgm@berkeley.edu>
Date

Allow non-initial hyphens in html tag names.

This allows for custom tags, see jgm/CommonMark#239.

Diffstat

2 files changed, 27 insertions, 20 deletions

Status File Name N° Changes Insertions Deletions
Modified src/scanners.c 45 26 19
Modified src/scanners.re 2 1 1
diff --git a/src/scanners.c b/src/scanners.c
@@ -11116,7 +11116,7 @@ bufsize_t _scan_html_tag(const unsigned char *p)
 		230, 230, 230, 230, 230, 230, 230, 230, 
 		230, 230, 230, 230, 230, 230, 230, 230, 
 		199, 230,  70, 230, 230, 230, 230, 134, 
-		230, 230, 230, 230, 230, 246, 246, 230, 
+		230, 230, 230, 230, 230, 254, 246, 230, 
 		254, 254, 254, 254, 254, 254, 254, 254, 
 		254, 254, 246, 230, 198, 198, 196, 230, 
 		230, 254, 254, 254, 254, 254, 254, 254, 
@@ -11222,19 +11222,20 @@ yy1261:
 	{ return 0; }
 yy1262:
 	yych = *(marker = ++p);
-	if (yych <= '9') {
-		if (yych <= 0x1F) {
+	if (yych <= '/') {
+		if (yych <= ' ') {
 			if (yych <= 0x08) goto yy1261;
 			if (yych <= '\r') goto yy1366;
-			goto yy1261;
+			if (yych <= 0x1F) goto yy1261;
+			goto yy1366;
 		} else {
-			if (yych <= ' ') goto yy1366;
+			if (yych == '-') goto yy1364;
 			if (yych <= '.') goto yy1261;
-			if (yych <= '/') goto yy1368;
-			goto yy1364;
+			goto yy1368;
 		}
 	} else {
 		if (yych <= '@') {
+			if (yych <= '9') goto yy1364;
 			if (yych == '>') goto yy1285;
 			goto yy1261;
 		} else {
@@ -11993,18 +11994,19 @@ yy1362:
 yy1364:
 	++p;
 	yych = *p;
-	if (yych <= '9') {
-		if (yych <= 0x1F) {
+	if (yych <= '/') {
+		if (yych <= ' ') {
 			if (yych <= 0x08) goto yy1268;
-			if (yych >= 0x0E) goto yy1268;
+			if (yych <= '\r') goto yy1366;
+			if (yych <= 0x1F) goto yy1268;
 		} else {
-			if (yych <= ' ') goto yy1366;
+			if (yych == '-') goto yy1364;
 			if (yych <= '.') goto yy1268;
-			if (yych <= '/') goto yy1368;
-			goto yy1364;
+			goto yy1368;
 		}
 	} else {
 		if (yych <= '@') {
+			if (yych <= '9') goto yy1364;
 			if (yych == '>') goto yy1285;
 			goto yy1268;
 		} else {
@@ -14084,7 +14086,7 @@ bufsize_t _scan_html_block_start_7(const unsigned char *p)
 		224, 224, 224, 224, 224, 224, 224, 224, 
 		224, 224, 224, 224, 224, 224, 224, 224, 
 		198, 224,  64, 224, 224, 224, 224, 128, 
-		224, 224, 224, 224, 224, 240, 240, 224, 
+		224, 224, 224, 224, 224, 241, 240, 224, 
 		241, 241, 241, 241, 241, 241, 241, 241, 
 		241, 241, 240, 224, 192, 192, 192, 224, 
 		224, 241, 241, 241, 241, 241, 241, 241, 
@@ -14222,13 +14224,18 @@ yy1641:
 	if (yybm[0+yych] & 2) {
 		goto yy1643;
 	}
-	if (yych <= '>') {
-		if (yych <= '/') goto yy1631;
-		if (yych <= '9') goto yy1641;
-		if (yych <= '=') goto yy1631;
-		goto yy1645;
+	if (yych <= '=') {
+		if (yych <= '-') {
+			if (yych <= ',') goto yy1631;
+			goto yy1641;
+		} else {
+			if (yych <= '/') goto yy1631;
+			if (yych <= '9') goto yy1641;
+			goto yy1631;
+		}
 	} else {
 		if (yych <= 'Z') {
+			if (yych <= '>') goto yy1645;
 			if (yych <= '@') goto yy1631;
 			goto yy1641;
 		} else {
diff --git a/src/scanners.re b/src/scanners.re
@@ -30,7 +30,7 @@ bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c, 
 
   escaped_char = [\\][!"#$%&'()*+,./:;<=>?@[\\\]^_`{|}~-];
 
-  tagname = [A-Za-z][A-Za-z0-9]*;
+  tagname = [A-Za-z][A-Za-z0-9-]*;
 
   blocktagname = 'address'|'article'|'aside'|'base'|'basefont'|'blockquote'|'body'|'caption'|'center'|'col'|'colgroup'|'dd'|'details'|'dialog'|'dir'|'div'|'dl'|'dt'|'fieldset'|'figcaption'|'figure'|'footer'|'form'|'frame'|'frameset'|'h1'|'head'|'header'|'hr'|'html'|'legend'|'li'|'link'|'main'|'menu'|'menuitem'|'meta'|'nav'|'noframes'|'ol'|'optgroup'|'option'|'p'|'param'|'pre'|'section'|'source'|'title'|'summary'|'table'|'tbody'|'td'|'tfoot'|'th'|'thead'|'title'|'tr'|'track'|'ul';