cmark

Unnamed repository; edit this file 'description' to name the repository.

commit fae6a253d2f0c79eb34b0bf83ca484c93484f5a5
parent dc2d831c7d256ea98d3ad4d6b738525618aab99d
Author: John MacFarlane <jgm@berkeley.edu>
Date:   Mon, 12 Sep 2016 15:40:46 +0200

Fixed h2..h6 HTML blocks (jgm/CommonMark#430).

Added regression test.

Diffstat:
Msrc/scanners.c | 60+++++++++++++++++++++++++++---------------------------------
Msrc/scanners.re | 2+-
Mtest/regression.txt | 24++++++++++++++++++++++++
3 files changed, 52 insertions(+), 34 deletions(-)
diff --git a/src/scanners.c b/src/scanners.c
@@ -1,7 +1,7 @@
 /* Generated by re2c 0.15.3 */
-#include <stdlib.h>
-#include "chunk.h"
 #include "scanners.h"
+#include "chunk.h"
+#include <stdlib.h>
 
 bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c,
                    bufsize_t offset) {
@@ -8258,45 +8258,37 @@ bufsize_t _scan_html_tag(const unsigned char *p) {
     unsigned char yych;
     static const unsigned char yybm[] = {
         /* table 1 .. 8: 0 */
-        0,   230, 230, 230, 230, 230, 230, 230, 230, 199, 199, 199, 199, 199,
+        0, 230, 230, 230, 230, 230, 230, 230, 230, 199, 199, 199, 199, 199, 230,
         230, 230, 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, 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,
+        230, 230, 230, 199, 230, 70, 230, 230, 230, 230, 134, 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, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
-        254, 254, 254, 254, 254, 254, 254, 230, 230, 226, 230, 246, 198, 254,
+        254, 254, 254, 254, 254, 254, 230, 230, 226, 230, 246, 198, 254, 254,
         254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254,
-        254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 230, 230, 230,
-        230, 230, 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,
+        254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 230, 230, 230, 230,
+        230, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
         /* table 9 .. 11: 256 */
-        0,   160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
+        0, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
         160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
         160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
-        160, 160, 160, 32,  160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
-        160, 160, 160, 160, 160, 160, 160, 128, 160, 224, 224, 224, 224, 224,
+        160, 160, 32, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
+        160, 160, 160, 160, 160, 160, 128, 160, 224, 224, 224, 224, 224, 224,
         224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224, 224,
-        224, 224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 160, 160, 160,
+        224, 224, 224, 224, 224, 224, 160, 160, 160, 160, 160, 160, 160, 160,
         160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
         160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
-        160, 160, 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
-        0,   0,   0,   0,
+        160, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
     };
     yych = *(marker = p);
     if (yych <= '`') {
@@ -10582,7 +10574,9 @@ bufsize_t _scan_html_block_start(const unsigned char *p) {
     yych = *++p;
     if (yych <= 'S') {
       if (yych <= 'D') {
-        if (yych == '1')
+        if (yych <= '0')
+          goto yy525;
+        if (yych <= '6')
           goto yy564;
         goto yy525;
       } else {
diff --git a/src/scanners.re b/src/scanners.re
@@ -37,7 +37,7 @@ bufsize_t _scan_at(bufsize_t (*scanner)(const unsigned char *), cmark_chunk *c, 
 
   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'|'iframe'|'legend'|'li'|'link'|'main'|'menu'|'menuitem'|'meta'|'nav'|'noframes'|'ol'|'optgroup'|'option'|'p'|'param'|'section'|'source'|'title'|'summary'|'table'|'tbody'|'td'|'tfoot'|'th'|'thead'|'title'|'tr'|'track'|'ul';
+  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'|'h2'|'h3'|'h4'|'h5'|'h6'|'head'|'header'|'hr'|'html'|'iframe'|'legend'|'li'|'link'|'main'|'menu'|'menuitem'|'meta'|'nav'|'noframes'|'ol'|'optgroup'|'option'|'p'|'param'|'section'|'source'|'title'|'summary'|'table'|'tbody'|'td'|'tfoot'|'th'|'thead'|'title'|'tr'|'track'|'ul';
 
   attributename = [a-zA-Z_:][a-zA-Z0-9:._-]*;
 
diff --git a/test/regression.txt b/test/regression.txt
@@ -32,3 +32,27 @@ Repeatedly solving
 <li>how techniques</li>
 </ul>
 ````````````````````````````````
+
+Issue jgm/CommonMark#430:  h2..h6 not recognized as block tags.
+
+```````````````````````````````` example
+<h1>lorem</h1>
+
+<h2>lorem</h2>
+
+<h3>lorem</h3>
+
+<h4>lorem</h4>
+
+<h5>lorem</h5>
+
+<h6>lorem</h6>
+.
+<h1>lorem</h1>
+<h2>lorem</h2>
+<h3>lorem</h3>
+<h4>lorem</h4>
+<h5>lorem</h5>
+<h6>lorem</h6>
+````````````````````````````````
+