Repository navigation
Idea: Parsec, a Rust HTML parser, as a selectolax backend #231
Replies: 4 comments 2 replies
|
A quick follow-up, since I promised numbers and you shouldn't have to take my word for it. The head-to-head is in now.
It doesn't win everywhere, and I'd rather you heard that from me. Two of the eight hostile inputs still go Lexbor's way, both piles of reopened formatting tags (parsec#68, being worked on now). The other way round, 80,000 unclosed The method, every number and how to run it yourself are on the Benchmarks wiki page. If a selectolax backend is ever interesting, the C API and Python bindings are next on the roadmap, and I'm still happy to shape them around what you'd need. James |
|
We cannot use Rust projects as dependencies. Selectolax is C99 and is shipped as a package on various platforms, e.g., Debian. |
|
Hi @rushter I've noticed a strange trend in my project: people are using neural networks to translate Lexbor into another language, and then trying to outdo Lexbor. |
|
Hi @rushter, that makes sense. A C99 package with no dependencies that Debian can build is a real strength, and Parsec shouldn't ask you to give it up. It'll stay its own project. Thanks for taking the time to look. @lexborisov, hello, and thank you for Lexbor. I used it in my scraper before any of this, and many of the lines Parsec measures itself against are ones you drew first. So you know where Parsec comes from: it isn't a translation of Lexbor. It's written from the HTML Standard and checked against the suites anyone can run, html5lib-tests and web-platform-tests. The tokenizer, tree builder and selector engine are its own, in Rust. And it isn't meant as a contest. I started it because my scraper kept wanting things from a parser: where a node came from in the source, XPath, documents shared across threads, a worst case that stays linear. A few of those were already open on Lexbor (lexbor/lexbor#374, lexbor/lexbor#340, lexbor/lexbor#32), so I knew I wasn't the only one. The benchmarks are there so nobody has to take my word for anything, not to keep score. If any of them treats Lexbor unfairly, tell me and I'll fix it. If anything in Parsec is useful to Lexbor, take it: the hostile inputs in the bench, the final-boss batch, test cases, ideas. It's all Apache-2.0. Better parsing for everyone is the result I'm after. James |
Uh oh!
There was an error while loading. Please reload this page.
Hi! An idea for selectolax: try Parsec as a parser backend.
Some background. I was using Lexbor in my scraper, and it served me well, but I have a bit of a Ricky Bobby complex: I wanna go fast. So I wrote my own HTML parser in Rust. It turned out quick enough that I've pulled it out of the scraper and made it its own open-source project, so everyone can use it.
Where it stands today:
:has(),:is(),:where(),:not()with lists,:nth-child(... of S)and:scope.unsafeblock, and documents you can share across threads.It isn't on crates.io yet. Next up are a C API and Python bindings, which are probably the parts that matter to selectolax. They're on the roadmap. If selectolax would want a second backend, I'd love to hear what you'd need from it, and I'm happy to shape the C API or Python side around it.
Docs are on the wiki, including a comparison with Lexbor.
Thanks for selectolax, by the way. It's how a lot of people first meet Lexbor, me included.
James
All reactions