aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/data/format/xml.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/data/format/xml.lux22
1 files changed, 12 insertions, 10 deletions
diff --git a/stdlib/source/lux/data/format/xml.lux b/stdlib/source/lux/data/format/xml.lux
index 61215813b..0ed744b46 100644
--- a/stdlib/source/lux/data/format/xml.lux
+++ b/stdlib/source/lux/data/format/xml.lux
@@ -33,7 +33,7 @@
(p.after (l.this ">") (parser/wrap ">"))
(p.after (l.this "&") (parser/wrap "&"))
(p.after (l.this "'") (parser/wrap "'"))
- (p.after (l.this """) (parser/wrap "\""))))
+ (p.after (l.this """) (parser/wrap text.double-quote))))
(def: xml-unicode-escape-char^
(l.Lexer Text)
@@ -56,7 +56,7 @@
(def: xml-char^
(l.Lexer Text)
- (p.either (l.none-of "<>&'\"")
+ (p.either (l.none-of ($_ text/compose "<>&'" text.double-quote))
xml-escape-char^))
(def: xml-identifier
@@ -92,7 +92,7 @@
(def: attr-value^
(l.Lexer Text)
(let [value^ (l.some xml-char^)]
- (p.either (l.enclosed ["\"" "\""] value^)
+ (p.either (l.enclosed [text.double-quote text.double-quote] value^)
(l.enclosed ["'" "'"] value^))))
(def: attrs^
@@ -110,9 +110,9 @@
spaced^
(p.after (l.this "/"))
(l.enclosed ["<" ">"]))]
- (p.assert ($_ text/compose "Close tag does not match open tag.\n"
- "Expected: " (name/encode expected) "\n"
- " Actual: " (name/encode actual) "\n")
+ (p.assert ($_ text/compose "Close tag does not match open tag." text.new-line
+ "Expected: " (name/encode expected) text.new-line
+ " Actual: " (name/encode actual) text.new-line)
(name/= expected actual))))
(def: comment^
@@ -181,7 +181,7 @@
(text.replace-all "<" "&lt;")
(text.replace-all ">" "&gt;")
(text.replace-all "'" "&apos;")
- (text.replace-all "\"" "&quot;")))
+ (text.replace-all text.double-quote "&quot;")))
(def: (write-tag [namespace name])
(-> Tag Text)
@@ -194,12 +194,12 @@
(|> attrs
d.entries
(list/map (function (_ [key value])
- ($_ text/compose (write-tag key) "=" "\""(sanitize-value value) "\"")))
+ ($_ text/compose (write-tag key) "=" text.double-quote (sanitize-value value) text.double-quote)))
(text.join-with " ")))
(def: xml-header
Text
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
+ ($_ text/compose "<?xml version=" text.double-quote "1.0" text.double-quote " encoding=" text.double-quote "UTF-8" text.double-quote "?>"))
(def: #export (write input)
(-> XML Text)
@@ -254,10 +254,12 @@
(exception: #export (wrong-tag {tag Name})
(name/encode tag))
+(def: blank-line ($_ text/compose text.new-line text.new-line))
+
(exception: #export (unconsumed-inputs {inputs (List XML)})
(|> inputs
(list/map (:: Codec<Text,XML> encode))
- (text.join-with "\n\n")))
+ (text.join-with blank-line)))
(def: #export text
(Reader Text)