use html_streaming_editor::*;
const HTML_INPUT: &str = r#"
Title
Some first text
Some more text, even with an
Third text of HTML, but no CSS
"#;
#[test]
fn only_first_para() -> Result<(), StreamingEditorError> {
let command = "EXTRACT-ELEMENT{#first-para}";
let mut input = Box::new(HTML_INPUT.as_bytes());
let hse = HtmlStreamingEditor::new(&mut input);
let result = hse.run(command)?;
let result_string = result
.iter()
.map(|n| n.outer_html())
.collect::>()
.join("");
assert_eq!(
result_string,
String::from(r#"Some first text
"#)
);
Ok(())
}
#[test]
fn only_list_items() -> Result<(), StreamingEditorError> {
let command = "EXTRACT-ELEMENT{li}";
let mut input = Box::new(HTML_INPUT.as_bytes());
let hse = HtmlStreamingEditor::new(&mut input);
let result = hse.run(command)?;
let result_string = result
.iter()
.map(|n| n.outer_html())
.collect::>()
.join("");
assert!(result_string.contains(r#"1"#));
assert!(result_string.contains(r#"2"#));
assert!(result_string.contains(r#"3"#));
Ok(())
}