8 ms·
Is there a tool like this that can modify part of the HTML without changing the formatting or inserting new tags unnecessarily? I know it's a difficult problem
by panic 4y ago
Is there a tool like this that can modify part of the HTML without changing the formatting or inserting new tags unnecessarily? I know it's a difficult problem given the complexity of HTML parsing, but I'd like to be able to work with parts of pages programmatically without messing up the hand-written formatting in other parts.
- k__ 4y agoI'd go so far and assume it's an AI problem.
- mh- 4y agoProbably not without constructing a DOM. Which nowadays, in practice, means using Blink or WebKit.
- yencabulator 4y agohttps://github.com/cloudflare/lol-html https://github.com/cloudflare/lol-html is a HTML rewriter that explicitly does not construct DOM or an AST, but streams nodes throughs ASAP. https://blog.cloudflare.com/html-parsing-1/ https://blog.cloudflare.com/html-parsing-1/ https://blog.cloudflare.com/html-parsing-2/ https://blog.cloudflare.com/html-parsing-2/
- mh- 4y agoThis is the best approach if they don't need to consider client-side JS mutations. Not sure why I interpreted it that way in my original reply. Thanks!