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 = Parent "eref" "<eref" "</eref>"
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 = Parent "iref" "<iref" "</iref>"
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>"
126 page_ref :: DTC -> DTC
127 page_ref = Parent "page-ref" "<page-ref" "</page-ref>"
129 para = Parent "para" "<para" "</para>"
131 q = Parent "q" "<q" "</q>"
133 quote = Parent "quote" "<quote" "</quote>"
135 -- ref (Empty a) = Leaf "ref" "<ref" "/>" a
136 ref x = Parent "ref" "<ref" "</ref>" x
137 reference :: DTC -> DTC
138 reference = Parent "reference" "<reference" "</reference>"
139 references :: DTC -> DTC
140 references = Parent "references" "<references" "</references>"
142 refs = Parent "refs" "<refs" "</refs>"
144 sc = Parent "sc" "<sc" "</sc>"
145 section :: DTC -> DTC
146 section = Parent "section" "<section" "</section>"
148 span = Parent "span" "<span" "</span>"
150 sub = Parent "sub" "<sub" "</sub>"
152 sup = Parent "sup" "<sup" "</sup>"
154 -- tag (Empty a) = Leaf "tag" "<tag" "/>" a
155 tag = Parent "tag" "<tag" "</tag>"
156 tag_back :: DTC -> DTC
157 tag_back = Parent "tag-back" "<tag-back" "</tag-back>"
159 title = Parent "title" "<title" "</title>"
161 toc = Leaf "toc" "<toc" "/>" ()
163 tof = Parent "tof" "<tof" "</tof>"
165 u = Parent "u" "<u" "</u>"
167 ul = Parent "ul" "<ul" "</ul>"
168 version :: DTC -> DTC
169 version = Parent "version" "<version" "</version>"
171 isInlinedElement :: Text -> Bool
172 isInlinedElement = \case
186 instance Attrify Name where
187 attrify (Name a) = attrify a
188 instance MayAttr Name where
189 mayAttr a (Name t) = mayAttr a t