gumbo-query
gumbo-query copied to clipboard
nth-child(odd) skips first node
Machine Linux (GCC 7.1) and Windows (GCC 6.3) Sample Code
std::string page("<div><p>1</p><p>2</p><p>3</p><p>4</p><p>5</p><p>6</p></div>");
CDocument doc;
doc.parse(page.c_str());
CSelection c = doc.find("p:nth-child(odd)");
CNode node = c.nodeAt(0);
std::cout << c.nodeNum() << std::endl;
for (int i = 0; i < c.nodeNum(); i++)
{
CNode node = c.nodeAt(i);
std::cout << " " + node.text() << std::endl;
}
Expected Output
3
1
3
5
Original output
2
3
5
There's a ton of broken functionality, some of it inherited from Cascadia (the source project this one was ported from), and some not. The project is dead also as there's been no activity from the author that I've seen in probably 2 years. I rewrote this library and fixed these issues in doing so and added tests, but you inherit some minor boost dependencies for use of string_ref
. Boost has a modular system now via git submodules so you can just check out what's needed to get string_ref
. I don't use my rewrite anymore but will be happy to fix anything that comes up.
@TechnikEmpire thanks for the information and your work. checking now.
@sir4ju1 Woops I didn't link. It's https://github.com/TechnikEmpire/GQ. I've made some changes recently that may make the build unclear. The VS project will be looking for boost in a specific location, you've gotta download it and edit/correct that. Feel free to open tickets on that repo.