1 {-# LANGUAGE OverloadedList #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE RecordWildCards #-}
4 module Text.Blaze.DTC where
8 import Data.Function (($), (.))
10 import Data.Maybe (Maybe(..))
11 import Data.Text (Text)
13 import Text.Blaze.Internal
14 import Text.Show (Show(..))
17 import Text.Blaze.Utils
18 import Text.Blaze.DTC.Attributes
23 xmlModel :: Text -> DTC
25 Leaf "xml-model" "<?xml-model" "?>\n" ()
26 ! attribute "type" " type=\"" "application/relax-ng-compact-syntax"
27 ! attribute "href" " href=\"" (attrValue rnc)
29 xmlStylesheet :: Text -> DTC
31 Leaf "xml-stylesheet" "<?xml-stylesheet" "?>\n" ()
32 ! attribute "type" " type=\"" "text/xsl"
33 ! attribute "href" " href=\"" (attrValue xsl)
35 html5Stylesheet :: Text -> DTC
37 Leaf "html5-stylesheet" "<?html5-stylesheet" "?>\n" ()
38 ! attribute "type" " type=\"" "text/xsl"
39 ! attribute "href" " href=\"" (attrValue xsl)
41 atomStylesheet :: Text -> DTC
43 Leaf "atom-stylesheet" "<?atom-stylesheet" "?>\n" ()
44 ! attribute "type" " type=\"" "text/xsl"
45 ! attribute "href" " href=\"" (attrValue xsl)
48 about = Parent "about" "<about" "</about>"
50 address = Parent "address" "<address" "</address>"
52 artwork = Parent "artwork" "<artwork" "</artwork>"
54 author = Parent "author" "<author" "</author>"
56 b = Parent "b" "<b" "</b>"
58 br = Leaf "br" "<br" " />" ()
60 call = Parent "call" "<call" "</call>"
62 code = Parent "code" "<code" "</code>"
68 , date_month :: Maybe Int
69 , date_day :: Maybe Int
73 Leaf "date" "<date" "/>" ()
74 ! attribute "year" " year=\"" (attrValue date_year)
75 !?? (date_month, attribute "month" " month=\"" . attrValue)
76 !?? (date_day, attribute "day" " day=\"" . attrValue)
79 define = Parent "define" "<define" "</define>"
80 document :: DTC -> DTC
81 document = Parent "document" "<document" "</document>"
83 editor = Parent "editor" "<editor" "</editor>"
85 email = Parent "email" "<email" "</email>"
87 eref (Empty a) = Leaf "eref" "<eref" "/>" a
88 eref x = Parent "eref" "<eref" "</eref>" x
90 figure = Parent "figure" "<figure" "</figure>"
92 i = Parent "i" "<i" "</i>"
93 include :: Bool -> AttributeValue -> DTC
95 Leaf "include" "<include" "/>" ()
96 !? (not inc, attribute "include" " include=\"" "no")
99 keyword = Parent "keyword" "<keyword" "</keyword>"
101 li = Parent "li" "<li" "</li>"
103 link = Parent "link" "<link" "</link>"
105 macro = Parent "macro" "<macro" "</macro>"
107 name = Parent "name" "<name" "</name>"
109 note = Parent "note" "<note" "</note>"
111 ol = Parent "ol" "<ol" "</ol>"
112 organization :: DTC -> DTC
113 organization = Parent "organization" "<organization" "</organization>"
115 para = Parent "para" "<para" "</para>"
117 q = Parent "q" "<q" "</q>"
119 quote = Parent "quote" "<quote" "</quote>"
121 ref (Empty a) = Leaf "ref" "<ref" "/>" a
122 ref x = Parent "ref" "<ref" "</ref>" x
123 reference :: DTC -> DTC
124 reference = Parent "reference" "<reference" "</reference>"
125 references :: DTC -> DTC
126 references = Parent "references" "<references" "</references>"
128 rref (Empty a) = Leaf "rref" "<rref" "/>" a
129 rref x = Parent "rref" "<rref" "</rref>" x
130 section :: DTC -> DTC
131 section = Parent "section" "<section" "</section>"
133 ul = Parent "ul" "<ul" "</ul>"
138 { postal_street :: Text
139 , postal_zipcode :: Text
140 , postal_city :: Text
141 , postal_region :: Text
142 , postal_country :: Text
144 postal :: Postal -> DTC
146 Parent "postal" "<postal" "</postal>" $ do
147 Parent "street" "<street" "</street>" $ toMarkup postal_street
148 Parent "zipcode" "<zipcode" "</zipcode>" $ toMarkup postal_zipcode
149 Parent "city" "<city" "</city>" $ toMarkup postal_city
150 Parent "region" "<region" "</region>" $ toMarkup postal_region
151 Parent "country" "<country" "</country>" $ toMarkup postal_country
153 indentTag :: Text -> IndentTag
156 "about" -> IndentTagChildren
157 "address" -> IndentTagChildren
158 "author" -> IndentTagChildren
159 "document" -> IndentTagChildren
160 "editor" -> IndentTagChildren
161 "figure" -> IndentTagChildren
162 "ol" -> IndentTagChildren
163 "postal" -> IndentTagChildren
164 "reference" -> IndentTagChildren
165 "references" -> IndentTagChildren
166 "section" -> IndentTagChildren
167 "ul" -> IndentTagChildren
171 "li" -> IndentTagText
172 "para" -> IndentTagText
174 "quote" -> IndentTagText
175 "note" -> IndentTagText
176 _ -> IndentTagPreserve