From 4d0a2cd298536eb630b5f07bafff6add8c2356c8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 21 Sep 2014 18:57:33 +0100 Subject: Split h-* selection and parsing --- src/microformats/parser.clj | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 2778cc2..b993a76 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -144,8 +144,8 @@ (r/map #(hash-map % (get-e-value element))) (into {}))) -(defn parse-children - "Parse element children for microformats" +(defn parse-h + "Parse h-* classes within a HTML element." [element] (let [el (first (html/select element [(html/union [(html/attr-starts :class "p-") (html/attr-starts :class "u-") @@ -153,10 +153,10 @@ (html/attr-starts :class "e-")])]))] (hash-map :properties (apply merge ((juxt parse-p parse-u parse-dt parse-e) el))))) -(defn parse-h - "Parse h-* classes within a HTML document." +(defn select-h + "Select h-* elements within a HTML document." [element] - (mapv parse-children (html/select element [(html/attr-starts :class "h-")]))) + (html/select element [(html/attr-starts :class "h-")])) (defn parse-rel "Parse rel attributes of an HTML link element" @@ -180,4 +180,4 @@ "Parse a HTML string with microformats" [html] (let [document (html/html-snippet html)] - {:items (parse-h document) :rels (parse-rels document)})) + {:items (mapv parse-h (select-h document)) :rels (parse-rels document)})) -- cgit 1.4.1