Add support for parsing empty br/hr tags
2 files changed, 11 insertions(+), 1 deletion(-)
M src/microformats/parser.clj → src/microformats/parser.clj
@@ -43,7 +43,7 @@ :area (-> el :attrs :alt) :abbr (-> el :attrs :title) :data (-> el :attrs :value) :input (-> el :attrs :value) - (first (:content el)))) + (or (first (:content el)) ""))) (defn parse-p "Parse p-* classes within HTML element."
M test/microformats/parser_test.clj → test/microformats/parser_test.clj
@@ -29,3 +29,13 @@ {:items [{:properties {:name "Example User"}}] :rels {}} "<div class=\"h-card\"><data class=\"p-name\" value=\"Example User\"></data></div>" ))) + +(deftest parse-p-empty-br-hr + (testing "br and hr tags should return empty strings" + (are [ex in] (= ex (parse in)) + {:items [{:properties {:name ""}}] :rels {}} + "<div class=\"h-card\"><br class=\"p-name\"/></div>" + + {:items [{:properties {:name ""}}] :rels {}} + "<div class=\"h-card\"><hr class=\"p-name\"/></div>") + ))