diff options
author | Alan Pearce | 2014-09-13 09:53:35 +0100 |
---|---|---|
committer | Alan Pearce | 2014-09-13 09:53:35 +0100 |
commit | 1ebede4bbab4fc1315cc0bf5fdc402a29eab34e1 (patch) | |
tree | 7690a56d5677dbf7a0677577a3810c93ec4787f0 /src | |
parent | 5955c420a37fdb57eeeeb04c0f649b9d922f7fde (diff) | |
download | microformats-1ebede4bbab4fc1315cc0bf5fdc402a29eab34e1.tar.lz microformats-1ebede4bbab4fc1315cc0bf5fdc402a29eab34e1.tar.zst microformats-1ebede4bbab4fc1315cc0bf5fdc402a29eab34e1.zip |
Fallback to text content if attributes are not found
Diffstat (limited to 'src')
-rw-r--r-- | src/microformats/parser.clj | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 3200669..75f7de9 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -35,23 +35,27 @@ (defn get-p-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) - (or (first (:content el)) ""))) + (or (case (:tag el) + :img (-> el :attrs :alt) + :area (-> el :attrs :alt) + :abbr (-> el :attrs :title) + :data (-> el :attrs :value) + :input (-> el :attrs :value) + nil) + (first (:content el)) + "")) (defn get-u-property "Get the u-x property value of an element" [el] - (case (:tag el) - :a (-> el :attrs :href) - :area (-> el :attrs :href) - :img (-> el :attrs :src) - :object (-> el :attrs :data) - (get-p-property el))) + (or (case (:tag el) + :a (-> el :attrs :href) + :area (-> el :attrs :href) + :img (-> el :attrs :src) + :object (-> el :attrs :data) + (get-p-property el)) + (first :content el) + "")) (defn parse-p "Parse p-* classes within HTML element." |