diff options
author | Alan Pearce | 2014-09-21 18:57:33 +0100 |
---|---|---|
committer | Alan Pearce | 2014-09-21 18:57:33 +0100 |
commit | 4d0a2cd298536eb630b5f07bafff6add8c2356c8 (patch) | |
tree | 57fff3a386c4a4d124ca6435f8cf2ae1d316172e | |
parent | 8eca33a1e4b5aa244a3a11bf1c8f1ed1b47b7e8d (diff) | |
download | microformats-4d0a2cd298536eb630b5f07bafff6add8c2356c8.tar.lz microformats-4d0a2cd298536eb630b5f07bafff6add8c2356c8.tar.zst microformats-4d0a2cd298536eb630b5f07bafff6add8c2356c8.zip |
Split h-* selection and parsing
-rw-r--r-- | src/microformats/parser.clj | 12 |
1 files changed, 6 insertions, 6 deletions
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)})) |