From 4f80b088207c13f787a2b2bfbb5a716fe9a5dbb5 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 23 Sep 2014 13:12:40 +0100 Subject: Extract property fetching into function --- src/microformats/parser.clj | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 9712108..934a0a3 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -171,15 +171,20 @@ [element] {:name (imply-name element)}) +(defn get-mf-properties + "Parse children of a microformat, returning a map of properties" + [element] + (merge (parse-implied element) + (apply merge (map parse-p (html/select element [(html/attr-starts :class "p-")]))) + (apply merge (map parse-u (html/select element [(html/attr-starts :class "u-")]))) + (apply merge (map parse-dt (html/select element [(html/attr-starts :class "dt-")]))) + (apply merge (map parse-e (html/select element [(html/attr-starts :class "e-")]))))) + (defn parse-h "Parse h-* classes within a HTML element." [element] (hash-map :type (get-mf-names element) - :properties (merge (parse-implied element) - (apply merge (map parse-p (html/select element [(html/attr-starts :class "p-")]))) - (apply merge (map parse-u (html/select element [(html/attr-starts :class "u-")]))) - (apply merge (map parse-dt (html/select element [(html/attr-starts :class "dt-")]))) - (apply merge (map parse-e (html/select element [(html/attr-starts :class "e-")])))))) + :properties (get-mf-properties element))) (defn select-h "Select h-* elements within a HTML document." -- cgit 1.4.1