html5ever icon indicating copy to clipboard operation
html5ever copied to clipboard

docs/example of searching and modifying the dom

Open tcurdt opened this issue 6 years ago • 6 comments

I would be great to have an example or more explicit docs that shows how to search and modify the dom - or did I just not find that?

tcurdt avatar Mar 07 '19 12:03 tcurdt

html5ever is really a parser (and serializer) that supports any data structure that implements the TreeSink trait. The rcdom module exists more to support html5ever’s own tests than for serious tree manipulation.

https://crates.io/crates/kuchiki is a proof-of-concept for providing more convenience APIs and plumbing a tree together with the parser and with CSS selector matching. But it also could use a lot more documentation, and I’m not actively working on it.

SimonSapin avatar Mar 07 '19 12:03 SimonSapin

@SimonSapin Thanks for the quick reply. That sounds like bad news though. Bummer. Writing a complete DOM first seems a bit out of scope.

I guess I need to find another way for parse -> dom -> manipulate -> serialize then.

tcurdt avatar Mar 07 '19 13:03 tcurdt

To be clear I think Kuchiki (which uses html5ever) is what you want, though the documentation is not great.

SimonSapin avatar Mar 07 '19 13:03 SimonSapin

Thanks, will give it a try.

When you say "not actively working on it" does that mean "in maintenance mode" or "noone looks after it"?

tcurdt avatar Mar 07 '19 13:03 tcurdt

Depends what you mean by “look after” exactly. I try to respond to issues and PRs but I make no promise about time.

SimonSapin avatar Mar 07 '19 13:03 SimonSapin

...bug fixes, merging PRs, releases - that sort of thing.

tcurdt avatar Mar 07 '19 13:03 tcurdt