aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/docx/styles-reader.js3
-rw-r--r--tests/docx/styles-reader.tests.js9
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/docx/styles-reader.js b/lib/docx/styles-reader.js
index fd3425c..5cfabbf 100644
--- a/lib/docx/styles-reader.js
+++ b/lib/docx/styles-reader.js
@@ -27,5 +27,6 @@ function readStylesXml(xml) {
function readStyleElement(styleElement) {
var type = styleElement.attributes["w:type"];
var styleId = styleElement.attributes["w:styleId"];
- return {type: type, styleId: styleId};
+ var name = styleElement.first("w:name").attributes["w:val"];
+ return {type: type, styleId: styleId, name: name};
}
diff --git a/tests/docx/styles-reader.tests.js b/tests/docx/styles-reader.tests.js
index 274f822..6dfdcd2 100644
--- a/tests/docx/styles-reader.tests.js
+++ b/tests/docx/styles-reader.tests.js
@@ -43,6 +43,15 @@ describe('readStylesXml', function() {
assert.equal(styles.findCharacterStyleById("Heading1"), null);
assert.equal(styles.findParagraphStyleById("Heading1Char"), null);
});
+
+ test('styles include names', function() {
+ var styles = readStylesXml({
+ root: new XmlElement("w:styles", {}, [
+ paragraphStyleElement("Heading1", "Heading 1")
+ ])
+ });
+ assert.equal(styles.findParagraphStyleById("Heading1").name, "Heading 1");
+ });
});
function paragraphStyleElement(id, name) {