diff options
-rw-r--r-- | src/microformats/parser.clj | 2 | ||||
-rw-r--r-- | test/microformats/parser_expectations.clj | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 9377d4a..32d0331 100644 --- a/src/microformats/parser.clj +++ b/src/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)})) diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index 5f8eeef..1cbeedd 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/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>")) |