0 | module Language.XML.Misc
 1 |
 2 | import Data.String.Parser
 3 |
 4 | public export
 5 | data Misc = Comment String | ProcessingInstruction String String
 6 |
 7 | %name Misc misc
 8 |
 9 | export
10 | Show Misc where
11 |     show (Comment comment) = "<!--\{comment}-->"
12 |     show (ProcessingInstruction target instruction) = "<?\{target} \{instruction}?>"
13 |
14 | export
15 | comment : Parser Misc
16 | comment = (map Comment (string "<!--" *> takeUntil "-->")) <?> "XML comment"
17 |
18 | export
19 | processingInstruction : Parser Misc
20 | processingInstruction = (do
21 |     ignore $ string "<?"
22 |     target <- pack <$> many letter
23 |     spaces1
24 |     instruction <- takeUntil "?>"
25 |     pure $ ProcessingInstruction target instruction
26 |   ) <?> "XML processing instruction"
27 |
28 | export
29 | misc : Parser Misc
30 | misc = comment <|> processingInstruction
31 |