about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/microformats/parser.clj30
1 files changed, 21 insertions, 9 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 94f0110..764594e 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -87,26 +87,38 @@
 (defn parse-p
   "Parse p-* classes within HTML element."
   [element]
-  (let [value (get-p-value element)]
-    (into {} (r/map #(hash-map % value) ((classes-to-props "p-") (element-to-classes element))))))
+  (->> element
+       element-to-classes
+       ((classes-to-props "p-"))
+       (r/map #(hash-map % (get-p-value element)))
+       (into {})))
 
 (defn parse-u
   "Parse u-* classes within HTML element"
   [element]
-  (let [value (get-u-value element)]
-    (into {} (r/map #(hash-map % value) ((classes-to-props "u-") (element-to-classes element))))))
+  (->> element
+       element-to-classes
+       ((classes-to-props "u-"))
+       (r/map #(hash-map % (get-u-value element)))
+       (into {})))
 
 (defn parse-dt
   "Parse dt-* classes within HTML element"
   [element]
-  (let [value (get-dt-value element)]
-    (into {} (r/map #(hash-map % value) ((classes-to-props "dt-") (element-to-classes element))))))
+  (->> element
+       element-to-classes
+       ((classes-to-props "dt-"))
+       (r/map #(hash-map % (get-dt-value element)))
+       (into {})))
 
 (defn parse-e
   "Parse e-* classes within HTML element"
   [element]
-  (let [value (get-e-value element)]
-    (into {} (r/map #(hash-map % value) ((classes-to-props "e-") (element-to-classes element))))))
+  (->> element
+       element-to-classes
+       ((classes-to-props "e-"))
+       (r/map #(hash-map % (get-e-value element)))
+       (into {})))
 
 (defn parse-children
   "Parse element children for microformats"
@@ -115,7 +127,7 @@
                                                      (html/attr-starts :class "u-")
                                                      (html/attr-starts :class "dt-")
                                                      (html/attr-starts :class "e-")])]))]
-    (hash-map :properties (merge (parse-p el) (parse-u el)))))
+    (hash-map :properties (merge ((juxt parse-p parse-u parse-dt parse-e))))))
 
 (defn parse-h
   "Parse h-* classes within a HTML document."