git.iko.soy/typeable/pandoc
on master help sign in
Moved html5Attributes, html4Attributes, rdfaAttributes...

from T.P.Writers.HTML (where they were unexported) to T.P.XML (where they are now exported). [API change: new exported functions] This allows these sets to be used elsewhere, e.g. in the HTML reader.

commitfae8ea36f0452eca093b76a1093e7b5c1cea9a5e authorJohn MacFarlane <jgm@berkeley.edu> dateWed 12 Feb 2020, 08:45 (7 years ago) parent3fbee8c
2 files changed+354−348
src/Text/Pandoc/Writers/HTML.hs+2−347 src/Text/Pandoc/XML.hs+352−1
src/Text/Pandoc/Writers/HTML.hs+2−347
@@ -54,7 +54,8 @@ import Text.Pandoc.Templates (renderTemplate)
5454import Text.Pandoc.Walk
5555import Text.Pandoc.Writers.Math
5656import Text.Pandoc.Writers.Shared
57−import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities)
57+import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities,
58+ html5Attributes, html4Attributes, rdfaAttributes)
5859import qualified Text.Blaze.XHtml5 as H5
5960import qualified Text.Blaze.XHtml5.Attributes as A5
6061import Control.Monad.Except (throwError)
@@ -1310,349 +1311,3 @@ isRawHtml f = do
13101311 return $ f == Format "html" ||
13111312 ((html5 && f == Format "html5") || f == Format "html4")
13121313
1313−html5Attributes :: Set.Set Text
1314−html5Attributes = Set.fromList
1315− [ "abbr"
1316− , "accept"
1317− , "accept-charset"
1318− , "accesskey"
1319− , "action"
1320− , "allowfullscreen"
1321− , "allowpaymentrequest"
1322− , "allowusermedia"
1323− , "alt"
1324− , "as"
1325− , "async"
1326− , "autocomplete"
1327− , "autofocus"
1328− , "autoplay"
1329− , "charset"
1330− , "checked"
1331− , "cite"
1332− , "class"
1333− , "color"
1334− , "cols"
1335− , "colspan"
1336− , "content"
1337− , "contenteditable"
1338− , "controls"
1339− , "coords"
1340− , "crossorigin"
1341− , "data"
1342− , "datetime"
1343− , "default"
1344− , "defer"
1345− , "dir"
1346− , "dirname"
1347− , "disabled"
1348− , "download"
1349− , "draggable"
1350− , "enctype"
1351− , "for"
1352− , "form"
1353− , "formaction"
1354− , "formenctype"
1355− , "formmethod"
1356− , "formnovalidate"
1357− , "formtarget"
1358− , "headers"
1359− , "height"
1360− , "hidden"
1361− , "high"
1362− , "href"
1363− , "hreflang"
1364− , "http-equiv"
1365− , "id"
1366− , "inputmode"
1367− , "integrity"
1368− , "is"
1369− , "ismap"
1370− , "itemid"
1371− , "itemprop"
1372− , "itemref"
1373− , "itemscope"
1374− , "itemtype"
1375− , "kind"
1376− , "label"
1377− , "lang"
1378− , "list"
1379− , "loop"
1380− , "low"
1381− , "manifest"
1382− , "max"
1383− , "maxlength"
1384− , "media"
1385− , "method"
1386− , "min"
1387− , "minlength"
1388− , "multiple"
1389− , "muted"
1390− , "name"
1391− , "nomodule"
1392− , "nonce"
1393− , "novalidate"
1394− , "onabort"
1395− , "onafterprint"
1396− , "onauxclick"
1397− , "onbeforeprint"
1398− , "onbeforeunload"
1399− , "onblur"
1400− , "oncancel"
1401− , "oncanplay"
1402− , "oncanplaythrough"
1403− , "onchange"
1404− , "onclick"
1405− , "onclose"
1406− , "oncontextmenu"
1407− , "oncopy"
1408− , "oncuechange"
1409− , "oncut"
1410− , "ondblclick"
1411− , "ondrag"
1412− , "ondragend"
1413− , "ondragenter"
1414− , "ondragexit"
1415− , "ondragleave"
1416− , "ondragover"
1417− , "ondragstart"
1418− , "ondrop"
1419− , "ondurationchange"
1420− , "onemptied"
1421− , "onended"
1422− , "onerror"
1423− , "onfocus"
1424− , "onhashchange"
1425− , "oninput"
1426− , "oninvalid"
1427− , "onkeydown"
1428− , "onkeypress"
1429− , "onkeyup"
1430− , "onlanguagechange"
1431− , "onload"
1432− , "onloadeddata"
1433− , "onloadedmetadata"
1434− , "onloadend"
1435− , "onloadstart"
1436− , "onmessage"
1437− , "onmessageerror"
1438− , "onmousedown"
1439− , "onmouseenter"
1440− , "onmouseleave"
1441− , "onmousemove"
1442− , "onmouseout"
1443− , "onmouseover"
1444− , "onmouseup"
1445− , "onoffline"
1446− , "ononline"
1447− , "onpagehide"
1448− , "onpageshow"
1449− , "onpaste"
1450− , "onpause"
1451− , "onplay"
1452− , "onplaying"
1453− , "onpopstate"
1454− , "onprogress"
1455− , "onratechange"
1456− , "onrejectionhandled"
1457− , "onreset"
1458− , "onresize"
1459− , "onscroll"
1460− , "onsecuritypolicyviolation"
1461− , "onseeked"
1462− , "onseeking"
1463− , "onselect"
1464− , "onstalled"
1465− , "onstorage"
1466− , "onsubmit"
1467− , "onsuspend"
1468− , "ontimeupdate"
1469− , "ontoggle"
1470− , "onunhandledrejection"
1471− , "onunload"
1472− , "onvolumechange"
1473− , "onwaiting"
1474− , "onwheel"
1475− , "open"
1476− , "optimum"
1477− , "pattern"
1478− , "ping"
1479− , "placeholder"
1480− , "playsinline"
1481− , "poster"
1482− , "preload"
1483− , "readonly"
1484− , "referrerpolicy"
1485− , "rel"
1486− , "required"
1487− , "reversed"
1488− , "role"
1489− , "rows"
1490− , "rowspan"
1491− , "sandbox"
1492− , "scope"
1493− , "selected"
1494− , "shape"
1495− , "size"
1496− , "sizes"
1497− , "slot"
1498− , "span"
1499− , "spellcheck"
1500− , "src"
1501− , "srcdoc"
1502− , "srclang"
1503− , "srcset"
1504− , "start"
1505− , "step"
1506− , "style"
1507− , "tabindex"
1508− , "target"
1509− , "title"
1510− , "translate"
1511− , "type"
1512− , "typemustmatch"
1513− , "updateviacache"
1514− , "usemap"
1515− , "value"
1516− , "width"
1517− , "workertype"
1518− , "wrap"
1519− ]
1520−
1521−-- See https://en.wikipedia.org/wiki/RDFa, https://www.w3.org/TR/rdfa-primer/
1522−rdfaAttributes :: Set.Set Text
1523−rdfaAttributes = Set.fromList
1524− [ "about"
1525− , "rel"
1526− , "rev"
1527− , "src"
1528− , "href"
1529− , "resource"
1530− , "property"
1531− , "content"
1532− , "datatype"
1533− , "typeof"
1534− , "vocab"
1535− , "prefix"
1536− ]
1537−
1538−html4Attributes :: Set.Set Text
1539−html4Attributes = Set.fromList
1540− [ "abbr"
1541− , "accept"
1542− , "accept-charset"
1543− , "accesskey"
1544− , "action"
1545− , "align"
1546− , "alink"
1547− , "alt"
1548− , "archive"
1549− , "axis"
1550− , "background"
1551− , "bgcolor"
1552− , "border"
1553− , "cellpadding"
1554− , "cellspacing"
1555− , "char"
1556− , "charoff"
1557− , "charset"
1558− , "checked"
1559− , "cite"
1560− , "class"
1561− , "classid"
1562− , "clear"
1563− , "code"
1564− , "codebase"
1565− , "codetype"
1566− , "color"
1567− , "cols"
1568− , "colspan"
1569− , "compact"
1570− , "content"
1571− , "coords"
1572− , "data"
1573− , "datetime"
1574− , "declare"
1575− , "defer"
1576− , "dir"
1577− , "disabled"
1578− , "enctype"
1579− , "face"
1580− , "for"
1581− , "frame"
1582− , "frameborder"
1583− , "headers"
1584− , "height"
1585− , "href"
1586− , "hreflang"
1587− , "hspace"
1588− , "http-equiv"
1589− , "id"
1590− , "ismap"
1591− , "label"
1592− , "lang"
1593− , "language"
1594− , "link"
1595− , "longdesc"
1596− , "marginheight"
1597− , "marginwidth"
1598− , "maxlength"
1599− , "media"
1600− , "method"
1601− , "multiple"
1602− , "name"
1603− , "nohref"
1604− , "noresize"
1605− , "noshade"
1606− , "nowrap"
1607− , "object"
1608− , "onblur"
1609− , "onchange"
1610− , "onclick"
1611− , "ondblclick"
1612− , "onfocus"
1613− , "onkeydown"
1614− , "onkeypress"
1615− , "onkeyup"
1616− , "onload"
1617− , "onmousedown"
1618− , "onmousemove"
1619− , "onmouseout"
1620− , "onmouseover"
1621− , "onmouseup"
1622− , "onreset"
1623− , "onselect"
1624− , "onsubmit"
1625− , "onunload"
1626− , "profile"
1627− , "prompt"
1628− , "readonly"
1629− , "rel"
1630− , "rev"
1631− , "rows"
1632− , "rowspan"
1633− , "rules"
1634− , "scheme"
1635− , "scope"
1636− , "scrolling"
1637− , "selected"
1638− , "shape"
1639− , "size"
1640− , "span"
1641− , "src"
1642− , "standby"
1643− , "start"
1644− , "style"
1645− , "summary"
1646− , "tabindex"
1647− , "target"
1648− , "text"
1649− , "title"
1650− , "usemap"
1651− , "valign"
1652− , "value"
1653− , "valuetype"
1654− , "version"
1655− , "vlink"
1656− , "vspace"
1657− , "width"
1658− ]
src/Text/Pandoc/XML.hs+352−1
@@ -20,7 +20,10 @@ module Text.Pandoc.XML ( escapeCharForXML,
2020 inTagsIndented,
2121 toEntities,
2222 toHtml5Entities,
23− fromEntities ) where
23+ fromEntities,
24+ html4Attributes,
25+ html5Attributes,
26+ rdfaAttributes ) where
2427
2528import Prelude
2629import Data.Char (isAscii, isSpace, ord)
@@ -31,6 +34,7 @@ import Text.DocLayout
3134import Text.Printf (printf)
3235import qualified Data.Map as M
3336import Data.String
37+import qualified Data.Set as Set
3438
3539-- | Escape one character as needed for XML.
3640escapeCharForXML :: Char -> Text
@@ -137,3 +141,350 @@ fromEntities' (T.uncons -> Just ('&', xs)) =
137141fromEntities' t = case T.uncons t of
138142 Just (x, xs) -> x : fromEntities' xs
139143 Nothing -> ""
144+
145+html5Attributes :: Set.Set Text
146+html5Attributes = Set.fromList
147+ [ "abbr"
148+ , "accept"
149+ , "accept-charset"
150+ , "accesskey"
151+ , "action"
152+ , "allowfullscreen"
153+ , "allowpaymentrequest"
154+ , "allowusermedia"
155+ , "alt"
156+ , "as"
157+ , "async"
158+ , "autocomplete"
159+ , "autofocus"
160+ , "autoplay"
161+ , "charset"
162+ , "checked"
163+ , "cite"
164+ , "class"
165+ , "color"
166+ , "cols"
167+ , "colspan"
168+ , "content"
169+ , "contenteditable"
170+ , "controls"
171+ , "coords"
172+ , "crossorigin"
173+ , "data"
174+ , "datetime"
175+ , "default"
176+ , "defer"
177+ , "dir"
178+ , "dirname"
179+ , "disabled"
180+ , "download"
181+ , "draggable"
182+ , "enctype"
183+ , "for"
184+ , "form"
185+ , "formaction"
186+ , "formenctype"
187+ , "formmethod"
188+ , "formnovalidate"
189+ , "formtarget"
190+ , "headers"
191+ , "height"
192+ , "hidden"
193+ , "high"
194+ , "href"
195+ , "hreflang"
196+ , "http-equiv"
197+ , "id"
198+ , "inputmode"
199+ , "integrity"
200+ , "is"
201+ , "ismap"
202+ , "itemid"
203+ , "itemprop"
204+ , "itemref"
205+ , "itemscope"
206+ , "itemtype"
207+ , "kind"
208+ , "label"
209+ , "lang"
210+ , "list"
211+ , "loop"
212+ , "low"
213+ , "manifest"
214+ , "max"
215+ , "maxlength"
216+ , "media"
217+ , "method"
218+ , "min"
219+ , "minlength"
220+ , "multiple"
221+ , "muted"
222+ , "name"
223+ , "nomodule"
224+ , "nonce"
225+ , "novalidate"
226+ , "onabort"
227+ , "onafterprint"
228+ , "onauxclick"
229+ , "onbeforeprint"
230+ , "onbeforeunload"
231+ , "onblur"
232+ , "oncancel"
233+ , "oncanplay"
234+ , "oncanplaythrough"
235+ , "onchange"
236+ , "onclick"
237+ , "onclose"
238+ , "oncontextmenu"
239+ , "oncopy"
240+ , "oncuechange"
241+ , "oncut"
242+ , "ondblclick"
243+ , "ondrag"
244+ , "ondragend"
245+ , "ondragenter"
246+ , "ondragexit"
247+ , "ondragleave"
248+ , "ondragover"
249+ , "ondragstart"
250+ , "ondrop"
251+ , "ondurationchange"
252+ , "onemptied"
253+ , "onended"
254+ , "onerror"
255+ , "onfocus"
256+ , "onhashchange"
257+ , "oninput"
258+ , "oninvalid"
259+ , "onkeydown"
260+ , "onkeypress"
261+ , "onkeyup"
262+ , "onlanguagechange"
263+ , "onload"
264+ , "onloadeddata"
265+ , "onloadedmetadata"
266+ , "onloadend"
267+ , "onloadstart"
268+ , "onmessage"
269+ , "onmessageerror"
270+ , "onmousedown"
271+ , "onmouseenter"
272+ , "onmouseleave"
273+ , "onmousemove"
274+ , "onmouseout"
275+ , "onmouseover"
276+ , "onmouseup"
277+ , "onoffline"
278+ , "ononline"
279+ , "onpagehide"
280+ , "onpageshow"
281+ , "onpaste"
282+ , "onpause"
283+ , "onplay"
284+ , "onplaying"
285+ , "onpopstate"
286+ , "onprogress"
287+ , "onratechange"
288+ , "onrejectionhandled"
289+ , "onreset"
290+ , "onresize"
291+ , "onscroll"
292+ , "onsecuritypolicyviolation"
293+ , "onseeked"
294+ , "onseeking"
295+ , "onselect"
296+ , "onstalled"
297+ , "onstorage"
298+ , "onsubmit"
299+ , "onsuspend"
300+ , "ontimeupdate"
301+ , "ontoggle"
302+ , "onunhandledrejection"
303+ , "onunload"
304+ , "onvolumechange"
305+ , "onwaiting"
306+ , "onwheel"
307+ , "open"
308+ , "optimum"
309+ , "pattern"
310+ , "ping"
311+ , "placeholder"
312+ , "playsinline"
313+ , "poster"
314+ , "preload"
315+ , "readonly"
316+ , "referrerpolicy"
317+ , "rel"
318+ , "required"
319+ , "reversed"
320+ , "role"
321+ , "rows"
322+ , "rowspan"
323+ , "sandbox"
324+ , "scope"
325+ , "selected"
326+ , "shape"
327+ , "size"
328+ , "sizes"
329+ , "slot"
330+ , "span"
331+ , "spellcheck"
332+ , "src"
333+ , "srcdoc"
334+ , "srclang"
335+ , "srcset"
336+ , "start"
337+ , "step"
338+ , "style"
339+ , "tabindex"
340+ , "target"
341+ , "title"
342+ , "translate"
343+ , "type"
344+ , "typemustmatch"
345+ , "updateviacache"
346+ , "usemap"
347+ , "value"
348+ , "width"
349+ , "workertype"
350+ , "wrap"
351+ ]
352+
353+-- See https://en.wikipedia.org/wiki/RDFa, https://www.w3.org/TR/rdfa-primer/
354+rdfaAttributes :: Set.Set Text
355+rdfaAttributes = Set.fromList
356+ [ "about"
357+ , "rel"
358+ , "rev"
359+ , "src"
360+ , "href"
361+ , "resource"
362+ , "property"
363+ , "content"
364+ , "datatype"
365+ , "typeof"
366+ , "vocab"
367+ , "prefix"
368+ ]
369+
370+html4Attributes :: Set.Set Text
371+html4Attributes = Set.fromList
372+ [ "abbr"
373+ , "accept"
374+ , "accept-charset"
375+ , "accesskey"
376+ , "action"
377+ , "align"
378+ , "alink"
379+ , "alt"
380+ , "archive"
381+ , "axis"
382+ , "background"
383+ , "bgcolor"
384+ , "border"
385+ , "cellpadding"
386+ , "cellspacing"
387+ , "char"
388+ , "charoff"
389+ , "charset"
390+ , "checked"
391+ , "cite"
392+ , "class"
393+ , "classid"
394+ , "clear"
395+ , "code"
396+ , "codebase"
397+ , "codetype"
398+ , "color"
399+ , "cols"
400+ , "colspan"
401+ , "compact"
402+ , "content"
403+ , "coords"
404+ , "data"
405+ , "datetime"
406+ , "declare"
407+ , "defer"
408+ , "dir"
409+ , "disabled"
410+ , "enctype"
411+ , "face"
412+ , "for"
413+ , "frame"
414+ , "frameborder"
415+ , "headers"
416+ , "height"
417+ , "href"
418+ , "hreflang"
419+ , "hspace"
420+ , "http-equiv"
421+ , "id"
422+ , "ismap"
423+ , "label"
424+ , "lang"
425+ , "language"
426+ , "link"
427+ , "longdesc"
428+ , "marginheight"
429+ , "marginwidth"
430+ , "maxlength"
431+ , "media"
432+ , "method"
433+ , "multiple"
434+ , "name"
435+ , "nohref"
436+ , "noresize"
437+ , "noshade"
438+ , "nowrap"
439+ , "object"
440+ , "onblur"
441+ , "onchange"
442+ , "onclick"
443+ , "ondblclick"
444+ , "onfocus"
445+ , "onkeydown"
446+ , "onkeypress"
447+ , "onkeyup"
448+ , "onload"
449+ , "onmousedown"
450+ , "onmousemove"
451+ , "onmouseout"
452+ , "onmouseover"
453+ , "onmouseup"
454+ , "onreset"
455+ , "onselect"
456+ , "onsubmit"
457+ , "onunload"
458+ , "profile"
459+ , "prompt"
460+ , "readonly"
461+ , "rel"
462+ , "rev"
463+ , "rows"
464+ , "rowspan"
465+ , "rules"
466+ , "scheme"
467+ , "scope"
468+ , "scrolling"
469+ , "selected"
470+ , "shape"
471+ , "size"
472+ , "span"
473+ , "src"
474+ , "standby"
475+ , "start"
476+ , "style"
477+ , "summary"
478+ , "tabindex"
479+ , "target"
480+ , "text"
481+ , "title"
482+ , "usemap"
483+ , "valign"
484+ , "value"
485+ , "valuetype"
486+ , "version"
487+ , "vlink"
488+ , "vspace"
489+ , "width"
490+ ]