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 replace_ul_with_created_div() -> Result<(), StreamingEditorError> { let command = "REPLACE-ELEMENT{ul ↤ CREATE-ELEMENT{div} | SET-TEXT-CONTENT{'this was an UL'} | SET-ATTR{id ↤ 'new'}}"; 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#"

Title

Some first text

Some more text, even with an

Third text of HTML, but no CSS

this was an UL
"# ) ); Ok(()) } #[test] fn replace_ul_with_sourced_html() -> Result<(), StreamingEditorError> { let command = "REPLACE-ELEMENT{ul ↤ LOAD-FILE{'tests/source.html'} | EXTRACT-ELEMENT{ul}}"; 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#"

Title

Some first text

Some more text, even with an

Third text of HTML, but no CSS

"# ) ); Ok(()) } #[test] fn replace_third_para_with_child_abbr() -> Result<(), StreamingEditorError> { let command = "REPLACE-ELEMENT{#third-para ↤ QUERY-REPLACED{abbr}}"; 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#"

Title

Some first text

Some more text, even with an

HTMLCSS
  • 1
  • 2
  • 3
"# ) ); Ok(()) }