Skip to content

Commit

Permalink
Allow non-initial hyphens in html tag names.
Browse files Browse the repository at this point in the history
This allows for custom tags, see commonmark/commonmark-spec#239.
  • Loading branch information
jgm committed Jul 11, 2015
1 parent 557566c commit 5f3fc4e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
45 changes: 26 additions & 19 deletions src/scanners.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -11222,19 +11222,20 @@ bufsize_t _scan_html_tag(const unsigned char *p)
{ 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 {
Expand Down Expand Up @@ -11993,18 +11994,19 @@ bufsize_t _scan_html_tag(const unsigned char *p)
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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -14222,13 +14224,18 @@ bufsize_t _scan_html_block_start_7(const unsigned char *p)
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/scanners.re
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 5f3fc4e

Please sign in to comment.