diff options
author | Alan Pearce | 2014-09-11 18:10:03 +0100 |
---|---|---|
committer | Alan Pearce | 2014-09-11 18:10:03 +0100 |
commit | 90d4ef777d61af7ad1990e9b3a65e42f591ed1ce (patch) | |
tree | dd27da695ddc74919cc69bf84d82d6531890b62b /src | |
parent | 31ad04a4ed9bfafa6c9682c9bdd98aadb45f6092 (diff) | |
download | microformats-90d4ef777d61af7ad1990e9b3a65e42f591ed1ce.tar.lz microformats-90d4ef777d61af7ad1990e9b3a65e42f591ed1ce.tar.zst microformats-90d4ef777d61af7ad1990e9b3a65e42f591ed1ce.zip |
Get correct property value for special tags
img, area, abbr, data and input tags are all consumed differently.
Diffstat (limited to 'src')
-rw-r--r-- | src/microformats/parser.clj | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index c39e396..959e1af 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -34,12 +34,23 @@ :class split-classes)) +(defn get-property + "Get the p-x property value of an element" + [el] + (case (:tag el) + :img (-> el :attrs :alt) + :area (-> el :attrs :alt) + :abbr (-> el :attrs :title) + :data (-> el :attrs :value) + :input (-> el :attrs :value) + (first (:content el)))) + (defn parse-p "Parse p-* classes within HTML element." [element] (let [el (first (html/select element [(html/attr-starts :class "p-")])) props (into [] ((classes-to-props "p-") (element-to-classes el)))] - (hash-map :properties (apply hash-map (first props) (repeat (count props) (first (:content el))))))) + (hash-map :properties (apply hash-map (first props) (repeat (count props) (get-property el)))))) (defn parse-h "Parse h-* classes within a HTML document." |