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 author = Parent "author" "<author" "</author>"
52 b = Parent "b" "<b" "</b>"
54 br = Leaf "br" "<br" " />" ()
56 call = Parent "call" "<call" "</call>"
58 code = Parent "code" "<code" "</code>"
64 , date_month :: Maybe Int
65 , date_day :: Maybe Int
69 Leaf "date" "<date" "/>" ()
70 ! attribute "year" " year=\"" (attrValue date_year)
71 !?? (date_month, attribute "month" " month=\"" . attrValue)
72 !?? (date_day, attribute "day" " day=\"" . attrValue)
75 define = Parent "define" "<define" "</define>"
76 document :: DTC -> DTC
77 document = Parent "document" "<document" "</document>"
79 editor = Parent "editor" "<editor" "</editor>"
81 email = Parent "email" "<email" "</email>"
83 eref = Parent "eref" "<eref" "</eref>"
85 i = Parent "i" "<i" "</i>"
86 include :: Bool -> AttributeValue -> DTC
88 Leaf "include" "<include" "/>" ()
89 !? (not inc, attribute "include" " include=\"" "no")
92 keyword = Parent "keyword" "<keyword" "</keyword>"
94 li = Parent "li" "<li" "</li>"
96 link = Parent "link" "<link" "</link>"
98 macro = Parent "macro" "<macro" "</macro>"
100 name = Parent "name" "<name" "</name>"
102 note = Parent "note" "<note" "</note>"
104 ol = Parent "ol" "<ol" "</ol>"
105 organization :: DTC -> DTC
106 organization = Parent "organization" "<organization" "</organization>"
108 para = Parent "para" "<para" "</para>"
110 q = Parent "q" "<q" "</q>"
112 quote = Parent "quote" "<quote" "</quote>"
114 ref (Empty a) = Leaf "ref" "<ref" "/>" a
115 ref x = Parent "ref" "<ref" "</ref>" x
116 reference :: DTC -> DTC
117 reference = Parent "reference" "<reference" "</reference>"
118 references :: DTC -> DTC
119 references = Parent "references" "<references" "</references>"
121 rref = Parent "rref" "<rref" "</rref>"
122 section :: DTC -> DTC
123 section = Parent "section" "<section" "</section>"
125 ul = Parent "ul" "<ul" "</ul>"
130 { postal_street :: Text
131 , postal_zipcode :: Text
132 , postal_city :: Text
133 , postal_region :: Text
134 , postal_country :: Text
136 postal :: Postal -> DTC
138 Parent "postal" "<postal" "</postal>" $ do
139 Parent "street" "<street" "</street>" $ toMarkup postal_street
140 Parent "zipcode" "<zipcode" "</zipcode>" $ toMarkup postal_zipcode
141 Parent "city" "<city" "</city>" $ toMarkup postal_city
142 Parent "region" "<region" "</region>" $ toMarkup postal_region
143 Parent "country" "<country" "</country>" $ toMarkup postal_country
145 indentTag :: Text -> IndentTag
148 "about" -> IndentTagChildren
149 "address" -> IndentTagChildren
150 "author" -> IndentTagChildren
151 "document" -> IndentTagChildren
152 "ol" -> IndentTagChildren
153 "postal" -> IndentTagChildren
154 "section" -> IndentTagChildren
155 "ul" -> IndentTagChildren
158 "li" -> IndentTagText
159 "para" -> IndentTagText
161 "quote" -> IndentTagText
162 "note" -> IndentTagText
163 _ -> IndentTagPreserve