diff options
-rw-r--r-- | src/microformats/parser.clj | 11 | ||||
-rw-r--r-- | test/microformats/parser_expectations.clj | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 5786f7c..eee04c4 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -225,11 +225,12 @@ (defn get-mf-properties "Parse children of a microformat, returning a map of properties" [element] - (merge (parse-implied element) - (apply merge (map parse-p (html/select element [(html/attr-starts :class "p-")]))) - (apply merge (map parse-u (html/select element [(html/attr-starts :class "u-")]))) - (apply merge (map parse-dt (html/select element [(html/attr-starts :class "dt-")]))) - (apply merge (map parse-e (html/select element [(html/attr-starts :class "e-")]))))) + (let [cappend (partial merge-with concat)] + (merge (parse-implied element) + (apply cappend (map parse-p (html/select element [(html/attr-starts :class "p-")]))) + (apply cappend (map parse-u (html/select element [(html/attr-starts :class "u-")]))) + (apply cappend (map parse-dt (html/select element [(html/attr-starts :class "dt-")]))) + (apply cappend (map parse-e (html/select element [(html/attr-starts :class "e-")])))))) (defn parse-h "Parse h-* classes within a HTML element." diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index 5c9984d..893872c 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/microformats/parser_expectations.clj @@ -172,6 +172,15 @@ (expect {:items [{:type ["h-card"] :properties {:name '("Example User") :url '("http://example.com")}}] :rels {}} (parse "<div class=\"h-card\"><a href=\"http://example.com\">Example User</a></div>")) +(expect {:items [{:type ["h-card"] :properties {:name '("Example") + :url '("http://example.com" + "http://myblog.com")}}] + :rels {}} + (parse "<div class=\"h-card\"> +<p class=\"u-name\">Example</p> +<a class=\"u-url\" href=\"http://example.com\">My Website</a> +<a class=\"u-url\" href=\"http://myblog.com\">My Blog</a> +</div>")) (expect {:items [{:type ["h-adr"], |