1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE RecordWildCards #-}
3 module Text.Blaze.DTC where
7 import Data.Function (($), (.))
9 import Data.Maybe (Maybe(..))
10 import Data.Text (Text)
12 import Text.Blaze.Internal
13 import Text.Show (Show(..))
15 import Text.Blaze.Utils
16 import Text.Blaze.DTC.Attributes
21 xmlModel :: Text -> DTC
23 Leaf "xml-model" "<?xml-model" "?>\n" ()
24 ! attribute "type" " type=\"" "application/relax-ng-compact-syntax"
25 ! attribute "href" " href=\"" (attrValue rnc)
27 xmlStylesheet :: Text -> DTC
29 Leaf "xml-stylesheet" "<?xml-stylesheet" "?>\n" ()
30 ! attribute "type" " type=\"" "text/xsl"
31 ! attribute "href" " href=\"" (attrValue xsl)
33 html5Stylesheet :: Text -> DTC
35 Leaf "html5-stylesheet" "<?html5-stylesheet" "?>\n" ()
36 ! attribute "type" " type=\"" "text/xsl"
37 ! attribute "href" " href=\"" (attrValue xsl)
39 atomStylesheet :: Text -> DTC
41 Leaf "atom-stylesheet" "<?atom-stylesheet" "?>\n" ()
42 ! attribute "type" " type=\"" "text/xsl"
43 ! attribute "href" " href=\"" (attrValue xsl)
46 about = Parent "about" "<about" "</about>"
48 address = Parent "address" "<address" "</address>"
50 artwork = Parent "artwork" "<artwork" "</artwork>"
52 author = Parent "author" "<author" "</author>"
54 b = Parent "b" "<b" "</b>"
56 br = Leaf "br" "<br" " />" ()
58 call = Parent "call" "<call" "</call>"
60 code = Parent "code" "<code" "</code>"
66 , date_month :: Maybe Int
67 , date_day :: Maybe Int
71 Leaf "date" "<date" "/>" ()
72 ! attribute "year" " year=\"" (attrValue date_year)
73 !?? (date_month, attribute "month" " month=\"" . attrValue)
74 !?? (date_day, attribute "day" " day=\"" . attrValue)
77 define = Parent "define" "<define" "</define>"
78 document :: DTC -> DTC
79 document = Parent "document" "<document" "</document>"
81 editor = Parent "editor" "<editor" "</editor>"
83 email = Parent "email" "<email" "</email>"
85 eref (Empty a) = Leaf "eref" "<eref" "/>" a
86 eref x = Parent "eref" "<eref" "</eref>" x
88 figure = Parent "figure" "<figure" "</figure>"
90 i = Parent "i" "<i" "</i>"
91 include :: Bool -> AttributeValue -> DTC
93 Leaf "include" "<include" "/>" ()
94 !? (not inc, attribute "include" " include=\"" "no")
97 keyword = Parent "keyword" "<keyword" "</keyword>"
99 li = Parent "li" "<li" "</li>"
101 link = Parent "link" "<link" "</link>"
103 macro = Parent "macro" "<macro" "</macro>"
105 name = Parent "name" "<name" "</name>"
107 note = Parent "note" "<note" "</note>"
109 ol = Parent "ol" "<ol" "</ol>"
110 organization :: DTC -> DTC
111 organization = Parent "organization" "<organization" "</organization>"
113 para = Parent "para" "<para" "</para>"
115 q = Parent "q" "<q" "</q>"
117 quote = Parent "quote" "<quote" "</quote>"
119 ref (Empty a) = Leaf "ref" "<ref" "/>" a
120 ref x = Parent "ref" "<ref" "</ref>" x
121 reference :: DTC -> DTC
122 reference = Parent "reference" "<reference" "</reference>"
123 references :: DTC -> DTC
124 references = Parent "references" "<references" "</references>"
126 rref (Empty a) = Leaf "rref" "<rref" "/>" a
127 rref x = Parent "rref" "<rref" "</rref>" x
128 section :: DTC -> DTC
129 section = Parent "section" "<section" "</section>"
131 ul = Parent "ul" "<ul" "</ul>"
136 { postal_street :: Text
137 , postal_zipcode :: Text
138 , postal_city :: Text
139 , postal_region :: Text
140 , postal_country :: Text
142 postal :: Postal -> DTC
144 Parent "postal" "<postal" "</postal>" $ do
145 Parent "street" "<street" "</street>" $ toMarkup postal_street
146 Parent "zipcode" "<zipcode" "</zipcode>" $ toMarkup postal_zipcode
147 Parent "city" "<city" "</city>" $ toMarkup postal_city
148 Parent "region" "<region" "</region>" $ toMarkup postal_region
149 Parent "country" "<country" "</country>" $ toMarkup postal_country
151 indentTag :: Text -> IndentTag
154 "about" -> IndentTagChildren
155 "address" -> IndentTagChildren
156 "author" -> IndentTagChildren
157 "document" -> IndentTagChildren
158 "figure" -> IndentTagChildren
159 "ol" -> IndentTagChildren
160 "postal" -> IndentTagChildren
161 "section" -> IndentTagChildren
162 "ul" -> IndentTagChildren
166 "li" -> IndentTagText
167 "para" -> IndentTagText
169 "quote" -> IndentTagText
170 "note" -> IndentTagText
171 _ -> IndentTagPreserve