You can clone with
First off, thanks for a brilliant project. I'm using cheerio 0.8.0:
My code looks like this:
The html returned from the $(cols.get(3)).html() looks like this:
Kid's Ride <br/>Foo <br/> <br/><font color="#000000">Permitted</font><br/>Category - D <br/><br/>\n
When I try to wrap that output back into the outer $() so that I can do more selects on it, this is the stack trace I see:
at parse (node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/node_modules/CSSwhat/index.js:109:11)\n
at parse (node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/index.js:646:18)\n
at Function.iterate (node_modules/cheerio/node_modules/cheerio-select/node_modules/CSSselect/index.js:687:42)\n
at [object Object].find (node_modules/cheerio/lib/api/traversing.js:7:14)
at [object Object].init (node_modules/cheerio/lib/cheerio.js:67:44)
at fn (node_modules/cheerio/lib/api/utils.js:246:12)
I suspect it has something to do with the entity (') in there as other similar html without the single quote in it parses just fine.
Hm... I'll look into this. For the time being you should be able to do... $(cols).eq(3).
Oh I see what's going on... it's thinking that the string is a selector and not an HTML string.. strange.
Edit: jQuery does not even recognize that as an HTML string. It handles the response a bit more gracefully though with .
Similar problem with this html:
Eastern States Cup #8-fin <br>Downhill
Error: Unmatched selector: <br/>Downhill <br/>
While $(cols).eq(3) works, I still need to parse that line of text and grab stuff from it.
$('<div/>').html(cols.eq(3).html().replace(/ /g, ' ')).eq(0).children()
I'm no expert, so that is the best I could do. Gross. =)
Okay, I'll make adjustments so that it does not error out, but just to be clear - jQuery returns  on $('Eastern States Cup #8-fin <br>Downhill ').. this is the behavior your anticipating?
$('Eastern States Cup #8-fin <br>Downhill ')
I vote for making it work correctly... which would be to parse it as if it was living inside a <div>. I didn't write this html, someone else did so I'm stuck with junk html. Right now, it sits within a <td> element. I grab the chunk of data from the td and then I want to grab bits from there. I either need to write my own parser or just assume that it is more html. Given that this project is supposed to be lenient to bad html, I think it should give me a set of elements.
now fails gracefully in cases that involve special chars, which is i…
…nline with jQuery (closes #59)
I'm not planning on deviating from how jQuery handles this case. For your use case you could explicitly wrap your input in <div> tags.