From aa549bd5cf4b42c88e3ce9e833db6628165cd079 Mon Sep 17 00:00:00 2001 From: bokuweb Date: Fri, 28 Feb 2020 13:50:12 +0900 Subject: [PATCH] fix: bold and italic (#47) --- docx-core/src/reader/run.rs | 22 ++++++++++++++++++++-- docx-wasm/package.json | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/docx-core/src/reader/run.rs b/docx-core/src/reader/run.rs index f1368e2..122f8e9 100644 --- a/docx-core/src/reader/run.rs +++ b/docx-core/src/reader/run.rs @@ -31,8 +31,26 @@ impl ElementReader for Run { }) => { let e = XMLElement::from_str(&name.local_name).unwrap(); match e { - XMLElement::Tab => run = run.add_tab(), - XMLElement::Bold => run = run.bold(), + XMLElement::Tab => { + run = { + if let Some(v) = &attributes.get(0) { + if &v.value == "0" { + continue; + } + } + run.add_tab() + } + } + XMLElement::Bold => { + run = { + if let Some(v) = &attributes.get(0) { + if &v.value == "0" { + continue; + } + } + run.bold() + } + } XMLElement::Highlight => run = run.highlight(attributes[0].value.clone()), XMLElement::Color => run = run.color(attributes[0].value.clone()), XMLElement::Size => run = run.size(usize::from_str(&attributes[0].value)?), diff --git a/docx-wasm/package.json b/docx-wasm/package.json index e097985..71c9c40 100644 --- a/docx-wasm/package.json +++ b/docx-wasm/package.json @@ -1,6 +1,6 @@ { "name": "docx-wasm", - "version": "0.0.40", + "version": "0.0.41", "main": "dist/node/index.js", "browser": "dist/web/index.js", "author": "bokuweb ",