diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/HTML.hs | 349 | ||||
-rw-r--r-- | src/Text/Pandoc/XML.hs | 353 |
2 files changed, 354 insertions, 348 deletions
diff --git a/src/Text/Pandoc/Writers/HTML.hs b/src/Text/Pandoc/Writers/HTML.hs index a393df6d0..6f78242b7 100644 --- a/src/Text/Pandoc/Writers/HTML.hs +++ b/src/Text/Pandoc/Writers/HTML.hs @@ -54,7 +54,8 @@ import Text.Pandoc.Templates (renderTemplate) import Text.Pandoc.Walk import Text.Pandoc.Writers.Math import Text.Pandoc.Writers.Shared -import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities) +import Text.Pandoc.XML (escapeStringForXML, fromEntities, toEntities, + html5Attributes, html4Attributes, rdfaAttributes) import qualified Text.Blaze.XHtml5 as H5 import qualified Text.Blaze.XHtml5.Attributes as A5 import Control.Monad.Except (throwError) @@ -1310,349 +1311,3 @@ isRawHtml f = do return $ f == Format "html" || ((html5 && f == Format "html5") || f == Format "html4") -html5Attributes :: Set.Set Text -html5Attributes = Set.fromList - [ "abbr" - , "accept" - , "accept-charset" - , "accesskey" - , "action" - , "allowfullscreen" - , "allowpaymentrequest" - , "allowusermedia" - , "alt" - , "as" - , "async" - , "autocomplete" - , "autofocus" - , "autoplay" - , "charset" - , "checked" - , "cite" - , "class" - , "color" - , "cols" - , "colspan" - , "content" - , "contenteditable" - , "controls" - , "coords" - , "crossorigin" - , "data" - , "datetime" - , "default" - , "defer" - , "dir" - , "dirname" - , "disabled" - , "download" - , "draggable" - , "enctype" - , "for" - , "form" - , "formaction" - , "formenctype" - , "formmethod" - , "formnovalidate" - , "formtarget" - , "headers" - , "height" - , "hidden" - , "high" - , "href" - , "hreflang" - , "http-equiv" - , "id" - , "inputmode" - , "integrity" - , "is" - , "ismap" - , "itemid" - , "itemprop" - , "itemref" - , "itemscope" - , "itemtype" - , "kind" - , "label" - , "lang" - , "list" - , "loop" - , "low" - , "manifest" - , "max" - , "maxlength" - , "media" - , "method" - , "min" - , "minlength" - , "multiple" - , "muted" - , "name" - , "nomodule" - , "nonce" - , "novalidate" - , "onabort" - , "onafterprint" - , "onauxclick" - , "onbeforeprint" - , "onbeforeunload" - , "onblur" - , "oncancel" - , "oncanplay" - , "oncanplaythrough" - , "onchange" - , "onclick" - , "onclose" - , "oncontextmenu" - , "oncopy" - , "oncuechange" - , "oncut" - , "ondblclick" - , "ondrag" - , "ondragend" - , "ondragenter" - , "ondragexit" - , "ondragleave" - , "ondragover" - , "ondragstart" - , "ondrop" - , "ondurationchange" - , "onemptied" - , "onended" - , "onerror" - , "onfocus" - , "onhashchange" - , "oninput" - , "oninvalid" - , "onkeydown" - , "onkeypress" - , "onkeyup" - , "onlanguagechange" - , "onload" - , "onloadeddata" - , "onloadedmetadata" - , "onloadend" - , "onloadstart" - , "onmessage" - , "onmessageerror" - , "onmousedown" - , "onmouseenter" - , "onmouseleave" - , "onmousemove" - , "onmouseout" - , "onmouseover" - , "onmouseup" - , "onoffline" - , "ononline" - , "onpagehide" - , "onpageshow" - , "onpaste" - , "onpause" - , "onplay" - , "onplaying" - , "onpopstate" - , "onprogress" - , "onratechange" - , "onrejectionhandled" - , "onreset" - , "onresize" - , "onscroll" - , "onsecuritypolicyviolation" - , "onseeked" - , "onseeking" - , "onselect" - , "onstalled" - , "onstorage" - , "onsubmit" - , "onsuspend" - , "ontimeupdate" - , "ontoggle" - , "onunhandledrejection" - , "onunload" - , "onvolumechange" - , "onwaiting" - , "onwheel" - , "open" - , "optimum" - , "pattern" - , "ping" - , "placeholder" - , "playsinline" - , "poster" - , "preload" - , "readonly" - , "referrerpolicy" - , "rel" - , "required" - , "reversed" - , "role" - , "rows" - , "rowspan" - , "sandbox" - , "scope" - , "selected" - , "shape" - , "size" - , "sizes" - , "slot" - , "span" - , "spellcheck" - , "src" - , "srcdoc" - , "srclang" - , "srcset" - , "start" - , "step" - , "style" - , "tabindex" - , "target" - , "title" - , "translate" - , "type" - , "typemustmatch" - , "updateviacache" - , "usemap" - , "value" - , "width" - , "workertype" - , "wrap" - ] - --- See https://en.wikipedia.org/wiki/RDFa, https://www.w3.org/TR/rdfa-primer/ -rdfaAttributes :: Set.Set Text -rdfaAttributes = Set.fromList - [ "about" - , "rel" - , "rev" - , "src" - , "href" - , "resource" - , "property" - , "content" - , "datatype" - , "typeof" - , "vocab" - , "prefix" - ] - -html4Attributes :: Set.Set Text -html4Attributes = Set.fromList - [ "abbr" - , "accept" - , "accept-charset" - , "accesskey" - , "action" - , "align" - , "alink" - , "alt" - , "archive" - , "axis" - , "background" - , "bgcolor" - , "border" - , "cellpadding" - , "cellspacing" - , "char" - , "charoff" - , "charset" - , "checked" - , "cite" - , "class" - , "classid" - , "clear" - , "code" - , "codebase" - , "codetype" - , "color" - , "cols" - , "colspan" - , "compact" - , "content" - , "coords" - , "data" - , "datetime" - , "declare" - , "defer" - , "dir" - , "disabled" - , "enctype" - , "face" - , "for" - , "frame" - , "frameborder" - , "headers" - , "height" - , "href" - , "hreflang" - , "hspace" - , "http-equiv" - , "id" - , "ismap" - , "label" - , "lang" - , "language" - , "link" - , "longdesc" - , "marginheight" - , "marginwidth" - , "maxlength" - , "media" - , "method" - , "multiple" - , "name" - , "nohref" - , "noresize" - , "noshade" - , "nowrap" - , "object" - , "onblur" - , "onchange" - , "onclick" - , "ondblclick" - , "onfocus" - , "onkeydown" - , "onkeypress" - , "onkeyup" - , "onload" - , "onmousedown" - , "onmousemove" - , "onmouseout" - , "onmouseover" - , "onmouseup" - , "onreset" - , "onselect" - , "onsubmit" - , "onunload" - , "profile" - , "prompt" - , "readonly" - , "rel" - , "rev" - , "rows" - , "rowspan" - , "rules" - , "scheme" - , "scope" - , "scrolling" - , "selected" - , "shape" - , "size" - , "span" - , "src" - , "standby" - , "start" - , "style" - , "summary" - , "tabindex" - , "target" - , "text" - , "title" - , "usemap" - , "valign" - , "value" - , "valuetype" - , "version" - , "vlink" - , "vspace" - , "width" - ] diff --git a/src/Text/Pandoc/XML.hs b/src/Text/Pandoc/XML.hs index 21f6d4d46..64dd62c0f 100644 --- a/src/Text/Pandoc/XML.hs +++ b/src/Text/Pandoc/XML.hs @@ -20,7 +20,10 @@ module Text.Pandoc.XML ( escapeCharForXML, inTagsIndented, toEntities, toHtml5Entities, - fromEntities ) where + fromEntities, + html4Attributes, + html5Attributes, + rdfaAttributes ) where import Prelude import Data.Char (isAscii, isSpace, ord) @@ -31,6 +34,7 @@ import Text.DocLayout import Text.Printf (printf) import qualified Data.Map as M import Data.String +import qualified Data.Set as Set -- | Escape one character as needed for XML. escapeCharForXML :: Char -> Text @@ -137,3 +141,350 @@ fromEntities' (T.uncons -> Just ('&', xs)) = fromEntities' t = case T.uncons t of Just (x, xs) -> x : fromEntities' xs Nothing -> "" + +html5Attributes :: Set.Set Text +html5Attributes = Set.fromList + [ "abbr" + , "accept" + , "accept-charset" + , "accesskey" + , "action" + , "allowfullscreen" + , "allowpaymentrequest" + , "allowusermedia" + , "alt" + , "as" + , "async" + , "autocomplete" + , "autofocus" + , "autoplay" + , "charset" + , "checked" + , "cite" + , "class" + , "color" + , "cols" + , "colspan" + , "content" + , "contenteditable" + , "controls" + , "coords" + , "crossorigin" + , "data" + , "datetime" + , "default" + , "defer" + , "dir" + , "dirname" + , "disabled" + , "download" + , "draggable" + , "enctype" + , "for" + , "form" + , "formaction" + , "formenctype" + , "formmethod" + , "formnovalidate" + , "formtarget" + , "headers" + , "height" + , "hidden" + , "high" + , "href" + , "hreflang" + , "http-equiv" + , "id" + , "inputmode" + , "integrity" + , "is" + , "ismap" + , "itemid" + , "itemprop" + , "itemref" + , "itemscope" + , "itemtype" + , "kind" + , "label" + , "lang" + , "list" + , "loop" + , "low" + , "manifest" + , "max" + , "maxlength" + , "media" + , "method" + , "min" + , "minlength" + , "multiple" + , "muted" + , "name" + , "nomodule" + , "nonce" + , "novalidate" + , "onabort" + , "onafterprint" + , "onauxclick" + , "onbeforeprint" + , "onbeforeunload" + , "onblur" + , "oncancel" + , "oncanplay" + , "oncanplaythrough" + , "onchange" + , "onclick" + , "onclose" + , "oncontextmenu" + , "oncopy" + , "oncuechange" + , "oncut" + , "ondblclick" + , "ondrag" + , "ondragend" + , "ondragenter" + , "ondragexit" + , "ondragleave" + , "ondragover" + , "ondragstart" + , "ondrop" + , "ondurationchange" + , "onemptied" + , "onended" + , "onerror" + , "onfocus" + , "onhashchange" + , "oninput" + , "oninvalid" + , "onkeydown" + , "onkeypress" + , "onkeyup" + , "onlanguagechange" + , "onload" + , "onloadeddata" + , "onloadedmetadata" + , "onloadend" + , "onloadstart" + , "onmessage" + , "onmessageerror" + , "onmousedown" + , "onmouseenter" + , "onmouseleave" + , "onmousemove" + , "onmouseout" + , "onmouseover" + , "onmouseup" + , "onoffline" + , "ononline" + , "onpagehide" + , "onpageshow" + , "onpaste" + , "onpause" + , "onplay" + , "onplaying" + , "onpopstate" + , "onprogress" + , "onratechange" + , "onrejectionhandled" + , "onreset" + , "onresize" + , "onscroll" + , "onsecuritypolicyviolation" + , "onseeked" + , "onseeking" + , "onselect" + , "onstalled" + , "onstorage" + , "onsubmit" + , "onsuspend" + , "ontimeupdate" + , "ontoggle" + , "onunhandledrejection" + , "onunload" + , "onvolumechange" + , "onwaiting" + , "onwheel" + , "open" + , "optimum" + , "pattern" + , "ping" + , "placeholder" + , "playsinline" + , "poster" + , "preload" + , "readonly" + , "referrerpolicy" + , "rel" + , "required" + , "reversed" + , "role" + , "rows" + , "rowspan" + , "sandbox" + , "scope" + , "selected" + , "shape" + , "size" + , "sizes" + , "slot" + , "span" + , "spellcheck" + , "src" + , "srcdoc" + , "srclang" + , "srcset" + , "start" + , "step" + , "style" + , "tabindex" + , "target" + , "title" + , "translate" + , "type" + , "typemustmatch" + , "updateviacache" + , "usemap" + , "value" + , "width" + , "workertype" + , "wrap" + ] + +-- See https://en.wikipedia.org/wiki/RDFa, https://www.w3.org/TR/rdfa-primer/ +rdfaAttributes :: Set.Set Text +rdfaAttributes = Set.fromList + [ "about" + , "rel" + , "rev" + , "src" + , "href" + , "resource" + , "property" + , "content" + , "datatype" + , "typeof" + , "vocab" + , "prefix" + ] + +html4Attributes :: Set.Set Text +html4Attributes = Set.fromList + [ "abbr" + , "accept" + , "accept-charset" + , "accesskey" + , "action" + , "align" + , "alink" + , "alt" + , "archive" + , "axis" + , "background" + , "bgcolor" + , "border" + , "cellpadding" + , "cellspacing" + , "char" + , "charoff" + , "charset" + , "checked" + , "cite" + , "class" + , "classid" + , "clear" + , "code" + , "codebase" + , "codetype" + , "color" + , "cols" + , "colspan" + , "compact" + , "content" + , "coords" + , "data" + , "datetime" + , "declare" + , "defer" + , "dir" + , "disabled" + , "enctype" + , "face" + , "for" + , "frame" + , "frameborder" + , "headers" + , "height" + , "href" + , "hreflang" + , "hspace" + , "http-equiv" + , "id" + , "ismap" + , "label" + , "lang" + , "language" + , "link" + , "longdesc" + , "marginheight" + , "marginwidth" + , "maxlength" + , "media" + , "method" + , "multiple" + , "name" + , "nohref" + , "noresize" + , "noshade" + , "nowrap" + , "object" + , "onblur" + , "onchange" + , "onclick" + , "ondblclick" + , "onfocus" + , "onkeydown" + , "onkeypress" + , "onkeyup" + , "onload" + , "onmousedown" + , "onmousemove" + , "onmouseout" + , "onmouseover" + , "onmouseup" + , "onreset" + , "onselect" + , "onsubmit" + , "onunload" + , "profile" + , "prompt" + , "readonly" + , "rel" + , "rev" + , "rows" + , "rowspan" + , "rules" + , "scheme" + , "scope" + , "scrolling" + , "selected" + , "shape" + , "size" + , "span" + , "src" + , "standby" + , "start" + , "style" + , "summary" + , "tabindex" + , "target" + , "text" + , "title" + , "usemap" + , "valign" + , "value" + , "valuetype" + , "version" + , "vlink" + , "vspace" + , "width" + ] |