about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/microformats/parser.clj10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index cf75a27..cebfcc7 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -258,9 +258,11 @@
 
 (defn select-h
   "Select top-level h-* elements within a HTML element."
-  [element]
-  (html/select element [[(html/attr-contains :class "h-")
-                         (html/but (parents (html/attr? :class)))]]))
+  [loc]
+  (when (not (z/end? loc))
+    (if (some->> loc z/node first :attrs :class (re-matcher #"(?:^|\s) h-\w"))
+      (z/node loc)
+      (recur (z/next loc)))))
 
 (defn parse-rel
   "Parse rel attributes of an HTML link element"
@@ -284,4 +286,4 @@
   "Parse a HTML string with microformats"
   [html]
   (let [document (html/html-snippet html)]
-    {:items (mapv parse-h (select-h document)) :rels (parse-rels document)}))
+    {:items (mapv parse-h (some->> document z/xml-zip select-h)) :rels (parse-rels document)}))