fix: style run props bool value (#153)
parent
046a7dd7e9
commit
6b45f31eea
|
@ -1,10 +1,16 @@
|
||||||
use docx_rs::*;
|
use docx_rs::*;
|
||||||
use std::fs::*;
|
|
||||||
use std::io::Read;
|
use std::fs::File;
|
||||||
|
use std::io::{Read, Write};
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
let mut file = File::open("./from_doc.docx").unwrap();
|
let mut file = File::open("./style_test.docx").unwrap();
|
||||||
let mut buf = vec![];
|
let mut buf = vec![];
|
||||||
file.read_to_end(&mut buf).unwrap();
|
file.read_to_end(&mut buf).unwrap();
|
||||||
dbg!(read_docx(&buf).unwrap().json());
|
dbg!(read_docx(&buf).unwrap().json());
|
||||||
|
|
||||||
|
let mut file = File::create("./test.json").unwrap();
|
||||||
|
let res = read_docx(&buf).unwrap().json();
|
||||||
|
file.write_all(res.as_bytes()).unwrap();
|
||||||
|
file.flush().unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,12 @@ impl ElementReader for Style {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// rPr
|
// rPr
|
||||||
XMLElement::Bold => style = style.bold(),
|
XMLElement::Bold => {
|
||||||
|
if !read_bool(&attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
style = style.bold();
|
||||||
|
}
|
||||||
XMLElement::Highlight => {
|
XMLElement::Highlight => {
|
||||||
style = style.highlight(attributes[0].value.clone())
|
style = style.highlight(attributes[0].value.clone())
|
||||||
}
|
}
|
||||||
|
@ -58,7 +63,12 @@ impl ElementReader for Style {
|
||||||
XMLElement::Underline => {
|
XMLElement::Underline => {
|
||||||
style = style.underline(&attributes[0].value.clone())
|
style = style.underline(&attributes[0].value.clone())
|
||||||
}
|
}
|
||||||
XMLElement::Italic => style = style.italic(),
|
XMLElement::Italic => {
|
||||||
|
if !read_bool(&attributes) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
style = style.italic();
|
||||||
|
}
|
||||||
XMLElement::Vanish => style = style.vanish(),
|
XMLElement::Vanish => style = style.vanish(),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue