Permalink
Browse files

Added comment support for sexp-as-element

  • Loading branch information...
1 parent 63c610b commit 71ed615a0a865077978d3dafb5b21ec367ab0aeb @senior senior committed Dec 12, 2012
Showing with 8 additions and 0 deletions.
  1. +1 −0 src/main/clojure/clojure/data/xml.clj
  2. +7 −0 src/test/clojure/clojure/data/xml/test_sexp.clj
@@ -181,6 +181,7 @@
(defn sexp-element [tag attrs child]
(cond
(= :-cdata tag) (CData. (first child))
+ (= :-comment tag) (Comment. (first child))
:else (Element. tag attrs (mapcat as-elements child))))
(extend-protocol AsElements
@@ -43,3 +43,10 @@
[:-cdata "more not parsed <stuff"])]]]
(is (= xml-input
(sexp-as-element sexp-input)))))
+
+(deftest with-comment
+ (let [xml-input (element :tag {:attr "value"}
+ (element :body {} (xml-comment "comment <stuff<here<")))
+ sexp-input [:tag {:attr "value"} [:body {} [:-comment "comment <stuff<here<"]]]]
+ (is (= xml-input
+ (sexp-as-element sexp-input)))))

0 comments on commit 71ed615

Please sign in to comment.