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 at = Parent "at" "<at" "</at>"
50 at_back = Parent "at-back" "<at-back" "</at-back>"
52 artwork = Parent "artwork" "<artwork" "</artwork>"
54 aside = Parent "aside" "<aside" "</aside>"
56 author = Parent "author" "<author" "</author>"
58 b = Parent "b" "<b" "</b>"
60 br = Leaf "br" "<br" " />" ()
62 break = Leaf "break" "<break" " />" ()
64 call = Parent "call" "<call" "</call>"
66 code = Parent "code" "<code" "</code>"
67 comment :: Text -> DTC
68 comment t = Comment (Text t) ()
70 date = Leaf "date" "<date" "/>" ()
72 define = Parent "define" "<define" "</define>"
74 del = Parent "del" "<del" "</del>"
75 document :: DTC -> DTC
76 document = Parent "document" "<document" "</document>"
78 editor = Parent "editor" "<editor" "</editor>"
80 email = Parent "email" "<email" "</email>"
82 entity = Leaf "entity" "<entity" "/>" ()
84 eref (Empty a) = Leaf "eref" "<eref" "/>" a
85 eref x = Parent "eref" "<eref" "</eref>" x
87 figure = Parent "figure" "<figure" "</figure>"
89 grades = Parent "grades" "<grades" "</grades>"
91 i = Parent "i" "<i" "</i>"
92 include :: Bool -> DTC
93 include inc = Leaf "include" "<include" "/>" () !? (not inc, attribute "include" " include=\"" "no")
95 index = Parent "index" "<index" "</index>"
97 iref (Empty a) = Leaf "iref" "<iref" "/>" a
98 iref x = Parent "iref" "<iref" "</iref>" x
100 judges = Parent "judges" "<judges" "</judges>"
101 judgment :: DTC -> DTC
102 judgment = Parent "judgment" "<judgment" "</judgment>"
104 li = Parent "li" "<li" "</li>"
106 link = Parent "link" "<link" "</link>"
108 macro = Parent "macro" "<macro" "</macro>"
110 note = Parent "note" "<note" "</note>"
112 ol = Parent "ol" "<ol" "</ol>"
113 organization :: DTC -> DTC
114 organization = Parent "organization" "<organization" "</organization>"
116 p = Parent "p" "<p" "</p>"
118 para = Parent "para" "<para" "</para>"
120 q = Parent "q" "<q" "</q>"
122 quote = Parent "quote" "<quote" "</quote>"
124 ref (Empty a) = Leaf "ref" "<ref" "/>" a
125 ref x = Parent "ref" "<ref" "</ref>" x
126 reference :: DTC -> DTC
127 reference = Parent "reference" "<reference" "</reference>"
128 references :: DTC -> DTC
129 references = Parent "references" "<references" "</references>"
131 refs = Parent "refs" "<refs" "</refs>"
133 sc = Parent "sc" "<sc" "</sc>"
134 section :: DTC -> DTC
135 section = Parent "section" "<section" "</section>"
137 span = Parent "span" "<span" "</span>"
139 sub = Parent "sub" "<sub" "</sub>"
141 sup = Parent "sup" "<sup" "</sup>"
143 -- tag (Empty a) = Leaf "tag" "<tag" "/>" a
144 tag = Parent "tag" "<tag" "</tag>"
145 tag_back :: DTC -> DTC
146 tag_back = Parent "tag-back" "<tag-back" "</tag-back>"
148 title = Parent "title" "<title" "</title>"
150 toc = Leaf "toc" "<toc" "/>" ()
152 tof = Parent "tof" "<tof" "</tof>"
154 u = Parent "u" "<u" "</u>"
156 ul = Parent "ul" "<ul" "</ul>"
157 version :: DTC -> DTC
158 version = Parent "version" "<version" "</version>"
160 isInlinedElement :: Text -> Bool
161 isInlinedElement = \case
175 instance Attrify Name where
176 attrify (Name a) = attrify a
177 instance MayAttr Name where
178 mayAttr a (Name t) = mayAttr a t