<a> unexpectedly unwrapped from around <ul>

34 views
Skip to first unread message

Lyle

unread,
Feb 14, 2012, 10:32:48 AM2/14/12
to enliv...@googlegroups.com
I'm seeing some behavior I don't quite understand. I want to wrap a <ul> with a link.
example.html:
<a>
    <ul>
        <li>One</li>
        <li>Two</li>
        <li>Three</li>
    </ul>
</a>
 
At the REPL I see:
user=> (use 'clojure.pprint 'net.cgrand.enlive-html)
user=> (pprint (select (html-resource "resources/example.html") [:body]))
({:tag :body,
  :attrs nil,
  :content
  ({:tag :a, :attrs nil, :content ("\n    ")}
   {:tag :ul,
    :attrs nil,
    :content
    ("\n        "
     {:tag :li, :attrs nil, :content ("One")}
     "\n        "
     {:tag :li, :attrs nil, :content ("Two")}
     "\n        "
     {:tag :li, :attrs nil, :content ("Three")}
     "\n    ")}
   "\n\n")})
nil

More concisely:
user=> (pprint (select (html-resource "resources/example.html") [:a]))
({:tag :a, :attrs nil, :content ("\n    ")})
 

Is this an issue of trying to put a block-level element inside an inline one? The document I'm trying to generate is valid HTML5, for whatever that's worth.

Thanks,
Lyle

Christophe Grand

unread,
Feb 14, 2012, 11:26:35 AM2/14/12
to enliv...@googlegroups.com
Hi,

You're right in your analysis, the problem stems from TagSoup fixing your html (blocks inside inlines).
Try replacing all html-resource by xml-resource. If it doesn't work then you'll need to implement your own *-resource, maybe by using NekoHTML. In any cases, don't hesitate to ask for help here.

I've been planning to replace TagSoup and the *-resource mechanism by a single resource function/mmethod and an option map but I had no time yet to work on this. If someone is willing to help on this task, please step in.

Christophe



--
You received this message because you are subscribed to the Google Groups "Enlive" group.
To view this discussion on the web visit https://groups.google.com/d/msg/enlive-clj/-/4bavNFn1TkIJ.
To post to this group, send email to enliv...@googlegroups.com.
To unsubscribe from this group, send email to enlive-clj+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/enlive-clj?hl=en.



--
Professional: http://cgrand.net/ (fr)
On Clojure: http://clj-me.cgrand.net/ (en)

Lyle

unread,
Feb 14, 2012, 4:55:44 PM2/14/12
to enliv...@googlegroups.com
Thanks. xml-resource didn't work for me either since it didn't like some of my other markup, so due to time constraints I've simply worked around it by wrapping that element in my Ring handler after the resource is loaded.

-Lyle
Reply all
Reply to author
Forward
0 new messages