fix: style run props bool value (#153)

main
bokuweb 2020-10-05 16:19:05 +09:00 committed by GitHub
parent 046a7dd7e9
commit 6b45f31eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 5 deletions

View File

@ -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();
}

View File

@ -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(),
_ => {}
}