redcarpet 3.3.2 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
1
23
  #ifndef HOUDINI_H__
2
24
  #define HOUDINI_H__
3
25
 
@@ -1,3 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
1
23
  #include <assert.h>
2
24
  #include <stdio.h>
3
25
  #include <string.h>
@@ -22,10 +44,10 @@
22
44
  * have its native function (i.e. as an URL
23
45
  * component/separator) and hence needs no escaping.
24
46
  *
25
- * There are two exceptions: the chacters & (amp)
26
- * and ' (single quote) do not appear in the table.
27
- * They are meant to appear in the URL as components,
28
- * yet they require special HTML-entity escaping
47
+ * There is one exception: the ' (single quote)
48
+ * character does not appear in the table.
49
+ * It is meant to appear in the URL as components,
50
+ * however it require special HTML-entity escaping
29
51
  * to generate valid HTML markup.
30
52
  *
31
53
  * All other characters will be escaped to %XX.
@@ -34,7 +56,7 @@
34
56
  static const char HREF_SAFE[] = {
35
57
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36
58
  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
37
- 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
59
+ 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1,
38
60
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1,
39
61
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
40
62
  1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1,
@@ -73,12 +95,6 @@ houdini_escape_href(struct buf *ob, const uint8_t *src, size_t size)
73
95
  break;
74
96
 
75
97
  switch (src[i]) {
76
- /* amp appears all the time in URLs, but needs
77
- * HTML-entity escaping to be inside an href */
78
- case '&':
79
- BUFPUTSL(ob, "&amp;");
80
- break;
81
-
82
98
  /* the single quote is a valid URL character
83
99
  * according to the standard; it needs HTML
84
100
  * entity escaping too */
@@ -1,3 +1,25 @@
1
+ /*
2
+ * Copyright (c) 2015, Vicent Marti
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
21
+ */
22
+
1
23
  #include <assert.h>
2
24
  #include <stdio.h>
3
25
  #include <string.h>
@@ -80,4 +102,3 @@ houdini_escape_html(struct buf *ob, const uint8_t *src, size_t size)
80
102
  {
81
103
  houdini_escape_html0(ob, src, size, 1);
82
104
  }
83
-
@@ -1,18 +1,24 @@
1
1
  /*
2
2
  * Copyright (c) 2009, Natacha Porté
3
- * Copyright (c) 2011, Vicent Marti
3
+ * Copyright (c) 2015, Vicent Marti
4
4
  *
5
- * Permission to use, copy, modify, and distribute this software for any
6
- * purpose with or without fee is hereby granted, provided that the above
7
- * copyright notice and this permission notice appear in all copies.
5
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ * of this software and associated documentation files (the "Software"), to deal
7
+ * in the Software without restriction, including without limitation the rights
8
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ * copies of the Software, and to permit persons to whom the Software is
10
+ * furnished to do so, subject to the following conditions:
8
11
  *
9
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
12
+ * The above copyright notice and this permission notice shall be included in
13
+ * all copies or substantial portions of the Software.
14
+ *
15
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ * THE SOFTWARE.
16
22
  */
17
23
 
18
24
  #include "markdown.h"
@@ -249,8 +255,15 @@ rndr_quote(struct buf *ob, const struct buf *text, void *opaque)
249
255
  if (!text || !text->size)
250
256
  return 0;
251
257
 
258
+ struct html_renderopt *options = opaque;
259
+
252
260
  BUFPUTSL(ob, "<q>");
253
- bufput(ob, text->data, text->size);
261
+
262
+ if (options->flags & HTML_ESCAPE)
263
+ escape_html(ob, text->data, text->size);
264
+ else
265
+ bufput(ob, text->data, text->size);
266
+
254
267
  BUFPUTSL(ob, "</q>");
255
268
 
256
269
  return 1;
@@ -275,13 +288,20 @@ rndr_header_anchor(struct buf *out, const struct buf *anchor)
275
288
  int stripped = 0, inserted = 0;
276
289
 
277
290
  for (; i < size; ++i) {
291
+ // skip html tags
278
292
  if (a[i] == '<') {
279
293
  while (i < size && a[i] != '>')
280
294
  i++;
295
+ // skip html entities
296
+ } else if (a[i] == '&') {
297
+ while (i < size && a[i] != ';')
298
+ i++;
281
299
  }
282
- else if (strchr(STRIPPED, a[i])) {
300
+ // replace non-ascii or invalid characters with dashes
301
+ else if (!isascii(a[i]) || strchr(STRIPPED, a[i])) {
283
302
  if (inserted && !stripped)
284
303
  bufputc(out, '-');
304
+ // and do it only once
285
305
  stripped = 1;
286
306
  }
287
307
  else {
@@ -291,8 +311,18 @@ rndr_header_anchor(struct buf *out, const struct buf *anchor)
291
311
  }
292
312
  }
293
313
 
294
- if (stripped)
314
+ // replace the last dash if there was anything added
315
+ if (stripped && inserted)
295
316
  out->size--;
317
+
318
+ // if anchor found empty, use djb2 hash for it
319
+ if (!inserted && anchor->size) {
320
+ unsigned long hash = 5381;
321
+ for (i = 0; i < size; ++i) {
322
+ hash = ((hash << 5) + hash) + a[i]; /* h * 33 + c */
323
+ }
324
+ bufprintf(out, "part-%lx", hash);
325
+ }
296
326
  }
297
327
 
298
328
  static void
@@ -303,7 +333,8 @@ rndr_header(struct buf *ob, const struct buf *text, int level, void *opaque)
303
333
  if (ob->size)
304
334
  bufputc(ob, '\n');
305
335
 
306
- if ((options->flags & HTML_TOC) && (level <= options->toc_data.nesting_level)) {
336
+ if ((options->flags & HTML_TOC) && level >= options->toc_data.nesting_bounds[0] &&
337
+ level <= options->toc_data.nesting_bounds[1]) {
307
338
  bufprintf(ob, "<h%d id=\"", level);
308
339
  rndr_header_anchor(ob, text);
309
340
  BUFPUTSL(ob, "\">");
@@ -632,7 +663,7 @@ rndr_footnote_def(struct buf *ob, const struct buf *text, unsigned int num, void
632
663
  bufprintf(ob, "\n<li id=\"fn%d\">\n", num);
633
664
  if (pfound) {
634
665
  bufput(ob, text->data, i);
635
- bufprintf(ob, "&nbsp;<a href=\"#fnref%d\" rev=\"footnote\">&#8617;</a>", num);
666
+ bufprintf(ob, "&nbsp;<a href=\"#fnref%d\">&#8617;</a>", num);
636
667
  bufput(ob, text->data + i, text->size - i);
637
668
  } else if (text) {
638
669
  bufput(ob, text->data, text->size);
@@ -643,7 +674,7 @@ rndr_footnote_def(struct buf *ob, const struct buf *text, unsigned int num, void
643
674
  static int
644
675
  rndr_footnote_ref(struct buf *ob, unsigned int num, void *opaque)
645
676
  {
646
- bufprintf(ob, "<sup id=\"fnref%d\"><a href=\"#fn%d\" rel=\"footnote\">%d</a></sup>", num, num, num);
677
+ bufprintf(ob, "<sup id=\"fnref%d\"><a href=\"#fn%d\">%d</a></sup>", num, num, num);
647
678
  return 1;
648
679
  }
649
680
 
@@ -652,7 +683,8 @@ toc_header(struct buf *ob, const struct buf *text, int level, void *opaque)
652
683
  {
653
684
  struct html_renderopt *options = opaque;
654
685
 
655
- if (level <= options->toc_data.nesting_level) {
686
+ if (level >= options->toc_data.nesting_bounds[0] &&
687
+ level <= options->toc_data.nesting_bounds[1]) {
656
688
  /* set the level offset if this is the first header
657
689
  * we're parsing for the document */
658
690
  if (options->toc_data.current_level == 0)
@@ -801,7 +833,8 @@ sdhtml_renderer(struct sd_callbacks *callbacks, struct html_renderopt *options,
801
833
  /* Prepare the options pointer */
802
834
  memset(options, 0x0, sizeof(struct html_renderopt));
803
835
  options->flags = render_flags;
804
- options->toc_data.nesting_level = 99;
836
+ options->toc_data.nesting_bounds[0] = 1;
837
+ options->toc_data.nesting_bounds[1] = 6;
805
838
 
806
839
  /* Prepare the callbacks */
807
840
  memcpy(callbacks, &cb_default, sizeof(struct sd_callbacks));
@@ -1,17 +1,23 @@
1
1
  /*
2
- * Copyright (c) 2011, Vicent Marti
2
+ * Copyright (c) 2015, Vicent Marti
3
3
  *
4
- * Permission to use, copy, modify, and distribute this software for any
5
- * purpose with or without fee is hereby granted, provided that the above
6
- * copyright notice and this permission notice appear in all copies.
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
7
10
  *
8
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ * THE SOFTWARE.
15
21
  */
16
22
 
17
23
  #ifndef HTML_H__
@@ -29,7 +35,7 @@ struct html_renderopt {
29
35
  struct {
30
36
  int current_level;
31
37
  int level_offset;
32
- int nesting_level;
38
+ int nesting_bounds[2];
33
39
  } toc_data;
34
40
 
35
41
  unsigned int flags;
@@ -75,4 +81,3 @@ sdhtml_smartypants(struct buf *ob, const uint8_t *text, size_t size);
75
81
  #endif
76
82
 
77
83
  #endif
78
-
@@ -1,6 +1,6 @@
1
- /* C code produced by gperf version 3.0.4 */
1
+ /* C code produced by gperf version 3.0.3 */
2
2
  /* Command-line: gperf -N find_block_tag -H hash_block_tag -C -c -E --ignore-case html_block_names.txt */
3
- /* See http://git.io/RN0ncw for the list of recognized elements */
3
+ /* See https://git.io/vPLqa for the list of recognized elements */
4
4
  /* Computed positions: -k'1-2' */
5
5
 
6
6
  #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
@@ -30,7 +30,7 @@
30
30
  error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu-gperf@gnu.org>."
31
31
  #endif
32
32
 
33
- /* maximum key range = 67, duplicates = 0 */
33
+ /* maximum key range = 72, duplicates = 0 */
34
34
 
35
35
  #ifndef GPERF_DOWNCASE
36
36
  #define GPERF_DOWNCASE 1
@@ -94,34 +94,34 @@ hash_block_tag (str, len)
94
94
  {
95
95
  static const unsigned char asso_values[] =
96
96
  {
97
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
98
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
99
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
100
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
101
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
102
- 55, 50, 45, 40, 35, 30, 68, 68, 68, 68,
103
- 68, 68, 68, 68, 68, 15, 10, 15, 15, 15,
104
- 0, 20, 10, 10, 5, 68, 68, 0, 20, 25,
105
- 0, 68, 68, 0, 25, 0, 15, 68, 68, 68,
106
- 68, 68, 68, 68, 68, 68, 68, 15, 10, 15,
107
- 15, 15, 0, 20, 10, 10, 5, 68, 68, 0,
108
- 20, 25, 0, 68, 68, 0, 25, 0, 15, 68,
109
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
110
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
111
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
112
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
113
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
114
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
115
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
116
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
117
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
118
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
119
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
120
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
121
- 68, 68, 68, 68, 68, 68, 68, 68, 68, 68,
122
- 68, 68, 68, 68, 68, 68, 68
97
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
98
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
99
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
100
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
101
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
102
+ 26, 60, 55, 45, 40, 35, 73, 73, 73, 73,
103
+ 73, 73, 73, 73, 73, 20, 15, 15, 0, 35,
104
+ 0, 25, 10, 10, 5, 73, 73, 0, 15, 15,
105
+ 0, 73, 73, 15, 20, 10, 10, 73, 73, 73,
106
+ 73, 73, 73, 73, 73, 73, 73, 20, 15, 15,
107
+ 0, 35, 0, 25, 10, 10, 5, 73, 73, 0,
108
+ 15, 15, 0, 73, 73, 15, 20, 10, 10, 73,
109
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
110
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
111
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
112
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
113
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
114
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
115
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
116
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
117
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
118
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
119
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
120
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
121
+ 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
122
+ 73, 73, 73, 73, 73, 73, 73
123
123
  };
124
- register int hval = len;
124
+ register unsigned int hval = len;
125
125
 
126
126
  switch (hval)
127
127
  {
@@ -135,12 +135,6 @@ hash_block_tag (str, len)
135
135
  return hval;
136
136
  }
137
137
 
138
- #ifdef __GNUC__
139
- __inline
140
- #if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
141
- __attribute__ ((__gnu_inline__))
142
- #endif
143
- #endif
144
138
  const char *
145
139
  find_block_tag (str, len)
146
140
  register const char *str;
@@ -148,76 +142,80 @@ find_block_tag (str, len)
148
142
  {
149
143
  enum
150
144
  {
151
- TOTAL_KEYWORDS = 41,
145
+ TOTAL_KEYWORDS = 43,
152
146
  MIN_WORD_LENGTH = 1,
153
147
  MAX_WORD_LENGTH = 10,
154
148
  MIN_HASH_VALUE = 1,
155
- MAX_HASH_VALUE = 67
149
+ MAX_HASH_VALUE = 72
156
150
  };
157
151
 
158
152
  static const char * const wordlist[] =
159
153
  {
160
154
  "",
161
155
  "p",
162
- "ul",
163
- "pre",
156
+ "dl",
157
+ "del",
164
158
  "form",
165
- "style",
159
+ "",
166
160
  "footer",
167
- "section",
168
- "", "", "",
161
+ "details",
162
+ "div",
163
+ "", "",
169
164
  "figure",
170
- "hr",
165
+ "ul",
171
166
  "fieldset",
172
- "math",
167
+ "",
173
168
  "figcaption",
174
169
  "header",
175
- "dl",
176
- "del",
177
- "",
178
- "blockquote",
170
+ "ol",
171
+ "pre",
172
+ "math",
173
+ "video",
179
174
  "script",
180
- "article",
181
- "div",
175
+ "section",
176
+ "noscript",
182
177
  "",
183
- "video",
178
+ "blockquote",
184
179
  "hgroup",
185
- "ol",
186
- "noscript",
187
- "", "",
180
+ "hr",
181
+ "ins",
182
+ "",
183
+ "style",
184
+ "output",
185
+ "summary",
186
+ "nav",
187
+ "",
188
+ "audio",
188
189
  "canvas",
189
190
  "dd",
190
- "nav",
191
+ "h1",
191
192
  "abbr",
192
- "audio",
193
- "iframe",
194
- "address",
195
- "ins",
196
- "",
197
193
  "table",
198
- "",
199
- "h6",
194
+ "iframe",
195
+ "article",
200
196
  "", "",
201
197
  "aside",
202
- "output",
203
- "h5",
198
+ "",
199
+ "h6",
204
200
  "", "",
205
201
  "tfoot",
206
202
  "",
203
+ "h5",
204
+ "", "", "", "",
207
205
  "h4",
208
206
  "", "", "", "",
209
- "h3",
207
+ "address",
210
208
  "", "", "", "",
211
- "h2",
209
+ "h3",
212
210
  "", "", "", "",
213
- "h1"
211
+ "h2"
214
212
  };
215
213
 
216
214
  if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
217
215
  {
218
- register int key = hash_block_tag (str, len);
216
+ unsigned int key = hash_block_tag (str, len);
219
217
 
220
- if (key <= MAX_HASH_VALUE && key >= 0)
218
+ if (key <= MAX_HASH_VALUE)
221
219
  {
222
220
  register const char *s = wordlist[key];
223
221