stringify_pretty

Function stringify_pretty 

Source
pub fn stringify_pretty(ele: Rc<Element<'_>>) -> String
Expand description

transform a Element(AST struct) to svg with pretty format

return string.

ยงExample

use svg_simple_parser::{Element,stringify_pretty};
use std::collections::HashMap;

let root = Element::new_width_children((
  "rect",
  HashMap::from([
    ("width".to_owned(),"100"),
  ]),
  vec![
    Element::new_width_children((
      "rect",
      HashMap::from([
        ("width".to_owned(),"100"),
      ]),
      vec![],
    )),
  ],
));
let svg = stringify_pretty(root);
assert_eq!(svg,"<rect width=\"100\">\r\n  <rect width=\"100\"/>\r\n</rect>\r\n");