5 ms·
brilliant. does this spin up a heavy DOM implementation in the background or do something lighter such as regexp?
by purplecats 5y ago
brilliant. does this spin up a heavy DOM implementation in the background or do something lighter such as regexp?
- mdzn 5y agoYou can’t parse HTML with regexps. It’s not a regular language.
- underdeserver 5y agohttps://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 https://stackoverflow.com/questions/1732348/regex-match-open...
- carnitine 5y agoWhat language implements regexps that actually correspond to regular languages though?
- Deukhoofd 5y agoLooks like it uses servos html5ever (through kuchiki), so no DOM representation.
- chrismorgan 5y agoKuchiki materialises what they call a “DOM-like tree”. I’d consider it a DOM tree, myself, despite the differences in precise API. But it’s not using a full browser to back it, which I suspect is what’s really being asked.
- mrweasel 5y agoIt looks to be using html5ever to parse the HTML, similar to something like BeautifulSoup in Python.
- delusional 5y agoThe source is right there. You can read it. It uses html5ever (part of the servo project).
- deleted 5y ago[deleted]
- gostsamo 5y agoYou can't parse html with regular expressions :) https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 https://stackoverflow.com/questions/1732348/regex-match-open...
- andybak 5y agoAnd the obligitory caveat from the comments: > While arbitrary HTML with only a regex is impossible, it's sometimes appropriate to use them for parsing a limited, known set of HTML.
- hnbad 5y agoThe emphasis here is on "known". The tool is general purpose (i.e. handling unknown HTML) so using regexes would be ill-advised.
- bmn__ 5y ago"Oh Yes You Can Use Regexes to Parse HTML!" https://stackoverflow.com/a/4234491 https://stackoverflow.com/a/4234491