Expand description
html_editor
is a simple html parser and editor.
Quick Start:
use html_editor::operation::*;
use html_editor::{parse, Node};
// You can create DOM nodes by parsing html string.
let html = r#"
<!doctype html>
<html>
<head>
</head>
<body>
</body>
</html>
"#;
let mut dom = parse(html).unwrap();
// Or you can create a node by some built-in methods like below.
let app: Node = Node::new_element("div", vec![("id", "app")], vec![]);
// Here shows how to edit the nodes and turn it back to html.
let html = dom
.remove_by(&Selector::from("head"))
.insert_to(&Selector::from("body"), app)
.trim()
.html();
assert_eq!(
html,
r#"<!DOCTYPE html><html><body><div id="app"></div></body></html>"#
);
Modules§
Structs§
- Element
- HTML Element