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