1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE RecordWildCards #-}
3 module Text.Blaze.DTC where
5 -- import Control.Monad (Monad(..))
8 import Data.Function (($), (.))
10 import Data.Maybe (Maybe(..))
11 import Data.Text (Text)
13 import Text.Blaze.Internal
14 import Text.Show (Show(..))
16 import Text.Blaze.Utils
17 import Text.Blaze.DTC.Attributes
22 xmlModel :: Text -> DTC
24 Leaf "xml-model" "<?xml-model" "?>\n" ()
25 ! attribute "type" " type=\"" "application/relax-ng-compact-syntax"
26 ! attribute "href" " href=\"" (attrValue rnc)
28 xmlStylesheet :: Text -> DTC
30 Leaf "xml-stylesheet" "<?xml-stylesheet" "?>\n" ()
31 ! attribute "type" " type=\"" "text/xsl"
32 ! attribute "href" " href=\"" (attrValue xsl)
34 html5Stylesheet :: Text -> DTC
36 Leaf "html5-stylesheet" "<?html5-stylesheet" "?>\n" ()
37 ! attribute "type" " type=\"" "text/xsl"
38 ! attribute "href" " href=\"" (attrValue xsl)
40 atomStylesheet :: Text -> DTC
42 Leaf "atom-stylesheet" "<?atom-stylesheet" "?>\n" ()
43 ! attribute "type" " type=\"" "text/xsl"
44 ! attribute "href" " href=\"" (attrValue xsl)
47 about = Parent "about" "<about" "</about>"
49 address = Parent "address" "<address" "</address>"
51 author = Parent "author" "<author" "</author>"
53 b = Parent "b" "<b" "</b>"
55 br = Leaf "br" "<br" " />" ()
57 call = Parent "call" "<call" "</call>"
59 code = Parent "code" "<code" "</code>"
65 , date_month :: Maybe Int
66 , date_day :: Maybe Int
70 Leaf "date" "<date" "/>" ()
71 ! attribute "year" " year=\"" (attrValue date_year)
72 !?? (date_month, attribute "month" " month=\"" . attrValue)
73 !?? (date_day, attribute "day" " day=\"" . attrValue)
76 define = Parent "define" "<define" "</define>"
77 document :: DTC -> DTC
78 document = Parent "document" "<document" "</document>"
80 editor = Parent "editor" "<editor" "</editor>"
82 email = Parent "email" "<email" "</email>"
84 eref = Parent "eref" "<eref" "</eref>"
86 i = Parent "i" "<i" "</i>"
87 include :: Bool -> AttributeValue -> DTC
89 Leaf "include" "<include" "/>" ()
90 !? (not inc, attribute "include" " include=\"" "no")
93 keyword = Parent "keyword" "<keyword" "</keyword>"
95 li = Parent "li" "<li" "</li>"
97 link = Parent "link" "<link" "</link>"
99 macro = Parent "macro" "<macro" "</macro>"
101 name = Parent "name" "<name" "</name>"
103 note = Parent "note" "<note" "</note>"
105 ol = Parent "ol" "<ol" "</ol>"
106 organization :: DTC -> DTC
107 organization = Parent "organization" "<organization" "</organization>"
109 para = Parent "para" "<para" "</para>"
111 q = Parent "q" "<q" "</q>"
113 quote = Parent "quote" "<quote" "</quote>"
115 ref (Empty a) = Leaf "ref" "<ref" "/>" a
116 ref x = Parent "ref" "<ref" "</ref>" x
117 reference :: DTC -> DTC
118 reference = Parent "reference" "<reference" "</reference>"
119 references :: DTC -> DTC
120 references = Parent "references" "<references" "</references>"
122 rref = Parent "rref" "<rref" "</rref>"
123 section :: DTC -> DTC
124 section = Parent "section" "<section" "</section>"
126 ul = Parent "ul" "<ul" "</ul>"
131 { postal_street :: Text
132 , postal_zipcode :: Text
133 , postal_city :: Text
134 , postal_region :: Text
135 , postal_country :: Text
137 postal :: Postal -> DTC
139 Parent "postal" "<postal" "</postal>" $ do
140 Parent "street" "<street" "</street>" $ toMarkup postal_street
141 Parent "zipcode" "<zipcode" "</zipcode>" $ toMarkup postal_zipcode
142 Parent "city" "<city" "</city>" $ toMarkup postal_city
143 Parent "region" "<region" "</region>" $ toMarkup postal_region
144 Parent "country" "<country" "</country>" $ toMarkup postal_country
146 indentTag :: Text -> IndentTag
149 "about" -> IndentTagChildren
150 "address" -> IndentTagChildren
151 "author" -> IndentTagChildren
152 "document" -> IndentTagChildren
153 "ol" -> IndentTagChildren
154 "postal" -> IndentTagChildren
155 "section" -> IndentTagChildren
156 "ul" -> IndentTagChildren
159 "li" -> IndentTagText
160 "para" -> IndentTagText
161 "quote" -> IndentTagText
162 "note" -> IndentTagText
163 _ -> IndentTagPreserve