Parse multi-type properties on same element
2 files changed, 10 insertions(+), 1 deletion(-)
M src/microformats/parser.clj → src/microformats/parser.clj
@@ -328,8 +328,8 @@ "Walk HTML element tree for microformat properties." [loc] (when (and (not (z/end? loc)) (not (contains? #{:br :hr} (-> loc z/node :tag)))) - (if-let [class-groups (some->> loc z/node :attrs :class (re-seq #"(?:^|\s)(h|p|u|dt|e)-\w+") (map second) distinct first list)] (map (partial parse-mf loc) class-groups) + (if-let [types (some->> loc z/node :attrs :class (re-seq #"(?:^|\s)(h|p|u|dt|e)-\w+") (map second) set)] (recur (z/next loc))))) (defn continue-walking
M test/microformats/parser_expectations.clj → test/microformats/parser_expectations.clj
@@ -231,6 +231,15 @@ <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-card") :properties {:name ("Example User") + :url ("http://example.com" + "http://myblog.com")}}) + :rels {}} + (parse "<div class=\"h-card\"> +<a class=\"u-url p-name\" href=\"http://example.com\">Example User</a> +<a class=\"u-url\" href=\"http://myblog.com\">My Blog</a> +</div>")) + (expect {:items '({:type ("h-card") :properties {:name ("Example") :tel ("01234567890")}})