aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-10-04 21:24:17 +0100
committerMichael Williamson <mike@zwobble.org>2016-10-04 21:24:17 +0100
commit095dc4513c3eeadb4dbe23d830156c9b0c39e875 (patch)
tree3f0e545986db9a25a135fcf69a553bf0dd5e81e5 /lib
parent90351d1f4a8d7bf89cfc09e5abe83564257c45d9 (diff)
Ignore run boolean elements that have value of false
Diffstat (limited to 'lib')
-rw-r--r--lib/docx/body-reader.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js
index 4a1655e..30f8bc9 100644
--- a/lib/docx/body-reader.js
+++ b/lib/docx/body-reader.js
@@ -43,10 +43,10 @@ function BodyReader(options) {
properties.verticalAlignment = verticalAlignmentElement.attributes["w:val"];
}
- properties.isBold = !!element.first("w:b");
- properties.isUnderline = !!element.first("w:u");
- properties.isItalic = !!element.first("w:i");
- properties.isStrikethrough = !!element.first("w:strike");
+ properties.isBold = readBooleanElement(element.first("w:b"));
+ properties.isUnderline = readBooleanElement(element.first("w:u"));
+ properties.isItalic = readBooleanElement(element.first("w:i"));
+ properties.isStrikethrough = readBooleanElement(element.first("w:strike"));
return readRunStyle(element).map(function(style) {
properties.styleId = style.styleId;
@@ -55,6 +55,15 @@ function BodyReader(options) {
});
}
+ function readBooleanElement(element) {
+ if (element) {
+ var value = element.attributes["w:val"];
+ return value !== "false" && value !== "0";
+ } else {
+ return false;
+ }
+ }
+
function readParagraphStyle(element) {
return readStyle(element, "w:pStyle", "Paragraph", styles.findParagraphStyleById);
}