gdritter repos gunpowder_treason / 84babcf
Let XMLWriter add initial XML header too Getty Ritter 5 years ago
1 changed file(s) with 6 addition(s) and 2 deletion(s). Collapse all Expand all
2929 }
3030
3131 impl<'a> XMLWriter<'a> {
32 pub fn start(buf: &'a mut Write) -> io::Result<XMLWriter<'a>> {
33 writeln!(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")?;
34 Ok(XMLWriter { writer: buf })
35 }
36
3237 /// create an entire closed tag with the given attributes
3338 pub fn tag(&mut self, name: &str, attrs: &[(&str, &Display)]) -> io::Result<()> {
3439 write!(self.writer, "<{}", name)?;
119124
120125 pub fn write_svg<W: Write>(self, buf: &mut W) -> io::Result<()> {
121126 let (w, h) = self.size;
122 writeln!(buf, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>")?;
123 let mut xml = XMLWriter { writer: buf };
127 let mut xml = XMLWriter::start(buf)?;
124128 xml.block(
125129 "svg",
126130 &[("xmlns", &"http://www.w3.org/2000/svg"),