about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorAlan Pearce2014-09-23 19:10:40 +0100
committerAlan Pearce2014-09-23 19:10:40 +0100
commit2bf7f18a47beb329f6dcd3776a819d6541cff166 (patch)
tree8e07bf2cc2cf142bad1d27a7158af96911faf15c /src
parent46d8526af589558b7ed1a2537e96953245c08720 (diff)
downloadmicroformats-2bf7f18a47beb329f6dcd3776a819d6541cff166.tar.lz
microformats-2bf7f18a47beb329f6dcd3776a819d6541cff166.tar.zst
microformats-2bf7f18a47beb329f6dcd3776a819d6541cff166.zip
Add basic img property inferring
Diffstat (limited to 'src')
-rw-r--r--src/microformats/parser.clj13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj
index 4f9f9e9..b28fce7 100644
--- a/src/microformats/parser.clj
+++ b/src/microformats/parser.clj
@@ -164,7 +164,9 @@
 (defn- imply-name
   "Imply the name of an entity from the element"
   [element]
-  (node-to-text (:content element)))
+  (case (:tag element)
+    :img (-> element :attrs :alt)
+    (node-to-text (:content element))))
 
 (defn- imply-url
   [element]
@@ -172,12 +174,19 @@
     :a (-> element :attrs :href)
     nil))
 
+(defn- imply-photo
+  [element]
+  (case (:tag element)
+    :img (-> element :attrs :src)
+    nil))
+
 (defn parse-implied
   "Parse implied properties of a HTML element"
   [element]
   (into {} (filter #(first (second %))
                    {:name (list (imply-name element))
-                    :url (list (imply-url element))})))
+                    :url (list (imply-url element))
+                    :photo (list (imply-photo element))})))
 
 (defn get-mf-properties
   "Parse children of a microformat, returning a map of properties"