From 21830ef89ee29c4dfbaa4340601ef837ffb53159 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 22 Sep 2014 20:02:22 +0100 Subject: Output lists of values according to spec --- src/microformats/parser.clj | 12 +++--- test/microformats/parser_expectations.clj | 62 +++++++++++++++---------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/microformats/parser.clj b/src/microformats/parser.clj index b3af5e3..de53855 100644 --- a/src/microformats/parser.clj +++ b/src/microformats/parser.clj @@ -105,8 +105,8 @@ "Get the e-x propery value of an element" [el] (let [content (:content el)] - {:html (apply str (node-to-html content)) - :value (apply str (html/texts content))})) + (list {:html (apply str (node-to-html content)) + :value (apply str (html/texts content))}))) (defn parse-p "Parse p-* classes within HTML element." @@ -114,7 +114,7 @@ (->> element element-to-classes ((classes-to-props "p-")) - (r/map #(hash-map % (get-p-value element))) + (r/map #(hash-map % (list (get-p-value element)))) (into {}))) (defn parse-u @@ -123,7 +123,7 @@ (->> element element-to-classes ((classes-to-props "u-")) - (r/map #(hash-map % (get-u-value element))) + (r/map #(hash-map % (list (get-u-value element)))) (into {}))) (defn parse-dt @@ -132,7 +132,7 @@ (->> element element-to-classes ((classes-to-props "dt-")) - (r/map #(hash-map % (get-dt-value element))) + (r/map #(hash-map % (list (get-dt-value element)))) (into {}))) (defn parse-e @@ -155,7 +155,7 @@ (defn- imply-name "Imply the name of an entity from the element" [element] - (or (first (:content element)))) + (:content element)) (defn parse-implied "Parse implied properties of a HTML element" diff --git a/test/microformats/parser_expectations.clj b/test/microformats/parser_expectations.clj index 53f9ca5..498d8e1 100644 --- a/test/microformats/parser_expectations.clj +++ b/test/microformats/parser_expectations.clj @@ -16,91 +16,91 @@ (expect "Foo bar" (apply str (#'microformats.parser/node-to-html '("Foo " {:tag :strong, :attrs nil, :content ("bar")})))) -(expect {:name "Name"} +(expect {:name '("Name")} (parse-p (snippet "
Name
"))) -(expect {:name "Name Endname"} +(expect {:name '("Name Endname")} (parse-p (snippet "Name (this should not be included) Endname
"))) -(expect {:name "Example User"} +(expect {:name '("Example User")} (parse-p (snippet "Example User
"))) -(expect {:nickname "exuser"} +(expect {:nickname '("exuser")} (parse-p (snippet "exuser
"))) -(expect {:name "Example User"} +(expect {:name '("Example User")} (parse-p (snippet ""))) -(expect {:name "Example User"} +(expect {:name '("Example User")} (parse-p (snippet "@example"))) -(expect {:name "@example"} +(expect {:name '("@example")} (parse-p (snippet "@example"))) -(expect {:name "Example User"} +(expect {:name '("Example User")} (parse-p (snippet ""))) -(expect {:name "Example User"} +(expect {:name '("Example User")} (parse-p (snippet "Example User"))) -(expect {:name ""} +(expect {:name '("")} (parse-p (snippet "Example User
Example User
")) -- cgit 1.4.1