about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2014-10-12 00:51:52 +0100
committerAlan Pearce2014-10-12 00:51:52 +0100
commit8d3b9dc5f28587d0290ebf6f7c0bedf0866f5b62 (patch)
tree3496401a1dc9d5578bd29dc7244fc4c640df2e1f
parentb12efc0d46294c8c6295971360b67de28127175a (diff)
downloadmicroformats-8d3b9dc5f28587d0290ebf6f7c0bedf0866f5b62.tar.xz
microformats-8d3b9dc5f28587d0290ebf6f7c0bedf0866f5b62.zip
Parse multi-type properties on same element
-rw-r--r--src/microformats/parser.clj2
-rw-r--r--test/microformats/parser_expectations.clj9
2 files changed, 10 insertions, 1 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 9bc9d84..92104dc 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj
@@ -328,8 +328,8 @@
328 [loc] 328 [loc]
329 (when (and (not (z/end? loc)) 329 (when (and (not (z/end? loc))
330 (not (contains? #{:br :hr} (-> loc z/node :tag)))) 330 (not (contains? #{:br :hr} (-> loc z/node :tag))))
331 (if-let [class-groups (some->> loc z/node :attrs :class (re-seq #"(?:^|\s)(h|p|u|dt|e)-\w+") (map second) distinct first list)]
332 (map (partial parse-mf loc) class-groups) 331 (map (partial parse-mf loc) class-groups)
332 (if-let [types (some->> loc z/node :attrs :class (re-seq #"(?:^|\s)(h|p|u|dt|e)-\w+") (map second) set)]
333 (recur (z/next loc))))) 333 (recur (z/next loc)))))
334 334
335(defn continue-walking 335(defn continue-walking
diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index 654241c..15d41da 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/microformats/parser_expectations.clj
@@ -231,6 +231,15 @@
231<a class=\"u-url\" href=\"http://myblog.com\">My Blog</a> 231<a class=\"u-url\" href=\"http://myblog.com\">My Blog</a>
232</div>")) 232</div>"))
233 233
234(expect {:items '({:type ("h-card") :properties {:name ("Example User")
235 :url ("http://example.com"
236 "http://myblog.com")}})
237 :rels {}}
238 (parse "<div class=\"h-card\">
239<a class=\"u-url p-name\" href=\"http://example.com\">Example User</a>
240<a class=\"u-url\" href=\"http://myblog.com\">My Blog</a>
241</div>"))
242
234(expect {:items '({:type ("h-card") 243(expect {:items '({:type ("h-card")
235 :properties {:name ("Example") 244 :properties {:name ("Example")
236 :tel ("01234567890")}}) 245 :tel ("01234567890")}})