theJohnnyBrown/endophile — pull request #2 by jarppe (2013-07-22 17:26:04+00:00)
Title: Fix and test for image problem

I noticed that this call:

(to-clj (mp "![alt text](/url \"image title\")"))

causes an exception: ClassCastException clojure.lang.LazySeq cannot be cast to java.lang.CharSequence clojure.string/blank? (string.clj:231)

The problem seems to be in the way the :alt attribute is handled in ExpImageNode:

(extend-type ExpImageNode AstToClj
(to-clj [node] {:tag :img
:attrs (a-attrs
{:src (.url node)
:title (.title node)
:alt (clj-contents node)})}))

The clj-contents returns a sequence. Later this passed to clojure.string/blank? which tries to cast it to CharSequence. I assume that the contents of :alt should be a string, so if I change the last line to:

:alt (str/join (clj-contents node))

then:

=> (to-clj (mp "![alt text](/url \"image title\")"))
({:tag :p, :content ({:tag :img, :attrs {:src "/url", :title "image title", :alt "alt text"}})})

which seems to be right.

This pull request contains that fix and a simple test for it.