0 | module Text.Html.Elements.Elab
  1 |
  2 | %default total
  3 |
  4 | ||| Configuration for generators.
  5 | public export
  6 | record Config where
  7 |   constructor MkConfig
  8 |
  9 |   ||| Name of the HTML element.
 10 |   name : String
 11 |
 12 |   ||| `True` if the HTML element can have children elements.
 13 |   children : Bool
 14 |
 15 |   ||| `True` if the HTML may have no attributes.
 16 |   noAttributes : Bool
 17 |
 18 |   ||| Name of the function used to validate the element's attributes.
 19 |   attributesFunc : String
 20 |
 21 |   ||| Name of the function used to validate the element's children.
 22 |   elemsFunc : String
 23 |
 24 | ||| Default configuration.
 25 | |||
 26 | ||| By default the configuration has:
 27 | |||
 28 | ||| - no name "";
 29 | ||| - can have children `True`;
 30 | ||| - may have no attributes `True`;
 31 | ||| - accepts the global attributes "standard";
 32 | ||| - accepts flow content children "flowContentElemns".
 33 | export
 34 | defaultConfig : Config
 35 | defaultConfig = MkConfig "" True True "standard" "flowContentElems"
 36 |
 37 | ||| List of all elements configurations.
 38 | |||
 39 | ||| This list is the one used to generates the various functions through elab.
 40 | export
 41 | elems : List Config
 42 | elems =
 43 |   [ { name := "a"
 44 |     , noAttributes := False
 45 |     , attributesFunc := "aAttributes"
 46 |     , elemsFunc := "aElems"
 47 |     } defaultConfig
 48 |   , { name := "abbr", elemsFunc := "phrasingContentElems" } defaultConfig
 49 |   , { name := "address", elemsFunc := "addressElems" } defaultConfig
 50 |   , { name := "area"
 51 |     , children := False
 52 |     , attributesFunc := "areaAttributes"
 53 |     } defaultConfig
 54 |   , { name := "article" } defaultConfig
 55 |   , { name := "aside" } defaultConfig
 56 |   , { name := "audio"
 57 |     , attributesFunc := "audioAttributes"
 58 |     , elemsFunc := "audioElems"
 59 |     } defaultConfig
 60 |   , { name := "b", elemsFunc := "phrasingContentElems" } defaultConfig
 61 |   , { name := "base"
 62 |     , children := False
 63 |     , attributesFunc := "baseAttributes"
 64 |     } defaultConfig
 65 |   , { name := "bdi", elemsFunc := "phrasingContentElems" } defaultConfig
 66 |   , { name := "bdo", elemsFunc := "phrasingContentElems" } defaultConfig
 67 |   , { name := "blockquote"
 68 |       -- For **blockquote** and **q** elements
 69 |     , attributesFunc := "citationAttributes"
 70 |     } defaultConfig
 71 |   , { name := "body" } defaultConfig
 72 |   , { name := "br", children := False } defaultConfig
 73 |   , { name := "button"
 74 |     , attributesFunc := "buttonAttributes"
 75 |     , elemsFunc := "phrasingContentElems"
 76 |     } defaultConfig
 77 |   , { name := "canvas"
 78 |     , attributesFunc := "canvasAttributes"
 79 |     , elemsFunc := "canvasElems"
 80 |     } defaultConfig
 81 |   , { name := "caption" } defaultConfig
 82 |   , { name := "cite", elemsFunc := "phrasingContentElems" } defaultConfig
 83 |   , { name := "code", elemsFunc := "phrasingContentElems" } defaultConfig
 84 |   , { name := "col"
 85 |     , children := False
 86 |     , attributesFunc := "colAttributes"
 87 |     } defaultConfig
 88 |   , { name := "colgroup"
 89 |     , attributesFunc := "colAttributes"
 90 |     , elemsFunc := "colgroupElems"
 91 |     } defaultConfig
 92 |   , { name := "data"
 93 |     , attributesFunc := "dataAttributes"
 94 |     , elemsFunc := "phrasingContentElems"
 95 |     } defaultConfig
 96 |   , { name := "datalist", elemsFunc := "datalistElems" } defaultConfig
 97 |   , { name := "dd" } defaultConfig
 98 |   , { name := "del"
 99 |     , attributesFunc := "changeAttributes"
100 |     -- Note: this is a simplification, as **del** is transparent.
101 |     , elemsFunc := "flowOrPhrasingContentElems"
102 |     } defaultConfig
103 |   , { name := "details"
104 |     , attributesFunc := "detailsAttributes"
105 |     , elemsFunc := "detailsElems"
106 |     } defaultConfig
107 |   , { name := "dfn", elemsFunc := "dfnElems" } defaultConfig
108 |   , { name := "dialog", attributesFunc := "dialogAttributes" } defaultConfig
109 |   , { name := "div", elemsFunc := "divElems" } defaultConfig
110 |   , { name := "dl", elemsFunc := "dlElems" } defaultConfig
111 |   , { name := "dt", elemsFunc := "dtElems" } defaultConfig
112 |   , { name := "em", elemsFunc := "phrasingContentElems" } defaultConfig
113 |   , { name := "embed"
114 |     , children := False
115 |     , attributesFunc := "embedAttributes"
116 |     } defaultConfig
117 |   , { name := "fieldset"
118 |     , attributesFunc := "fieldsetAttributes"
119 |     , elemsFunc := "fieldsetElems"
120 |     } defaultConfig
121 |   , { name := "figcaption" } defaultConfig
122 |   , { name := "figure", elemsFunc := "figureElems" } defaultConfig
123 |   , { name := "footer", elemsFunc := "footerElems" } defaultConfig
124 |   , { name := "form"
125 |     , attributesFunc := "formAttributes"
126 |     , elemsFunc := "formElems"
127 |     } defaultConfig
128 |   , { name := "h1", elemsFunc := "phrasingContentElems" } defaultConfig
129 |   , { name := "h2", elemsFunc := "phrasingContentElems" } defaultConfig
130 |   , { name := "h3", elemsFunc := "phrasingContentElems" } defaultConfig
131 |   , { name := "h4", elemsFunc := "phrasingContentElems" } defaultConfig
132 |   , { name := "h5", elemsFunc := "phrasingContentElems" } defaultConfig
133 |   , { name := "h6", elemsFunc := "phrasingContentElems" } defaultConfig
134 |   , { name := "head", elemsFunc := "headElems" } defaultConfig
135 |   , { name := "header", elemsFunc := "headerElems" } defaultConfig
136 |   , { name := "hgroup", elemsFunc := "hgroupElems" } defaultConfig
137 |   , { name := "hr"
138 |     , children := False
139 |     } defaultConfig
140 |   , { name := "html"
141 |     , noAttributes := False
142 |     , attributesFunc := "htmlAttributes"
143 |     , elemsFunc := "htmlElems"
144 |     } defaultConfig
145 |   , { name := "i", elemsFunc := "phrasingContentElems" } defaultConfig
146 |   , { name := "iframe"
147 |     , attributesFunc := "iframeAttributes"
148 |     , children := False
149 |     } defaultConfig
150 |   , { name := "img"
151 |     , attributesFunc := "imgAttributes"
152 |     , children := False
153 |     } defaultConfig
154 |   , { name := "input"
155 |     , attributesFunc := "inputAttributes"
156 |     , children := False
157 |     } defaultConfig
158 |   , { name := "ins"
159 |     , attributesFunc := "changeAttributes"
160 |     -- Note: this is a simplification, as **ins** is transparent.
161 |     , elemsFunc := "flowOrPhrasingContentElems"
162 |     } defaultConfig
163 |   , { name := "kbd", elemsFunc := "phrasingContentElems" } defaultConfig
164 |   , { name := "label"
165 |     , attributesFunc := "labelAttributes"
166 |     , elemsFunc := "labelElems"
167 |     } defaultConfig
168 |   , { name := "legend", elemsFunc := "legendElems" } defaultConfig
169 |   , { name := "li", attributesFunc := "liAttributes" } defaultConfig
170 |   , { name := "link"
171 |     , noAttributes := False
172 |     , children := False
173 |     , attributesFunc := "linkAttributes"
174 |     } defaultConfig
175 |   , { name := "main" } defaultConfig
176 |   , { name := "map"
177 |     , attributesFunc := "mapAttributes"
178 |     -- Note: this is a simplification, as any transparent content is accepted.
179 |     , elemsFunc := "flowOrPhrasingContentElems"
180 |     } defaultConfig
181 |   , { name := "mark", elemsFunc := "phrasingContentElems" } defaultConfig
182 |   , { name := "meta"
183 |     , noAttributes := False
184 |     , children := False
185 |     , attributesFunc := "metaAttributes"
186 |     } defaultConfig
187 |     -- Note: the "ulElems" is not a mistake. **menu** has the same behaviour
188 |     -- as **ul**.
189 |   , { name := "menu", elemsFunc := "ulElems" } defaultConfig
190 |   , { name := "meter"
191 |     , attributesFunc := "meterAttributes"
192 |     , elemsFunc := "meterElems"
193 |     } defaultConfig
194 |   , { name := "nav" } defaultConfig
195 |   , { name := "noscript", elemsFunc := "noscriptElems" } defaultConfig
196 |   , { name := "object"
197 |     , attributesFunc := "objectAttributes"
198 |     , elemsFunc := "objectElems"
199 |     } defaultConfig
200 |   , { name := "ol"
201 |     , attributesFunc := "olAttributes"
202 |     -- Note: the "ulElems" is not a mitake as **ol** accepts the same elements.
203 |     , elemsFunc := "ulElems"
204 |     } defaultConfig
205 |   , { name := "optgroup"
206 |     , attributesFunc := "optgroupAttributes"
207 |     , elemsFunc := "optgroupElems"
208 |     } defaultConfig
209 |   , { name := "option"
210 |     , attributesFunc := "optionAttributes"
211 |     , elemsFunc := "plaintextElems"
212 |     } defaultConfig
213 |   , { name := "output"
214 |     , attributesFunc := "outputAttributes"
215 |     , elemsFunc := "phrasingContentElems"
216 |     } defaultConfig
217 |   , { name := "p", elemsFunc := "phrasingContentElems" } defaultConfig
218 |   , { name := "picture", elemsFunc := "pictureElems" } defaultConfig
219 |   , { name := "pre", elemsFunc := "phrasingContentElems" } defaultConfig
220 |   , { name := "progress"
221 |     , attributesFunc := "progressAttributes"
222 |     , elemsFunc := "progressElems"
223 |     } defaultConfig
224 |   , { name := "q"
225 |       -- For **blockquote** and **q** elements
226 |     , attributesFunc := "citationAttributes"
227 |     , elemsFunc := "phrasingContentElems"
228 |     } defaultConfig
229 |   , { name := "rp"
230 |     , elemsFunc := "plaintextElems"
231 |     } defaultConfig
232 |   , { name := "rt", elemsFunc := "phrasingContentElems" } defaultConfig
233 |   , { name := "ruby", elemsFunc := "rubyElems" } defaultConfig
234 |   , { name := "s", elemsFunc := "phrasingContentElems" } defaultConfig
235 |   , { name := "samp", elemsFunc := "phrasingContentElems" } defaultConfig
236 |   , { name := "script"
237 |     , attributesFunc := "scriptAttributes"
238 |     , elemsFunc := "scriptElems"
239 |     } defaultConfig
240 |   , { name := "search" } defaultConfig
241 |   , { name := "section" } defaultConfig
242 |   , { name := "select"
243 |     , attributesFunc := "selectAttributes"
244 |     , elemsFunc := "selectElems"
245 |     } defaultConfig
246 |   , { name := "slot"
247 |     , attributesFunc := "slotAttributes"
248 |     , elemsFunc := "slotElems"
249 |     } defaultConfig
250 |   , { name := "small", elemsFunc := "phrasingContentElems" } defaultConfig
251 |   , { name := "source"
252 |     , attributesFunc := "sourceAttributes"
253 |     , noAttributes := True
254 |     , children := False
255 |     } defaultConfig
256 |   , { name := "span", elemsFunc := "phrasingContentElems" } defaultConfig
257 |   , { name := "strong", elemsFunc := "phrasingContentElems" } defaultConfig
258 |   , { name := "style"
259 |     , attributesFunc := "styleAttributes"
260 |     , elemsFunc := "styleElems"
261 |     } defaultConfig
262 |   , { name := "sub", elemsFunc := "phrasingContentElems" } defaultConfig
263 |   , { name := "summary", elemsFunc := "summaryElems" } defaultConfig
264 |   , { name := "sup", elemsFunc := "phrasingContentElems" } defaultConfig
265 |   , { name := "table", elemsFunc := "tableElems" } defaultConfig
266 |   , { name := "tbody", elemsFunc := "tbodyElems" } defaultConfig
267 |   , { name := "td" , attributesFunc := "tdAttributes" } defaultConfig
268 |   , { name := "template"
269 |     , attributesFunc := "templateAttributes"
270 |     , elemsFunc := "templateElems"
271 |     } defaultConfig
272 |   , { name := "textarea"
273 |     , attributesFunc := "textareaAttributes"
274 |     , elemsFunc := "plaintextElems"
275 |     } defaultConfig
276 |     -- `tbodyElems` is not a typo, `tfoot` also accepts `tr` elements only.
277 |   , { name := "tfoot", elemsFunc := "tbodyElems" } defaultConfig
278 |   , { name := "th"
279 |     , attributesFunc := "thAttributes"
280 |     , elemsFunc := "thElems"
281 |     } defaultConfig
282 |     -- `tbodyElems` is not a typo, `thead` also accepts `tr` elements only.
283 |   , { name := "thead", elemsFunc := "tbodyElems" } defaultConfig
284 |   , { name := "time"
285 |     , attributesFunc := "timeAttributes"
286 |     , elemsFunc := "phrasingContentElems"
287 |     } defaultConfig
288 |   , { name := "tr", elemsFunc := "trElems" } defaultConfig
289 |   , { name := "track"
290 |     , attributesFunc := "trackAttributes"
291 |     , noAttributes := True
292 |     , children := False
293 |     } defaultConfig
294 |   , { name := "u", elemsFunc := "phrasingContentElems" } defaultConfig
295 |   , { name := "ul", elemsFunc := "ulElems" } defaultConfig
296 |   , { name := "var", elemsFunc := "phrasingContentElems" } defaultConfig
297 |   , { name := "video"
298 |     , attributesFunc := "videoAttributes"
299 |     , elemsFunc := "videoElems"
300 |     } defaultConfig
301 |   , { name := "wbr"
302 |     , children := False
303 |     } defaultConfig
304 |   ]
305 |