use crate::nodes::{Ast, NodeValue}; use super::*; #[test] fn raw_node() { let user_input = "User input: "; let system_input_inline = "System Inline input: "; let system_input_block = "System Block input: "; let input = user_input.to_owned() + system_input_inline + "\n\n" + system_input_block + "\n"; let mut options = Options::default(); options.render.escape = true; options.render.r#unsafe = false; options.extension.tagfilter = true; let arena = Arena::new(); let root = parse_document(&arena, user_input, &options); let raw_ast_inline = Ast::new( NodeValue::Raw(system_input_inline.to_string()), (0, 0).into(), ); let raw_node_inline = arena.alloc(raw_ast_inline.into()); root.first_child() .unwrap() .last_child() .unwrap() .insert_after(raw_node_inline); let raw_ast_block = Ast::new( NodeValue::Raw(system_input_block.to_string()), (0, 0).into(), ); let raw_node_block = arena.alloc(raw_ast_block.into()); root.first_child().unwrap().insert_after(raw_node_block); let mut output = String::new(); html::format_document(root, &options, &mut output).unwrap(); compare_strs( &output, concat!( "

User input: <iframe></iframe>", "System Inline input:

\n", "System Block input: " ), "html", &input, ); let mut md = String::new(); cm::format_document_with_plugins(root, &options, &mut md, &options::Plugins::default()) .unwrap(); compare_strs(&md, &input, "cm", &input); let mut xml = String::new(); crate::xml::format_document(root, &options, &mut xml).unwrap(); compare_strs( &xml, concat!( "\n", "\n", "\n", " \n", " User input: \n", " <iframe>\n", " </iframe>\n", " System Inline input: <iframe></iframe>\n", " \n", " System Block input: <iframe></iframe>\n\n" ), "xml", &input, ); }