pub fn parse(html: &str) -> Result<Vec<Node>, String>Expand description
Parse the html string and return a Vector of Node.
Example:
use html_editor::parse;
// Parse a segment.
let segment = parse(r#"<p class="content">Hello, world!</p>"#);
println!("{:#?}", segment);
// Or you can parse a whole html file.
let document = parse("<!doctype html><html><head></head><body></body></html>");
println!("{:#?}", document);Output:
[
Element {
name: "p",
attrs: {
"class": "content",
},
children: [
Text(
"Hello, world!",
),
],
},
]
[
Doctype(Html),
Element {
name: "html",
attrs: {},
children: [
Element {
name: "head",
attrs: {},
children: [],
},
Element {
name: "body",
attrs: {},
children: [],
},
],
},
]