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 = Parent "entity" "<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 head = Parent "head" "<head" "</head>"
93 i = Parent "i" "<i" "</i>"
94 include :: Bool -> DTC
95 include inc = Leaf "include" "<include" "/>" () !? (not inc, attribute "include" " include=\"" "no")
97 index = Parent "index" "<index" "</index>"
99 iref (Empty a) = Leaf "iref" "<iref" "/>" a
100 iref x = Parent "iref" "<iref" "</iref>" x
102 judges = Parent "judges" "<judges" "</judges>"
103 judgment :: DTC -> DTC
104 judgment = Parent "judgment" "<judgment" "</judgment>"
106 li = Parent "li" "<li" "</li>"
108 link = Parent "link" "<link" "</link>"
110 macro = Parent "macro" "<macro" "</macro>"
112 note = Parent "note" "<note" "</note>"
114 ol = Parent "ol" "<ol" "</ol>"
115 organization :: DTC -> DTC
116 organization = Parent "organization" "<organization" "</organization>"
118 p = Parent "p" "<p" "</p>"
120 para = Parent "para" "<para" "</para>"
122 q = Parent "q" "<q" "</q>"
124 quote = Parent "quote" "<quote" "</quote>"
126 ref (Empty a) = Leaf "ref" "<ref" "/>" a
127 ref x = Parent "ref" "<ref" "</ref>" x
128 reference :: DTC -> DTC
129 reference = Parent "reference" "<reference" "</reference>"
130 references :: DTC -> DTC
131 references = Parent "references" "<references" "</references>"
133 refs = Parent "refs" "<refs" "</refs>"
135 sc = Parent "sc" "<sc" "</sc>"
136 section :: DTC -> DTC
137 section = Parent "section" "<section" "</section>"
139 span = Parent "span" "<span" "</span>"
141 sub = Parent "sub" "<sub" "</sub>"
143 sup = Parent "sup" "<sup" "</sup>"
145 -- tag (Empty a) = Leaf "tag" "<tag" "/>" a
146 tag = Parent "tag" "<tag" "</tag>"
147 tag_back :: DTC -> DTC
148 tag_back = Parent "tag-back" "<tag-back" "</tag-back>"
150 title = Parent "title" "<title" "</title>"
152 toc = Leaf "toc" "<toc" "/>" ()
154 tof = Parent "tof" "<tof" "</tof>"
156 u = Parent "u" "<u" "</u>"
158 ul = Parent "ul" "<ul" "</ul>"
159 version :: DTC -> DTC
160 version = Parent "version" "<version" "</version>"
162 isInlinedElement :: Text -> Bool
163 isInlinedElement = \case
177 instance Attrify Name where
178 attrify (Name a) = attrify a
179 instance MayAttr Name where
180 mayAttr a (Name t) = mayAttr a t