diff options
-rw-r--r-- | src/scanners.c | 60 | ||||
-rw-r--r-- | src/scanners.re | 2 | ||||
-rw-r--r-- | test/regression.txt | 24 | ||||
-rw-r--r-- | test/spec.txt | 53 |
4 files changed, 79 insertions, 60 deletions
diff --git a/src/scanners.c b/src/scanners.c index 709a74e..466d302 100644 --- 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 index 9e9999c..07396f3 100644 --- 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 index c8a1057..54872da 100644 --- 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> +```````````````````````````````` + diff --git a/test/spec.txt b/test/spec.txt index e2b6834..7d97e1e 100644 --- a/test/spec.txt +++ b/test/spec.txt @@ -1985,7 +1985,7 @@ by their start and end conditions. The block begins with a line that meets a [start condition](@) (after up to three spaces optional indentation). It ends with the first subsequent line that meets a matching [end condition](@), or the last line of -the document or other [container block](@), if no line is encountered that meets the +the document or other [container block]), if no line is encountered that meets the [end condition]. If the first line meets both the [start condition] and the [end condition], the block will contain just that line. @@ -2015,7 +2015,8 @@ followed by one of the strings (case-insensitive) `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`, +`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`, `summary`, `table`, `tbody`, `td`, @@ -4730,8 +4731,7 @@ takes four spaces (a common case), but diverge in other cases. A [list](@) is a sequence of one or more list items [of the same type]. The list items -may be separated by single [blank lines], but two -blank lines end all containing lists. +may be separated by any number of blank lines. Two list items are [of the same type](@) if they begin with a [list marker] of the same type. @@ -4809,10 +4809,11 @@ Foo `Markdown.pl` does not allow this, through fear of triggering a list via a numeral in a hard-wrapped line: -```````````````````````````````` markdown +``` markdown The number of windows in my house is 14. The number of doors is 6. -```````````````````````````````` +``` + Oddly, though, `Markdown.pl` *does* allow a blockquote to interrupt a paragraph, even though the same considerations might apply. @@ -4821,10 +4822,12 @@ In CommonMark, we do allow lists to interrupt paragraphs, for two reasons. First, it is natural and not uncommon for people to start lists without blank lines: - I need to buy - - new shoes - - a coat - - a plane ticket +``` markdown +I need to buy +- new shoes +- a coat +- a plane ticket +``` Second, we are attracted to a @@ -4836,20 +4839,24 @@ Second, we are attracted to a (Indeed, the spec for [list items] and [block quotes] presupposes this principle.) This principle implies that if - * I need to buy - - new shoes - - a coat - - a plane ticket +``` markdown + * I need to buy + - new shoes + - a coat + - a plane ticket +``` is a list item containing a paragraph followed by a nested sublist, as all Markdown implementations agree it is (though the paragraph may be rendered without `<p>` tags, since the list is "tight"), then - I need to buy - - new shoes - - a coat - - a plane ticket +``` markdown +I need to buy +- new shoes +- a coat +- a plane ticket +``` by itself should be a paragraph followed by a nested sublist. @@ -6558,7 +6565,7 @@ Note that in the preceding case, the interpretation is precluded by the condition that a delimiter that -can both open and close (like the `*` after `foo` +can both open and close (like the `*` after `foo`) cannot form emphasis if the sum of the lengths of the delimiter runs containing the opening and closing delimiters is a multiple of 3. @@ -6590,12 +6597,6 @@ omitted: ```````````````````````````````` -```````````````````````````````` example -*foo**bar*** -. -<p><em>foo<strong>bar</strong></em></p> -```````````````````````````````` - Indefinite levels of nesting are possible: ```````````````````````````````` example @@ -9045,7 +9046,7 @@ blocks. But we cannot close unmatched blocks yet, because we may have a [lazy continuation line]. 2. Next, after consuming the continuation markers for existing -blocks, we look for new block starts (e.g. `>` for a block quote. +blocks, we look for new block starts (e.g. `>` for a block quote). If we encounter a new block start, we close any blocks unmatched in step 1 before creating the new block as a child of the last matched block. |