@MatthewMueller
Trying to use cheerio to match against a custom HTML node receives that error.
Here is a simple test to try it out:
var cheerio = require('cheerio');
var markup = '<html><body><esi:foo attr="test"></esi:foo></body></html>';
var $ = cheerio.load(markup);
$('esi:foo').text();
The use case is basically for running unit tests on rendered HTML that will be parsed by apache traffic server (ats) and execute these esi tags.
@fb55 does the html parser support the colon in <esi:foo>?
In the meantime, @redonkulus you may want to try:
var $ = cheerio.load(markup, { xmlMode: true });
and see if that works.
@MatthewMueller same issue with xmlMode flag passed in.
Try escaping the colon with a backslash (which needs to be escaped itself
with an additional backslash inside JS strings). Otherwise, it is parsed as
a pseudo selector.
@fb55 double backslash fixed it. I originally tried one but not two, smh.
Thanks!
Try escaping the colon with a backslash (which needs to be escaped itself
with an additional backslash inside JS strings). Otherwise, it is parsed as
a pseudo selector.
Do pseudo selectors apply to HTML? Or is this just for <style>div:hover { color: blue }</style>?
<div:hover> will produce an HTMLUnknownElement named DIV:HOVER. If you'd like to query for it in an CSS selector, you'll need to escape the colon (div\:hover). Otherwise, you'll match elements named DIV in their hover state. Same applies to classes (eg. [foo\.bar]).
Because JS uses backslashes for escaping inside itself, this weird double escape is required.
Double black slash \\ before the : fixed it! :
\\:
Most helpful comment
@fb55 double backslash fixed it. I originally tried one but not two, smh.