diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-06-08 22:22:54 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-06-08 22:22:54 +0100 |
| commit | 3ddcb6b5aa1a4502ff60fecc0e38041efa41a20e (patch) | |
| tree | a27964927b79b8964af274e864b3400f4a336482 /lib | |
| parent | aac54dca5f6b96788ae9c045cb64534ab7b598ad (diff) | |
Ignore styles that aren't paragraph or character
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/docx/styles-reader.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/docx/styles-reader.js b/lib/docx/styles-reader.js index d38c510..dc90bc1 100644 --- a/lib/docx/styles-reader.js +++ b/lib/docx/styles-reader.js @@ -17,10 +17,17 @@ function readStylesXml(xml) { var paragraphStyles = {}; var characterStyles = {}; + var styles = { + "paragraph": paragraphStyles, + "character": characterStyles + }; + xml.root.getElementsByTagName("w:style").forEach(function(styleElement) { var style = readStyleElement(styleElement); - var styleSet = style.type === "paragraph" ? paragraphStyles : characterStyles; - styleSet[style.styleId] = style; + var styleSet = styles[style.type]; + if (styleSet) { + styleSet[style.styleId] = style; + } }); return new Styles(paragraphStyles, characterStyles); |
