Fix duplicated extended (#317)

* fix: duplicated comments extended

* 0.0.206
main
bokuweb 2021-07-25 08:51:28 +09:00 committed by GitHub
parent 6c139144f3
commit a2dd6e5df4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View File

@ -18,7 +18,16 @@ impl FromXML for CommentsExtended {
let e = XMLElement::from_str(&name.local_name) let e = XMLElement::from_str(&name.local_name)
.expect("should convert to XMLElement"); .expect("should convert to XMLElement");
if let XMLElement::CommentExtended = e { if let XMLElement::CommentExtended = e {
comments_extended.push(CommentExtended::read(&mut r, &attributes)?); if let Ok(ex) = CommentExtended::read(&mut r, &attributes) {
if let Some(pos) = comments_extended
.iter()
.position(|e| e.paragraph_id == ex.paragraph_id)
{
comments_extended[pos] = ex;
} else {
comments_extended.push(ex);
}
}
} }
} }
Ok(XmlEvent::EndElement { name, .. }) => { Ok(XmlEvent::EndElement { name, .. }) => {

View File

@ -1,6 +1,6 @@
{ {
"name": "docx-wasm", "name": "docx-wasm",
"version": "0.0.205", "version": "0.0.206",
"main": "dist/node/index.js", "main": "dist/node/index.js",
"browser": "dist/web/index.js", "browser": "dist/web/index.js",
"author": "bokuweb <bokuweb12@gmail.com>", "author": "bokuweb <bokuweb12@gmail.com>",