From 46d8526af589558b7ed1a2537e96953245c08720 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Tue, 23 Sep 2014 19:05:47 +0100 Subject: Add basic implied URL parsing --- src/microformats/parser.clj | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index 934a0a3..4f9f9e9 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -164,12 +164,20 @@ (defn- imply-name "Imply the name of an entity from the element" [element] - (list (node-to-text (:content element)))) + (node-to-text (:content element))) + +(defn- imply-url + [element] + (case (:tag element) + :a (-> element :attrs :href) + nil)) (defn parse-implied "Parse implied properties of a HTML element" [element] - {:name (imply-name element)}) + (into {} (filter #(first (second %)) + {:name (list (imply-name element)) + :url (list (imply-url element))}))) (defn get-mf-properties "Parse children of a microformat, returning a map of properties" -- cgit 1.4.1