1 /**
2 * Copyright © DiamondMVC 2019
3 * License: MIT (https://github.com/DiamondMVC/Diamond/blob/master/LICENSE)
4 * Author: Jacob Jensen (bausshf)
5 */
6 module diamond.html.htmlparsersettings;
7 
8 import diamond.dom.domparsersettings;
9 
10 /// Wrapper around html parser settings.
11 final class HtmlParserSettings : DomParserSettings
12 {
13   public:
14   final:
15   /// Creates a new html parser settings:
16   this() @safe
17   {
18     super
19     (
20       false, // Html is not strict
21       // Tags that can contain flexible content.
22       ["script", "pre", "code", "style", "svg"],
23       // Html allows self-closing tags.
24       true,
25       // Tags that are self-closing.
26       [
27         "area", "base", "br", "col", "embed",
28         "hr", "img", "input", "keygen", "link",
29         "meta", "param", "source", "track", "wbr"
30       ],
31       // Standard tags are tags that aren't self-closing
32       [
33         // Main root tags
34         "doctype", "html",
35         // Sectioning root tags
36         "head", "body",
37         // Document metadata tags
38         "title",
39         // Content sectioning
40         "address", "article", "aside",
41         "footer", "header",
42         "h1", "h2", "h3", "h4", "h5", "h6",
43         "hgroup",
44         "main", "nav", "section",
45         // Text content
46         "blockquote",
47         "dd", "dir", "div", "dl", "dt",
48         "figcaption", "figure",
49         "hr",
50         "li", "ol", "ul",
51         "p",
52         // Inline text semantics
53         "a",
54         "abbr",
55         "b",
56         "bdo", "bdo",
57         "br",
58         "cite",
59         "data",
60         "dfn",
61         "em", "i",
62         "kbd",
63         "mark", "q",
64         "rn", "rp", "rt", "rtc",
65         "ruby",
66         "s",
67         "samp", "small", "span",
68         "strong", "sub", "sup",
69         "time", "tt",
70         "u",
71         "var",
72         // Image and multimedia
73         "audio", "map", "video",
74         // Embedded content
75         "applet", "iframe",
76         "noembed", "object",
77         "picture",
78         // Scripting
79         "canvas",
80         // Demarcating edits
81         "del", "ins",
82         // Table content
83         "caption",
84         "col", "colgroup",
85         "table",
86         "tbody", "td",
87         "tfoot",
88         "th", "thead",
89         "tr",
90         // Forms,
91         "button", "datalist", "fieldset",
92         "form", "label", "legend",
93         "meter", "optgroup",
94         "option",
95         "output",
96         "progress",
97         "select",
98         "textarea",
99         // Interactive elements,
100         "details", "dialog",
101         "menu", "menuitem", "summary",
102         // Web Components
103         "content", "element", "shadow", "slot", "template"
104       ],
105       // Tags to repair in the head section
106       [
107         "title", "meta", "link", "base",
108         // Although style can be allowed in the body, when repairing it's better suited in the head section.
109         "style"
110       ],
111       // Tags to repair in the body section
112       [
113         "area", "br", "col", "embed",
114         "hr", "img", "input", "keygen",
115         "param", "source", "track", "wbr",
116         "address", "article", "aside",
117         "footer", "header",
118         "h1", "h2", "h3", "h4", "h5", "h6",
119         "hgroup",
120         "main", "nav", "section",
121         "blockquote",
122         "dd", "dir", "div", "dl", "dt",
123         "figcaption", "figure",
124         "hr",
125         "li", "ol", "ul",
126         "a",
127         "abbr",
128         "b",
129         "bdo", "bdo",
130         "br",
131         "cite",
132         "data",
133         "dfn",
134         "em", "i",
135         "kbd",
136         "mark", "q",
137         "rn", "rp", "rt", "rtc",
138         "ruby",
139         "s",
140         "samp", "small", "span",
141         "strong", "sub", "sup",
142         "time", "tt",
143         "u",
144         "var",
145         "audio", "map", "video",
146         "applet", "iframe",
147         "noembed", "object",
148         "picture",
149         "canvas",
150         "del", "ins",
151         "caption",
152         "col", "colgroup",
153         "table",
154         "tbody", "td",
155         "tfoot",
156         "th", "thead",
157         "tr",
158         "button", "datalist", "fieldset",
159         "form", "label", "legend",
160         "meter", "optgroup",
161         "option",
162         "output",
163         "progress",
164         "select",
165         "textarea",
166         "details", "dialog",
167         "menu", "menuitem", "summary",
168         "content", "element", "shadow", "slot", "template",
169         "svg", "path",
170         // script is placed in the body, because sometimes it's depending on the content.
171         // During a repair we do not know if the script is depending or not and thus we have to make an assumption.
172         "script"
173       ]
174     );
175   }
176 }