Skip to content

Commit

Permalink
parse-string added
Browse files Browse the repository at this point in the history
parse HTML from a given string

parse-string test
  • Loading branch information
Robert Doroftei authored and kokosro committed Feb 20, 2014
1 parent 375490c commit d43e9e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/crouton/html.clj
Expand Up @@ -58,3 +58,8 @@
slurp
Jsoup/parse
as-clojure))

(defn parse-string
"Reads and parses the HTML from a suplied source text."
[string]
(as-clojure (Jsoup/parse string)))
8 changes: 8 additions & 0 deletions test/crouton/test/html.clj
Expand Up @@ -53,3 +53,11 @@
{:tag :html :attrs nil
:content [{:tag :head :attrs nil :content nil}
{:tag :body :attrs nil :content ["x & y"]}]}))))

(deftest test-parse-string
(testing "Elements"
(is (= (parse-string "<html><head></head><body></body></html>")
{:tag :html :attrs nil
:content [{:tag :head :attrs nil :content nil}
{:tag :body :attrs nil :content nil}]}))))

0 comments on commit d43e9e0

Please sign in to comment.