1 {-# LANGUAGE OverloadedLists #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# OPTIONS_GHC -fno-warn-orphans #-}
4 module Text.Blaze.DTC where
7 import Data.Text (Text)
9 import Text.Blaze.Internal
10 import qualified Language.Symantic.XML as XML
11 import qualified Data.Text.Lazy as TL
13 import Text.Blaze.Utils
14 import Text.Blaze.XML (XML)
16 import Hdoc.DTC.Document
21 xmlns_dtc :: XML.Namespace
22 xmlns_dtc = XML.Namespace (TL.pack "http://commonsoft.org/xml/2018/dtc.rnc")
24 xmlModel :: Text -> DTC
26 Leaf "xml-model" "<?xml-model" "?>\n" ()
27 ! attribute "type" " type=\"" "application/relax-ng-compact-syntax"
28 ! attribute "href" " href=\"" (attrify rnc)
30 xmlStylesheet :: Text -> DTC
32 Leaf "xml-stylesheet" "<?xml-stylesheet" "?>\n" ()
33 ! attribute "type" " type=\"" "text/xsl"
34 ! attribute "href" " href=\"" (attrify xsl)
36 html5Stylesheet :: Text -> DTC
38 Leaf "html5-stylesheet" "<?html5-stylesheet" "?>\n" ()
39 ! attribute "type" " type=\"" "text/xsl"
40 ! attribute "href" " href=\"" (attrify xsl)
42 atomStylesheet :: Text -> DTC
44 Leaf "atom-stylesheet" "<?atom-stylesheet" "?>\n" ()
45 ! attribute "type" " type=\"" "text/xsl"
46 ! attribute "href" " href=\"" (attrify xsl)
49 about = Parent "about" "<about" "</about>"
51 alias = Parent "alias" "<alias" "</alias>"
53 at = Parent "at" "<at" "</at>"
55 at_back = Parent "at-back" "<at-back" "</at-back>"
57 artwork = Parent "artwork" "<artwork" "</artwork>"
59 aside = Parent "aside" "<aside" "</aside>"
61 author = Parent "author" "<author" "</author>"
63 b = Parent "b" "<b" "</b>"
65 br = Leaf "br" "<br" " />" ()
67 break = Leaf "break" "<break" " />" ()
69 call = Parent "call" "<call" "</call>"
71 code = Parent "code" "<code" "</code>"
72 comment :: Text -> DTC
73 comment t = Comment (Text t) ()
75 date = Leaf "date" "<date" "/>" ()
77 define = Parent "define" "<define" "</define>"
79 del = Parent "del" "<del" "</del>"
80 document :: DTC -> DTC
81 document = Parent "document" "<document" "</document>"
83 editor = Parent "editor" "<editor" "</editor>"
85 email = Parent "email" "<email" "</email>"
87 entity = Parent "entity" "<entity" "</entity>"
89 eref (Empty a) = Leaf "eref" "<eref" "/>" a
90 eref x = Parent "eref" "<eref" "</eref>" x
92 figure = Parent "figure" "<figure" "</figure>"
94 grades = Parent "grades" "<grades" "</grades>"
96 head = Parent "head" "<head" "</head>"
98 i = Parent "i" "<i" "</i>"
99 include :: Bool -> DTC
101 Leaf "include" "<include" "/>" ()
102 !? (not inc, attribute "include" " include=\"" "no")
104 index = Parent "index" "<index" "</index>"
106 iref (Empty a) = Leaf "iref" "<iref" "/>" a
107 iref x = Parent "iref" "<iref" "</iref>" x
109 judges = Parent "judges" "<judges" "</judges>"
110 judgment :: DTC -> DTC
111 judgment = Parent "judgment" "<judgment" "</judgment>"
113 li = Parent "li" "<li" "</li>"
115 link = Parent "link" "<link" "</link>"
117 macro = Parent "macro" "<macro" "</macro>"
119 note = Parent "note" "<note" "</note>"
121 ol = Parent "ol" "<ol" "</ol>"
123 org = Parent "org" "<org" "</org>"
125 p = Parent "p" "<p" "</p>"
127 para = Parent "para" "<para" "</para>"
129 q = Parent "q" "<q" "</q>"
131 quote = Parent "quote" "<quote" "</quote>"
133 ref (Empty a) = Leaf "ref" "<ref" "/>" a
134 ref x = Parent "ref" "<ref" "</ref>" x
135 reference :: DTC -> DTC
136 reference = Parent "reference" "<reference" "</reference>"
137 references :: DTC -> DTC
138 references = Parent "references" "<references" "</references>"
140 refs = Parent "refs" "<refs" "</refs>"
142 sc = Parent "sc" "<sc" "</sc>"
143 section :: DTC -> DTC
144 section = Parent "section" "<section" "</section>"
146 span = Parent "span" "<span" "</span>"
148 sub = Parent "sub" "<sub" "</sub>"
150 sup = Parent "sup" "<sup" "</sup>"
152 -- tag (Empty a) = Leaf "tag" "<tag" "/>" a
153 tag = Parent "tag" "<tag" "</tag>"
154 tag_back :: DTC -> DTC
155 tag_back = Parent "tag-back" "<tag-back" "</tag-back>"
157 title = Parent "title" "<title" "</title>"
159 toc = Leaf "toc" "<toc" "/>" ()
161 tof = Parent "tof" "<tof" "</tof>"
163 u = Parent "u" "<u" "</u>"
165 ul = Parent "ul" "<ul" "</ul>"
166 version :: DTC -> DTC
167 version = Parent "version" "<version" "</version>"
169 isInlinedElement :: Text -> Bool
170 isInlinedElement = \case
184 instance Attrify Name where
185 attrify (Name a) = attrify a
186 instance MayAttr Name where
187 mayAttr a (Name t) = mayAttr a t