1%{ /* -*-indented-text-*- */ 2 3/* 4 * Copyright © 1998-2017 World Wide Web Consortium 5 * See http://www.w3.org/Consortium/Legal/copyright-software 6 * 7 * Part of HTML-XML-utils, see: 8 * http://www.w3.org/Tools/HTML-XML-utils/ 9 * 10 * Author: Bert Bos <bert@w3.org> 11 * Created: 5 Nov 1998 12 * 13 * Input file for gperf, to generate a perfect hash function 14 * for all HTML tags, and to store each element's type. 15 * 16 * mixed = element accepts text content 17 * empty = element is empty 18 * cdata = element has character data content (i.e., unparsed content) 19 * stag = start tag is required 20 * etag = end tag is required 21 * pre = element is preformatted 22 * break_before, break_after = pretty-print with a newline before/after the elt 23 * parents = array of possible parents, first one is preferred parent 24 * 25 * The DTD is a mixture of strict HTML 4.0 and some HTML5 26 * 27 */ 28#include <config.h> 29#include <string.h> 30#include <stdlib.h> 31#include <assert.h> 32#include <stdbool.h> 33#include "export.h" 34#include "types.e" 35 36#define MAXNAMELEN 10 /* Max. len. of elt. name */ 37EXPORTDEF(MAXNAMELEN) 38 39EXPORT typedef struct _ElementType { 40 string name; 41 bool mixed, empty, cdata, stag, etag, pre, break_before, break_after; 42 string parents[76]; 43} ElementType; 44 45/* lookup_element -- look up the string in the hash table */ 46EXPORT const ElementType * lookup_element(/* register const char *str, 47 register unsigned int len */); 48 49/* Different kinds of parent elements: */ 50#define PHRASE "abbr", "acronym", "b", "bdi", "bdo", "big", "cite", "code", "dfn", "em", "i", "kbd", "q", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "tt", "u", "var" 51#define BRIDGE "p", "address", "caption", "dt", "h1", "h2", "h3", "h4", "h5", "h6", "legend", "pre" 52#define FLOW "article", "aside", "dd", "del", "details", "div", "fieldset", "figcaption", "figure", "footer", "header", "ins", "li", "nav", "section", "main", "object", "td", "th" 53#define INLINE_PARENT BRIDGE, PHRASE, FLOW 54#define BLOCK_PARENT "body", "blockquote", "map", "main" 55%} 56ElementType {} 57 58%% 59# name mixed empty cdata stag etag pre b a parents 60# ---- ----- ----- ----- ---- ---- --- - - ------- 61"%data", 1, 0, 0, 1, 0, 0, 0, 0, {"p", NULL} 62a, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "label", NULL} 63abbr, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 64acronym, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 65address, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 66area, 0, 1, 0, 1, 0, 0, 0, 0, {"map", NULL} 67article, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 68aside, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 69audio, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 70b, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 71base, 0, 1, 0, 1, 0, 0, 1, 1, {"head", NULL} 72bdi, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 73bdo, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 74big, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 75blockquote, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 76body, 0, 0, 0, 0, 0, 0, 1, 1, {"html", NULL} 77br, 0, 1, 0, 1, 0, 0, 0, 1, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 78button, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "label", NULL} 79caption, 1, 0, 0, 1, 1, 0, 1, 1, {"table", NULL} 80cite, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 81code, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 82col, 0, 1, 0, 1, 0, 0, 0, 0, {"colgroup", "table", NULL} 83colgroup, 0, 0, 0, 1, 1, 0, 1, 1, {"table", NULL} 84dd, 1, 0, 0, 1, 0, 0, 1, 1, {"dl", NULL} 85del, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, BLOCK_PARENT, "a", "button", "noscript", "form", "label", "option", "textarea", NULL} 86details, 1, 0, 0, 1, 1, 0, 1, 1, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 87dfn, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 88div, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 89dl, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 90dt, 1, 0, 0, 1, 0, 0, 1, 1, {"dl", NULL} 91em, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 92embed, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 93fieldset, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "form", NULL} 94figcaption, 1, 0, 0, 1, 1, 0, 1, 1, {"figure", NULL} 95figure, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 96footer, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 97form, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, NULL} 98h1, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 99h2, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 100h3, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 101h4, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 102h5, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 103h6, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 104head, 0, 0, 0, 0, 0, 0, 1, 1, {"html", NULL} 105header, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 106hr, 0, 1, 0, 1, 0, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 107html, 0, 0, 0, 0, 0, 0, 1, 1, {NULL, NULL} 108i, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 109img, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 110input, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "label", NULL} 111ins, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, BLOCK_PARENT, "a", "button", "noscript", "form", "label", "option", "textarea", NULL} 112kbd, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 113keygen, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 114label, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", NULL} 115legend, 1, 0, 0, 1, 1, 0, 1, 1, {"fieldset", NULL} 116li, 1, 0, 0, 1, 0, 0, 1, 1, {"ul", "ol", NULL} 117link, 0, 1, 0, 1, 0, 0, 1, 0, {"head", NULL} 118main, 1, 0, 0, 1, 1, 0, 1, 1, {"body", "div", "noscript", NULL} 119map, 0, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 120meta, 0, 1, 0, 1, 0, 0, 1, 0, {INLINE_PARENT, "head", "a", "button", "noscript", "label", NULL} 121nav, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 122noscript, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, BLOCK_PARENT, "a", "button", "noscript", "form", "label", "option", "textarea", NULL} 123object, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "del", "header", "aside", "section", "main", "article", "nav", "fieldset", "head", "ins", "label", "object", NULL} 124ol, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 125optgroup, 0, 0, 0, 1, 1, 0, 1, 1, {"select", NULL} 126option, 1, 0, 0, 1, 0, 0, 1, 1, {"select", "optgroup", NULL} 127p, 1, 0, 0, 1, 0, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 128param, 0, 1, 0, 1, 0, 0, 1, 1, {"object", NULL} 129pre, 1, 0, 0, 1, 1, 1, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 130q, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 131samp, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 132script, 1, 0, 1, 1, 1, 1, 1, 0, {"body", INLINE_PARENT, "blockquote", "head", "map", "a", "button", "noscript", "form", "label", NULL} 133section, 1, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 134select, 0, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "label", NULL} 135small, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 136source, 0, 1, 0, 1, 0, 0, 1, 1, {"audio", "video", "template", NULL} 137span, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 138strong, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 139style, 1, 0, 1, 1, 1, 1, 1, 0, {"head", NULL} 140sub, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 141summary, 1, 0, 0, 1, 1, 0, 1, 1, {"details", NULL} 142sup, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 143table, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 144tbody, 0, 0, 0, 0, 0, 0, 1, 1, {"table", NULL} 145td, 1, 0, 0, 1, 0, 0, 1, 1, {"tr", NULL} 146textarea, 1, 0, 0, 1, 1, 1, 0, 0, {INLINE_PARENT, "a", "label", NULL} 147tfoot, 0, 0, 0, 1, 0, 0, 1, 1, {"table", NULL} 148th, 1, 0, 0, 1, 0, 0, 1, 1, {"tr", NULL} 149thead, 0, 0, 0, 1, 0, 0, 1, 1, {"table", NULL} 150title, 1, 0, 0, 1, 1, 0, 1, 1, {"head", NULL} 151tr, 0, 0, 0, 1, 0, 0, 1, 1, {"tbody", "tfoot", "thead", NULL} 152track, 0, 1, 0, 1, 0, 0, 1, 1, {"audio", "video", "template", NULL} 153tt, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 154ul, 0, 0, 0, 1, 1, 0, 1, 1, {BLOCK_PARENT, FLOW, "button", "noscript", "form", NULL} 155var, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 156video, 1, 0, 0, 1, 1, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 157wbr, 0, 1, 0, 1, 0, 0, 0, 0, {INLINE_PARENT, "a", "button", "noscript", "label", NULL} 158%% 159