fix: style run props bool value (#153)
parent
046a7dd7e9
commit
6b45f31eea
|
@ -1,10 +1,16 @@
|
|||
use docx_rs::*;
|
||||
use std::fs::*;
|
||||
use std::io::Read;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
|
||||
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![];
|
||||
file.read_to_end(&mut buf).unwrap();
|
||||
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;
|
||||
}
|
||||
// rPr
|
||||
XMLElement::Bold => style = style.bold(),
|
||||
XMLElement::Bold => {
|
||||
if !read_bool(&attributes) {
|
||||
continue;
|
||||
}
|
||||
style = style.bold();
|
||||
}
|
||||
XMLElement::Highlight => {
|
||||
style = style.highlight(attributes[0].value.clone())
|
||||
}
|
||||
|
@ -58,7 +63,12 @@ impl ElementReader for Style {
|
|||
XMLElement::Underline => {
|
||||
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(),
|
||||
_ => {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue