about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2014-09-24 18:51:15 +0100
committerAlan Pearce2014-09-24 18:51:15 +0100
commitabce14ea6914678045a0d69adf182e5a2d5b5ee1 (patch)
tree487c9261c923527fbbafe6f0ceed4ec91abab457
parenteaf3f2052b41f813a30a081b3882136fa178a538 (diff)
downloadmicroformats-abce14ea6914678045a0d69adf182e5a2d5b5ee1.tar.lz
microformats-abce14ea6914678045a0d69adf182e5a2d5b5ee1.tar.zst
microformats-abce14ea6914678045a0d69adf182e5a2d5b5ee1.zip
Extract mf property element selection into methods
-rw-r--r--src/microformats/parser.clj20
1 files changed, 16 insertions, 4 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 03e543f..4706992 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -222,15 +222,27 @@
                     :url (list (parse-implied-url element))
                     :photo (list (parse-implied-photo element))})))
 
+(defn- select-p
+  [element] (html/select element [(html/attr-contains :class "p-")]))
+
+(defn- select-u
+  [element] (html/select element [(html/attr-contains :class "u-")]))
+
+(defn- select-dt
+  [element] (html/select element [(html/attr-contains :class "dt-")]))
+
+(defn- select-e
+  [element] (html/select element [(html/attr-contains :class "e-")]))
+
 (defn get-mf-properties
   "Parse children of a microformat, returning a map of properties"
   [element]
   (let [cappend (partial merge-with concat)]
     (merge (parse-implied element)
-           (apply cappend (map parse-p (html/select element [(html/attr-contains :class "p-")])))
-           (apply cappend (map parse-u (html/select element [(html/attr-contains :class "u-")])))
-           (apply cappend (map parse-dt (html/select element [(html/attr-contains :class "dt-")])))
-           (apply cappend (map parse-e (html/select element [(html/attr-contains :class "e-")]))))))
+           (apply cappend (map parse-p (select-p element)))
+           (apply cappend (map parse-u (select-u element)))
+           (apply cappend (map parse-dt (select-dt element)))
+           (apply cappend (map parse-e (select-e element))))))
 
 (defn parse-h
   "Parse h-* classes within a HTML element."