parsing divs inside an a element

66 views
Skip to first unread message

Andrew Sernyak

unread,
Dec 16, 2016, 8:50:29 AM12/16/16
to Enlive
Hi,

I've encountered the following weird behavior.  

(enlive/sniptest "<a href=\"#\"><div>FOO</div></a>  ")  ;; => "<a href=\"#\"></a><div>FOO</div>  "

When I substitute div to a span — everything works as expected. 

Is there some reason for this?

Andrew

Christophe Grand

unread,
Dec 16, 2016, 9:19:01 AM12/16/16
to enlive-clj
In HTML4 divs are not allowed inside a. You should switch to HTML5 using jsoup (see https://github.com/cgrand/enlive#pluggable-parsers-111)

hth,

Christophe

--
You received this message because you are subscribed to the Google Groups "Enlive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enlive-clj+unsubscribe@googlegroups.com.
To post to this group, send email to enliv...@googlegroups.com.
Visit this group at https://groups.google.com/group/enlive-clj.
For more options, visit https://groups.google.com/d/optout.



--
On Clojure http://clj-me.cgrand.net/
Clojure Programming http://clojurebook.com
Training, Consulting & Contracting http://lambdanext.eu/

Andrew Sernyak

unread,
Dec 19, 2016, 5:26:11 AM12/19/16
to Enlive, chris...@cgrand.net
I've managed to fix my problem by doing

(enlive/html-resource
   
(java.io.ByteArrayInputStream.
     
(.getBytes html "utf-8"))
   
{:parser net.cgrand.jsoup/parser} )

Thanks a lot.

пʼятниця, 16 грудня 2016 р. 16:19:01 UTC+2 користувач Christophe Grand написав:
In HTML4 divs are not allowed inside a. You should switch to HTML5 using jsoup (see https://github.com/cgrand/enlive#pluggable-parsers-111)

hth,

Christophe
On Fri, Dec 16, 2016 at 2:41 PM, Andrew Sernyak <ndrew....@gmail.com> wrote:
Hi,

I've encountered the following weird behavior.  

(enlive/sniptest "<a href=\"#\"><div>FOO</div></a>  ")  ;; => "<a href=\"#\"></a><div>FOO</div>  "

When I substitute div to a span — everything works as expected. 

Is there some reason for this?

Andrew

--
You received this message because you are subscribed to the Google Groups "Enlive" group.
To unsubscribe from this group and stop receiving emails from it, send an email to enlive-clj+...@googlegroups.com.

To post to this group, send email to enliv...@googlegroups.com.
Visit this group at https://groups.google.com/group/enlive-clj.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages