fix: del in ins (#442)

main
bokuweb 2022-03-15 16:58:29 +09:00 committed by GitHub
parent 2622147371
commit 5dd154d51d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 2546 additions and 4 deletions

View File

@ -4,11 +4,11 @@ use std::fs::File;
use std::io::{Read, Write}; use std::io::{Read, Write};
pub fn main() { pub fn main() {
let mut file = File::open("./ppr_del.docx").unwrap(); let mut file = File::open("./hello.docx").unwrap();
let mut buf = vec![]; let mut buf = vec![];
file.read_to_end(&mut buf).unwrap(); file.read_to_end(&mut buf).unwrap();
let mut file = File::create("./test.json").unwrap(); let mut file = File::create("./hello.json").unwrap();
let res = read_docx(&buf).unwrap().json(); let res = read_docx(&buf).unwrap().json();
file.write_all(res.as_bytes()).unwrap(); file.write_all(res.as_bytes()).unwrap();
file.flush().unwrap(); file.flush().unwrap();

View File

@ -20,8 +20,8 @@ impl ElementReader for Insert {
}) => { }) => {
let e = XMLElement::from_str(&name.local_name).unwrap(); let e = XMLElement::from_str(&name.local_name).unwrap();
match e { match e {
XMLElement::Run => ins = ins.add_run(Run::read(r, attrs)?), XMLElement::Run => ins = ins.add_run(Run::read(r, &attributes)?),
XMLElement::Delete => ins = ins.add_delete(Delete::read(r, attrs)?), XMLElement::Delete => ins = ins.add_delete(Delete::read(r, &attributes)?),
XMLElement::CommentRangeStart => { XMLElement::CommentRangeStart => {
if let Some(id) = read(&attributes, "id") { if let Some(id) = read(&attributes, "id") {
if let Ok(id) = usize::from_str(&id) { if let Ok(id) = usize::from_str(&id) {

File diff suppressed because it is too large Load Diff

View File

@ -112,6 +112,12 @@ describe("reader", () => {
const json = w.readDocx(buffer); const json = w.readDocx(buffer);
expect(json).toMatchSnapshot(); expect(json).toMatchSnapshot();
}); });
test("should read del_in_ins docx", () => {
const buffer = readFileSync("../fixtures/del_in_ins/del_in_ins.docx");
const json = w.readDocx(buffer);
expect(json).toMatchSnapshot();
});
}); });
describe("writer", () => { describe("writer", () => {

Binary file not shown.

BIN
hello.docx 100644

Binary file not shown.

1
rust-toolchain 100644
View File

@ -0,0 +1 @@
1.58.1