]> Git — Sourcephile - doclang.git/blob - Text/Blaze/DTC.hs
Add basic support for HeaderDotSlash including.
[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 call :: DTC -> DTC
53 call = Parent "call" "<call" "</call>"
54 code :: DTC -> DTC
55 code = Parent "code" "<code" "</code>"
56 comment :: Text -> DTC
57 comment t = Comment (Text t) ()
58 date :: DTC
59 date = Leaf "date" "<date" "/>" ()
60 define :: DTC -> DTC
61 define = Parent "define" "<define" "</define>"
62 del :: DTC -> DTC
63 del = Parent "del" "<del" "</del>"
64 document :: DTC -> DTC
65 document = Parent "document" "<document" "</document>"
66 editor :: DTC -> DTC
67 editor = Parent "editor" "<editor" "</editor>"
68 email :: DTC -> DTC
69 email = Parent "email" "<email" "</email>"
70 entity :: DTC
71 entity = Leaf "entity" "<entity" "/>" ()
72 eref :: DTC -> DTC
73 eref (Empty a) = Leaf "eref" "<eref" "/>" a
74 eref x = Parent "eref" "<eref" "</eref>" x
75 figure :: DTC -> DTC
76 figure = Parent "figure" "<figure" "</figure>"
77 i :: DTC -> DTC
78 i = Parent "i" "<i" "</i>"
79 include :: Bool -> DTC
80 include inc =
81 Leaf "include" "<include" "/>" ()
82 !? (not inc, attribute "include" " include=\"" "no")
83 index :: DTC -> DTC
84 index = Parent "index" "<index" "</index>"
85 iref :: DTC -> DTC
86 iref (Empty a) = Leaf "iref" "<iref" "/>" a
87 iref x = Parent "iref" "<iref" "</iref>" x
88 li :: DTC -> DTC
89 li = Parent "li" "<li" "</li>"
90 link :: DTC -> DTC
91 link = Parent "link" "<link" "</link>"
92 macro :: DTC -> DTC
93 macro = Parent "macro" "<macro" "</macro>"
94 note :: DTC -> DTC
95 note = Parent "note" "<note" "</note>"
96 ol :: DTC -> DTC
97 ol = Parent "ol" "<ol" "</ol>"
98 organization :: DTC -> DTC
99 organization = Parent "organization" "<organization" "</organization>"
100 p :: DTC -> DTC
101 p = Parent "p" "<p" "</p>"
102 para :: DTC -> DTC
103 para = Parent "para" "<para" "</para>"
104 q :: DTC -> DTC
105 q = Parent "q" "<q" "</q>"
106 quote :: DTC -> DTC
107 quote = Parent "quote" "<quote" "</quote>"
108 ref :: DTC -> DTC
109 ref (Empty a) = Leaf "ref" "<ref" "/>" a
110 ref x = Parent "ref" "<ref" "</ref>" x
111 reference :: DTC -> DTC
112 reference = Parent "reference" "<reference" "</reference>"
113 references :: DTC -> DTC
114 references = Parent "references" "<references" "</references>"
115 rref :: DTC -> DTC
116 rref (Empty a) = Leaf "rref" "<rref" "/>" a
117 rref x = Parent "rref" "<rref" "</rref>" x
118 sc :: DTC -> DTC
119 sc = Parent "sc" "<sc" "</sc>"
120 section :: DTC -> DTC
121 section = Parent "section" "<section" "</section>"
122 sub :: DTC -> DTC
123 sub = Parent "sub" "<sub" "</sub>"
124 sup :: DTC -> DTC
125 sup = Parent "sup" "<sup" "</sup>"
126 tag :: DTC -> DTC
127 tag = Parent "tag" "<tag" "</tag>"
128 title :: DTC -> DTC
129 title = Parent "title" "<title" "</title>"
130 toc :: DTC
131 toc = Leaf "toc" "<toc" "/>" ()
132 tof :: DTC -> DTC
133 tof = Parent "tof" "<tof" "</tof>"
134 u :: DTC -> DTC
135 u = Parent "u" "<u" "</u>"
136 ul :: DTC -> DTC
137 ul = Parent "ul" "<ul" "</ul>"
138 version :: DTC -> DTC
139 version = Parent "version" "<version" "</version>"
140
141 isInlinedElement :: Text -> Bool
142 isInlinedElement = \case
143 "a" -> True
144 "b" -> True
145 "br" -> True
146 "code" -> True
147 "em" -> True
148 "i" -> True
149 "note" -> True
150 "q" -> True
151 "u" -> True
152 _ -> False