{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Text.Blaze.DTC where import Data.Bool import Data.Text (Text) import Text.Blaze import Text.Blaze.Internal import qualified Symantic.XML as XML import qualified Data.Text.Lazy as TL import Text.Blaze.Utils import Text.Blaze.XML (XML) import Textphile.DTC.Document -- * Type 'DTC' type DTC = XML xmlns_dtc :: XML.Namespace xmlns_dtc = XML.Namespace (TL.pack "http://commonsoft.org/xml/2018/dtc.rnc") xmlModel :: Text -> DTC xmlModel rnc = Leaf "xml-model" "\n" () ! attribute "type" " type=\"" "application/relax-ng-compact-syntax" ! attribute "href" " href=\"" (attrify rnc) xmlStylesheet :: Text -> DTC xmlStylesheet xsl = Leaf "xml-stylesheet" "\n" () ! attribute "type" " type=\"" "text/xsl" ! attribute "href" " href=\"" (attrify xsl) html5Stylesheet :: Text -> DTC html5Stylesheet xsl = Leaf "html5-stylesheet" "\n" () ! attribute "type" " type=\"" "text/xsl" ! attribute "href" " href=\"" (attrify xsl) atomStylesheet :: Text -> DTC atomStylesheet xsl = Leaf "atom-stylesheet" "\n" () ! attribute "type" " type=\"" "text/xsl" ! attribute "href" " href=\"" (attrify xsl) about :: DTC -> DTC about = Parent "about" "" alias :: DTC -> DTC alias = Parent "alias" "" at :: DTC -> DTC at = Parent "at" "" at_back :: DTC -> DTC at_back = Parent "at-back" "" artwork :: DTC -> DTC artwork = Parent "artwork" "" aside :: DTC -> DTC aside = Parent "aside" "" author :: DTC -> DTC author = Parent "author" "" b :: DTC -> DTC b = Parent "b" "" br :: DTC br = Leaf "br" "" () break :: DTC break = Leaf "break" "" () call :: DTC -> DTC call = Parent "call" "" code :: DTC -> DTC code = Parent "code" "" comment :: Text -> DTC comment t = Comment (Text t) () date :: DTC date = Leaf "date" "" () define :: DTC -> DTC define = Parent "define" "" del :: DTC -> DTC del = Parent "del" "" document :: DTC -> DTC document = Parent "document" "" editor :: DTC -> DTC editor = Parent "editor" "" email :: DTC -> DTC email = Parent "email" "" entity :: DTC -> DTC entity = Parent "entity" "" eref :: DTC -> DTC -- eref (Empty a) = Leaf "eref" "" a eref = Parent "eref" "" figure :: DTC -> DTC figure = Parent "figure" "" grades :: DTC -> DTC grades = Parent "grades" "" head :: DTC -> DTC head = Parent "head" "" i :: DTC -> DTC i = Parent "i" "" include :: Bool -> DTC include inc = Leaf "include" "" () !? (not inc, attribute "include" " include=\"" "no") index :: DTC -> DTC index = Parent "index" "" iref :: DTC -> DTC -- iref (Empty a) = Leaf "iref" "" a iref = Parent "iref" "" judges :: DTC -> DTC judges = Parent "judges" "" judgment :: DTC -> DTC judgment = Parent "judgment" "" li :: DTC -> DTC li = Parent "li" "" link :: DTC -> DTC link = Parent "link" "" macro :: DTC -> DTC macro = Parent "macro" "" note :: DTC -> DTC note = Parent "note" "" ol :: DTC -> DTC ol = Parent "ol" "" org :: DTC -> DTC org = Parent "org" "" p :: DTC -> DTC p = Parent "p" "" page_ref :: DTC -> DTC page_ref = Parent "page-ref" "" para :: DTC -> DTC para = Parent "para" "" q :: DTC -> DTC q = Parent "q" "" quote :: DTC -> DTC quote = Parent "quote" "" ref :: DTC -> DTC -- ref (Empty a) = Leaf "ref" "" a ref x = Parent "ref" "" x reference :: DTC -> DTC reference = Parent "reference" "" references :: DTC -> DTC references = Parent "references" "" refs :: DTC -> DTC refs = Parent "refs" "" sc :: DTC -> DTC sc = Parent "sc" "" section :: DTC -> DTC section = Parent "section" "" span :: DTC -> DTC span = Parent "span" "" sub :: DTC -> DTC sub = Parent "sub" "" sup :: DTC -> DTC sup = Parent "sup" "" tag :: DTC -> DTC -- tag (Empty a) = Leaf "tag" "" a tag = Parent "tag" "" tag_back :: DTC -> DTC tag_back = Parent "tag-back" "" title :: DTC -> DTC title = Parent "title" "" toc :: DTC toc = Leaf "toc" "" () tof :: DTC -> DTC tof = Parent "tof" "" u :: DTC -> DTC u = Parent "u" "" ul :: DTC -> DTC ul = Parent "ul" "" version :: DTC -> DTC version = Parent "version" "" isInlinedElement :: Text -> Bool isInlinedElement = \case "a" -> True "b" -> True "br" -> True "code" -> True "em" -> True "i" -> True "note" -> True "q" -> True "u" -> True "sup" -> True "sub" -> True _ -> False instance Attrify Name where attrify (Name a) = attrify a instance MayAttr Name where mayAttr a (Name t) = mayAttr a t