all repos — archive/microformats @ b1e28b8b122a46951ab8e17f010ab58fd06f9524

Incomplete Clojure microformats library

Fix parse failure with spaces preceding HTML

Alan Pearce
commit

b1e28b8b122a46951ab8e17f010ab58fd06f9524

parent

5cc13ae3cec7a1778df2994d27a5594004f9a45a

2 files changed, 4 insertions(+), 1 deletion(-)

jump to
M src/microformats/parser.cljsrc/microformats/parser.clj
@@ -279,5 +279,5 @@
(defn parse "Parse a HTML string with microformats" [html] - (let [document (html/html-snippet html)] + (let [document (html/html-snippet (str/trim html))] {:items (mapv parse-h (some->> document z/xml-zip select-h)) :rels (parse-rels document)}))
M test/microformats/parser_expectations.cljtest/microformats/parser_expectations.clj
@@ -149,6 +149,9 @@
(expect {:items [{:properties {:name '("Example User")} :type ["h-card"]}] :rels {}} (parse "<div class=\"h-card\"><p class=\"p-name\"> Example User </p></div>")) +(expect {:items [{:properties {:name '("Example User")} :type ["h-card"]}] :rels {}} + (parse " <div class=\"h-card\"><p class=\"p-name\">Example User</p></div>")) + (expect {:items [{:properties {:name '("Example User") :url '("http://example.com")} :type ["h-card"]}] :rels {}} (parse "<div class=\"h-card\"><a class=\"p-name u-url\" href=\"http://example.com\">Example User</></div>"))