Skip to content

Commit

Permalink
Merge pull request #579 from Jamedjo/html5-details
Browse files Browse the repository at this point in the history
Added support for html5 details and summary tags
  • Loading branch information
robin850 committed Oct 15, 2016
2 parents e3a1d0b + 5412f7e commit e8d0958
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 70 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog

* Added suppport for html5 details & summary tags

Fix issue [#578](https://github.com/vmg/redcarpet/issues/578).

*James Edwards-Jones*

* Multiple single quote pairs are parsed correctly with SmartyPants.

Fix issue [#549](https://github.com/vmg/redcarpet/issues/549).
Expand Down
138 changes: 68 additions & 70 deletions ext/redcarpet/html_blocks.h
@@ -1,6 +1,6 @@
/* C code produced by gperf version 3.0.4 */
/* C code produced by gperf version 3.0.3 */
/* Command-line: gperf -N find_block_tag -H hash_block_tag -C -c -E --ignore-case html_block_names.txt */
/* See http://git.io/RN0ncw for the list of recognized elements */
/* See https://git.io/vPLqa for the list of recognized elements */
/* Computed positions: -k'1-2' */

#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
Expand Down Expand Up @@ -30,7 +30,7 @@
error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
#endif

/* maximum key range = 67, duplicates = 0 */
/* maximum key range = 72, duplicates = 0 */

#ifndef GPERF_DOWNCASE
#define GPERF_DOWNCASE 1
Expand Down Expand Up @@ -94,34 +94,34 @@ hash_block_tag (str, len)
{
static const unsigned char asso_values[] =
{
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
55, 50, 45, 40, 35, 30, 68, 68, 68, 68,
68, 68, 68, 68, 68, 15, 10, 15, 15, 15,
0, 20, 10, 10, 5, 68, 68, 0, 20, 25,
0, 68, 68, 0, 25, 0, 15, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 15, 10, 15,
15, 15, 0, 20, 10, 10, 5, 68, 68, 0,
20, 25, 0, 68, 68, 0, 25, 0, 15, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
68, 68, 68, 68, 68, 68, 68
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
26, 60, 55, 45, 40, 35, 73, 73, 73, 73,
73, 73, 73, 73, 73, 20, 15, 15, 0, 35,
0, 25, 10, 10, 5, 73, 73, 0, 15, 15,
0, 73, 73, 15, 20, 10, 10, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 20, 15, 15,
0, 35, 0, 25, 10, 10, 5, 73, 73, 0,
15, 15, 0, 73, 73, 15, 20, 10, 10, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
73, 73, 73, 73, 73, 73, 73
};
register int hval = len;
register unsigned int hval = len;

switch (hval)
{
Expand All @@ -135,89 +135,87 @@ hash_block_tag (str, len)
return hval;
}

#ifdef __GNUC__
__inline
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const char *
find_block_tag (str, len)
register const char *str;
register unsigned int len;
{
enum
{
TOTAL_KEYWORDS = 41,
TOTAL_KEYWORDS = 43,
MIN_WORD_LENGTH = 1,
MAX_WORD_LENGTH = 10,
MIN_HASH_VALUE = 1,
MAX_HASH_VALUE = 67
MAX_HASH_VALUE = 72
};

static const char * const wordlist[] =
{
"",
"p",
"ul",
"pre",
"dl",
"del",
"form",
"style",
"",
"footer",
"section",
"", "", "",
"details",
"div",
"", "",
"figure",
"hr",
"ul",
"fieldset",
"math",
"",
"figcaption",
"header",
"dl",
"del",
"",
"blockquote",
"ol",
"pre",
"math",
"video",
"script",
"article",
"div",
"section",
"noscript",
"",
"video",
"blockquote",
"hgroup",
"ol",
"noscript",
"", "",
"hr",
"ins",
"",
"style",
"output",
"summary",
"nav",
"",
"audio",
"canvas",
"dd",
"nav",
"h1",
"abbr",
"audio",
"iframe",
"address",
"ins",
"",
"table",
"",
"h6",
"iframe",
"article",
"", "",
"aside",
"output",
"h5",
"",
"h6",
"", "",
"tfoot",
"",
"h5",
"", "", "", "",
"h4",
"", "", "", "",
"h3",
"address",
"", "", "", "",
"h2",
"h3",
"", "", "", "",
"h1"
"h2"
};

if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = hash_block_tag (str, len);
unsigned int key = hash_block_tag (str, len);

if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key];

Expand Down
12 changes: 12 additions & 0 deletions test/html5_test.rb
Expand Up @@ -67,4 +67,16 @@ def test_script_tag_recognition

assert_renders html, html
end

def test_new_html5_tags_not_escaped
details = <<-HTML.chomp.strip_heredoc
<details>
log:
</details>
HTML

assert_renders details, details
end

end

0 comments on commit e8d0958

Please sign in to comment.