mirror of
https://forge.katzen.cafe/katzen-cafe/iowo.git
synced 2024-11-24 06:18:44 +01:00
svg-filters(codegen): add pretty and ugly printing
This commit is contained in:
parent
bf60bdd814
commit
d87033d320
|
@ -43,10 +43,25 @@ impl SvgDocument {
|
||||||
self.filters.get_mut(&id.to_string()).unwrap()
|
self.filters.get_mut(&id.to_string()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn generate_svg_pretty(&self) -> String {
|
||||||
|
let mut result = Vec::new();
|
||||||
|
let doc_writer = quick_xml::Writer::new_with_indent(&mut result, b' ', 2);
|
||||||
|
|
||||||
|
self.generate(doc_writer);
|
||||||
|
|
||||||
|
String::from_utf8_lossy(&result).to_string()
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate_svg(&self) -> String {
|
pub fn generate_svg(&self) -> String {
|
||||||
let mut result = Vec::new();
|
let mut result = Vec::new();
|
||||||
let mut doc_writer = quick_xml::Writer::new_with_indent(&mut result, b' ', 2);
|
let doc_writer = quick_xml::Writer::new(&mut result);
|
||||||
|
|
||||||
|
self.generate(doc_writer);
|
||||||
|
|
||||||
|
String::from_utf8_lossy(&result).to_string()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn generate(&self, mut doc_writer: quick_xml::Writer<&mut Vec<u8>>) {
|
||||||
doc_writer
|
doc_writer
|
||||||
.create_element("svg")
|
.create_element("svg")
|
||||||
.write_inner_content(|writer| {
|
.write_inner_content(|writer| {
|
||||||
|
@ -55,8 +70,6 @@ impl SvgDocument {
|
||||||
.try_fold(writer, Self::gen_filter)
|
.try_fold(writer, Self::gen_filter)
|
||||||
.map(|_| {})
|
.map(|_| {})
|
||||||
});
|
});
|
||||||
|
|
||||||
String::from_utf8_lossy(&result).to_string()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gen_filter<'w, 'r>(
|
fn gen_filter<'w, 'r>(
|
||||||
|
|
Loading…
Reference in a new issue