fix: del in ins (#442)
parent
2622147371
commit
5dd154d51d
|
@ -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();
|
||||||
|
|
|
@ -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
|
@ -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.
Binary file not shown.
|
@ -0,0 +1 @@
|
||||||
|
1.58.1
|
Loading…
Reference in New Issue