]> Git — Sourcephile - doclang.git/blob - Text/Blaze/DTC.hs
Split TCT -> DTC parsing into TCT -> XML -> DTC.
[doclang.git] / Text / Blaze / DTC.hs
1 {-# LANGUAGE OverloadedLists #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE RecordWildCards #-}
4 module Text.Blaze.DTC where
5
6 import Data.Bool
7 import Data.Text (Text)
8 import Text.Blaze
9 import Text.Blaze.Internal
10
11 import Text.Blaze.Utils
12
13 -- * Type 'XML'
14 type XML = Markup
15
16 -- * Type 'DTC'
17 type DTC = XML
18
19 xmlModel :: Text -> DTC
20 xmlModel rnc =
21 Leaf "xml-model" "<?xml-model" "?>\n" ()
22 ! attribute "type" " type=\"" "application/relax-ng-compact-syntax"
23 ! attribute "href" " href=\"" (attrValue rnc)
24
25 xmlStylesheet :: Text -> DTC
26 xmlStylesheet xsl =
27 Leaf "xml-stylesheet" "<?xml-stylesheet" "?>\n" ()
28 ! attribute "type" " type=\"" "text/xsl"
29 ! attribute "href" " href=\"" (attrValue xsl)
30
31 html5Stylesheet :: Text -> DTC
32 html5Stylesheet xsl =
33 Leaf "html5-stylesheet" "<?html5-stylesheet" "?>\n" ()
34 ! attribute "type" " type=\"" "text/xsl"
35 ! attribute "href" " href=\"" (attrValue xsl)
36
37 atomStylesheet :: Text -> DTC
38 atomStylesheet xsl =
39 Leaf "atom-stylesheet" "<?atom-stylesheet" "?>\n" ()
40 ! attribute "type" " type=\"" "text/xsl"
41 ! attribute "href" " href=\"" (attrValue xsl)
42
43 about :: DTC -> DTC
44 about = Parent "about" "<about" "</about>"
45 alias :: DTC
46 alias = Leaf "alias" "<alias" "/>" ()
47 address :: DTC
48 address = Leaf "address" "<address" "/>" ()
49 artwork :: DTC -> DTC
50 artwork = Parent "artwork" "<artwork" "</artwork>"
51 author :: DTC -> DTC
52 author = Parent "author" "<author" "</author>"
53 b :: DTC -> DTC
54 b = Parent "b" "<b" "</b>"
55 br :: DTC
56 br = Leaf "br" "<br" " />" ()
57 call :: DTC -> DTC
58 call = Parent "call" "<call" "</call>"
59 code :: DTC -> DTC
60 code = Parent "code" "<code" "</code>"
61 comment :: Text -> DTC
62 comment t = Comment (Text t) ()
63 date :: DTC
64 date = Leaf "date" "<date" "/>" ()
65 define :: DTC -> DTC
66 define = Parent "define" "<define" "</define>"
67 del :: DTC -> DTC
68 del = Parent "del" "<del" "</del>"
69 document :: DTC -> DTC
70 document = Parent "document" "<document" "</document>"
71 editor :: DTC -> DTC
72 editor = Parent "editor" "<editor" "</editor>"
73 email :: DTC -> DTC
74 email = Parent "email" "<email" "</email>"
75 eref :: DTC -> DTC
76 eref (Empty a) = Leaf "eref" "<eref" "/>" a
77 eref x = Parent "eref" "<eref" "</eref>" x
78 figure :: DTC -> DTC
79 figure = Parent "figure" "<figure" "</figure>"
80 i :: DTC -> DTC
81 i = Parent "i" "<i" "</i>"
82 include :: Bool -> DTC
83 include inc =
84 Leaf "include" "<include" "/>" ()
85 !? (not inc, attribute "include" " include=\"" "no")
86 index :: DTC -> DTC
87 index = Parent "index" "<index" "</index>"
88 iref :: DTC -> DTC
89 iref (Empty a) = Leaf "iref" "<iref" "/>" a
90 iref x = Parent "iref" "<iref" "</iref>" x
91 keyword :: DTC -> DTC
92 keyword = Parent "keyword" "<keyword" "</keyword>"
93 li :: DTC -> DTC
94 li = Parent "li" "<li" "</li>"
95 link :: DTC -> DTC
96 link = Parent "link" "<link" "</link>"
97 macro :: DTC -> DTC
98 macro = Parent "macro" "<macro" "</macro>"
99 note :: DTC -> DTC
100 note = Parent "note" "<note" "</note>"
101 ol :: DTC -> DTC
102 ol = Parent "ol" "<ol" "</ol>"
103 organization :: DTC -> DTC
104 organization = Parent "organization" "<organization" "</organization>"
105 para :: DTC -> DTC
106 para = Parent "para" "<para" "</para>"
107 q :: DTC -> DTC
108 q = Parent "q" "<q" "</q>"
109 quote :: DTC -> DTC
110 quote = Parent "quote" "<quote" "</quote>"
111 ref :: DTC -> DTC
112 ref (Empty a) = Leaf "ref" "<ref" "/>" a
113 ref x = Parent "ref" "<ref" "</ref>" x
114 reference :: DTC -> DTC
115 reference = Parent "reference" "<reference" "</reference>"
116 rl :: DTC -> DTC
117 rl = Parent "rl" "<rl" "</rl>"
118 rref :: DTC -> DTC
119 rref (Empty a) = Leaf "rref" "<rref" "/>" a
120 rref x = Parent "rref" "<rref" "</rref>" x
121 sc :: DTC -> DTC
122 sc = Parent "sc" "<sc" "</sc>"
123 section :: DTC -> DTC
124 section = Parent "section" "<section" "</section>"
125 sub :: DTC -> DTC
126 sub = Parent "sub" "<sub" "</sub>"
127 sup :: DTC -> DTC
128 sup = Parent "sup" "<sup" "</sup>"
129 title :: DTC -> DTC
130 title = Parent "title" "<title" "</title>"
131 toc :: DTC
132 toc = Leaf "toc" "<toc" "/>" ()
133 tof :: DTC
134 tof = Leaf "tof" "<tof" "/>" ()
135 u :: DTC -> DTC
136 u = Parent "u" "<u" "</u>"
137 ul :: DTC -> DTC
138 ul = Parent "ul" "<ul" "</ul>"
139 version :: DTC -> DTC
140 version = Parent "version" "<version" "</version>"
141
142 indentTag :: Text -> IndentTag
143 indentTag t =
144 case t of
145 "about" -> IndentTagChildren
146 "address" -> IndentTagChildren
147 "author" -> IndentTagChildren
148 "document" -> IndentTagChildren
149 "editor" -> IndentTagChildren
150 "figure" -> IndentTagChildren
151 "ol" -> IndentTagChildren
152 "postal" -> IndentTagChildren
153 "reference" -> IndentTagChildren
154 "rl" -> IndentTagChildren
155 "section" -> IndentTagChildren
156 "ul" -> IndentTagChildren
157 "a" -> IndentTagText
158 "b" -> IndentTagText
159 "i" -> IndentTagText
160 "li" -> IndentTagText
161 "para" -> IndentTagText
162 "q" -> IndentTagText
163 "quote" -> IndentTagText
164 "note" -> IndentTagText
165 _ -> IndentTagPreserve