Earlier quoted context omitted.
You can't parse html with regular expressions :) https://stackoverflow.com/questions/1732348/regex-match-open...
"Oh Yes You Can Use Regexes to Parse HTML!" https://stackoverflow.com/a/4234491
Htmlq: like jq, but for html
61–70 of 172 posts
Re: Htmlq: like jq, but for html
#62Earlier quoted context omitted.
You can't parse html with regular expressions :) https://stackoverflow.com/questions/1732348/regex-match-open...
"Oh Yes You Can Use Regexes to Parse HTML!" https://stackoverflow.com/a/4234491
Re: Htmlq: like jq, but for html
#63This is very nice! For reasoning about tree-based data such as HTML, I also highly recommend the declarative programming language Prolog. HTML documents map naturally to Prolog terms and can be readily reasoned about with built-in language mechanisms. For instance, here is the sample query from the htmlq README, fetching all elements with id get-help from https://www.rust-lang.org , using Scryer Prolog and its SGML a…
Thanks, that's a rare example of something which is (a) simple enough to understand for a Prolog-newbie like me, and (b) more practical than ubiquitous family-tree example. I'm always looking for opportunities to dip my toes into Prolog; in hindsight it's clearly a good fit for tree-structured data structures.
Re: Htmlq: like jq, but for html
#64what's wrong with using html tidy + xmllint ?
Re: Htmlq: like jq, but for html
#65Re: Htmlq: like jq, but for html
#66Earlier quoted context omitted.
Thanks, that's a rare example of something which is (a) simple enough to understand for a Prolog-newbie like me, and (b) more practical than ubiquitous family-tree example. I'm always looking for opportunities to dip my toes into Prolog; in hindsight it's clearly a good fit for tree-structured data structures.
Interestingly, the only other context in which I've come across Prolog is from friends who studied at Cambridge, here in the UK. For some reason, the CS 'tripos' (course) there is really heavily focussed on Prolog, and everyone I know from there ended up a huge fan of the language. I'm not sure why that's the case, though, given that almost all other universities seem to use more common languages (Java, C++, etc).
Re: Htmlq: like jq, but for html
#67This looks very useful, big fan of all the ^[a-z]+q$ utilities out there. But as a user, I would probably want to use XPath[0] notation here. Maybe that is just me. A quick search revealed xidel[1] which seems to be similar, but supports XPath. [0] https://en.wikipedia.org/wiki/XPath [1] https://github.com/benibela/xidel
I'd like to state my support for the author's choice of CSS selectors in this particular use case. I think it's a natural fit for this domain and already very well known, perhaps even known better than XPath.
Re: Htmlq: like jq, but for html
#68Re: Htmlq: like jq, but for html
#69This is very nice! For reasoning about tree-based data such as HTML, I also highly recommend the declarative programming language Prolog. HTML documents map naturally to Prolog terms and can be readily reasoned about with built-in language mechanisms. For instance, here is the sample query from the htmlq README, fetching all elements with id get-help from https://www.rust-lang.org , using Scryer Prolog and its SGML a…
Re: Htmlq: like jq, but for html
#70This looks very useful, big fan of all the ^[a-z]+q$ utilities out there. But as a user, I would probably want to use XPath[0] notation here. Maybe that is just me. A quick search revealed xidel[1] which seems to be similar, but supports XPath. [0] https://en.wikipedia.org/wiki/XPath [1] https://github.com/benibela/xidel
Thanks, this looks more powerfull. Support CSS, XPath and XQuery. Maybe I could learn a bit of XQuery when I have a use case for it :)
(: XQuery comments are marked by mirrored smilie faces, like this. :)