diff options
author | Alan Pearce | 2014-09-23 13:12:40 +0100 |
---|---|---|
committer | Alan Pearce | 2014-09-23 13:12:40 +0100 |
commit | 4f80b088207c13f787a2b2bfbb5a716fe9a5dbb5 (patch) | |
tree | 025b54517130bb53ed604763b8f626f928e81fd8 | |
parent | f45945cad76b864fa4a84277f6581ffef31e225e (diff) | |
download | microformats-4f80b088207c13f787a2b2bfbb5a716fe9a5dbb5.tar.lz microformats-4f80b088207c13f787a2b2bfbb5a716fe9a5dbb5.tar.zst microformats-4f80b088207c13f787a2b2bfbb5a716fe9a5dbb5.zip |
Extract property fetching into function
-rw-r--r-- | src/microformats/parser.clj | 15 |
1 files changed, 10 insertions, 5 deletions
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." |