diff options
Diffstat (limited to 'lib/docx')
| -rw-r--r-- | lib/docx/styles-reader.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/docx/styles-reader.js b/lib/docx/styles-reader.js index bff859f..28c809b 100644 --- a/lib/docx/styles-reader.js +++ b/lib/docx/styles-reader.js @@ -37,7 +37,18 @@ function readStylesXml(root) { root.getElementsByTagName("w:style").forEach(function(styleElement) { var style = readStyleElement(styleElement); var styleSet = styles[style.type]; - if (styleSet) { + + // Per 17.7.4.17 style (Style Definition) of ECMA-376 4th edition Part 1: + // + // > If multiple style definitions each declare the same value for their + // > styleId, then the first such instance shall keep its current + // > identifier with all other instances being reassigned in any manner + // > desired. + // + // For the purpose of conversion, there's no point holding onto styles + // with reassigned style IDs, so we ignore such style definitions. + + if (styleSet && styleSet[style.styleId] === undefined) { styleSet[style.styleId] = style; } }); |
