1 {-# LANGUAGE OverloadedLists #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 module Text.Blaze.DTC where
7 import Data.Text (Text)
9 import Text.Blaze.Internal
11 import Text.Blaze.Utils
12 import Text.Blaze.XML (XML)
14 import Hdoc.DTC.Document
17 type DTC = Text.Blaze.XML.XML
19 xmlModel :: Text -> DTC
21 Leaf "xml-model" "<?xml-model" "?>\n" ()
22 ! attribute "type" " type=\"" "application/relax-ng-compact-syntax"
23 ! attribute "href" " href=\"" (attrify rnc)
25 xmlStylesheet :: Text -> DTC
27 Leaf "xml-stylesheet" "<?xml-stylesheet" "?>\n" ()
28 ! attribute "type" " type=\"" "text/xsl"
29 ! attribute "href" " href=\"" (attrify xsl)
31 html5Stylesheet :: Text -> DTC
33 Leaf "html5-stylesheet" "<?html5-stylesheet" "?>\n" ()
34 ! attribute "type" " type=\"" "text/xsl"
35 ! attribute "href" " href=\"" (attrify xsl)
37 atomStylesheet :: Text -> DTC
39 Leaf "atom-stylesheet" "<?atom-stylesheet" "?>\n" ()
40 ! attribute "type" " type=\"" "text/xsl"
41 ! attribute "href" " href=\"" (attrify xsl)
44 about = Parent "about" "<about" "</about>"
46 alias = Parent "alias" "<alias" "</alias>"
48 artwork = Parent "artwork" "<artwork" "</artwork>"
50 aside = Parent "aside" "<aside" "</aside>"
52 author = Parent "author" "<author" "</author>"
54 b = Parent "b" "<b" "</b>"
56 br = Leaf "br" "<br" " />" ()
58 break = Leaf "break" "<break" " />" ()
60 call = Parent "call" "<call" "</call>"
62 code = Parent "code" "<code" "</code>"
63 comment :: Text -> DTC
64 comment t = Comment (Text t) ()
66 date = Leaf "date" "<date" "/>" ()
68 define = Parent "define" "<define" "</define>"
70 del = Parent "del" "<del" "</del>"
71 document :: DTC -> DTC
72 document = Parent "document" "<document" "</document>"
74 editor = Parent "editor" "<editor" "</editor>"
76 email = Parent "email" "<email" "</email>"
78 entity = Leaf "entity" "<entity" "/>" ()
80 eref (Empty a) = Leaf "eref" "<eref" "/>" a
81 eref x = Parent "eref" "<eref" "</eref>" x
83 figure = Parent "figure" "<figure" "</figure>"
85 grades = Parent "grades" "<grades" "</grades>"
87 i = Parent "i" "<i" "</i>"
88 include :: Bool -> DTC
89 include inc = Leaf "include" "<include" "/>" () !? (not inc, attribute "include" " include=\"" "no")
91 index = Parent "index" "<index" "</index>"
93 iref (Empty a) = Leaf "iref" "<iref" "/>" a
94 iref x = Parent "iref" "<iref" "</iref>" x
96 judges = Parent "judges" "<judges" "</judges>"
97 judgment :: DTC -> DTC
98 judgment = Parent "judgment" "<judgment" "</judgment>"
100 li = Parent "li" "<li" "</li>"
102 link = Parent "link" "<link" "</link>"
104 macro = Parent "macro" "<macro" "</macro>"
106 note = Parent "note" "<note" "</note>"
108 ol = Parent "ol" "<ol" "</ol>"
109 organization :: DTC -> DTC
110 organization = Parent "organization" "<organization" "</organization>"
112 p = Parent "p" "<p" "</p>"
114 para = Parent "para" "<para" "</para>"
116 q = Parent "q" "<q" "</q>"
118 quote = Parent "quote" "<quote" "</quote>"
119 reference :: DTC -> DTC
120 reference = Parent "reference" "<reference" "</reference>"
121 references :: DTC -> DTC
122 references = Parent "references" "<references" "</references>"
124 rref (Empty a) = Leaf "rref" "<rref" "/>" a
125 rref x = Parent "rref" "<rref" "</rref>" x
127 sc = Parent "sc" "<sc" "</sc>"
128 section :: DTC -> DTC
129 section = Parent "section" "<section" "</section>"
131 span = Parent "span" "<span" "</span>"
133 sub = Parent "sub" "<sub" "</sub>"
135 sup = Parent "sup" "<sup" "</sup>"
137 -- tag (Empty a) = Leaf "tag" "<tag" "/>" a
138 tag = Parent "tag" "<tag" "</tag>"
140 title = Parent "title" "<title" "</title>"
142 toc = Leaf "toc" "<toc" "/>" ()
144 tof = Parent "tof" "<tof" "</tof>"
146 u = Parent "u" "<u" "</u>"
148 ul = Parent "ul" "<ul" "</ul>"
149 version :: DTC -> DTC
150 version = Parent "version" "<version" "</version>"
152 isInlinedElement :: Text -> Bool
153 isInlinedElement = \case
167 instance Attrify Name where
168 attrify (Name a) = attrify a
169 instance MayAttr Name where
170 mayAttr a (Name t) = mayAttr a t