aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-04-01 12:26:27 +0100
committerMichael Williamson <mike@zwobble.org>2013-04-01 12:26:27 +0100
commitd99c29f5bf1b597f7fb2c823d7894032f6c17010 (patch)
treeac7fa9b799ec7e2b3a088ade7826cf5d7f2baf4b /lib
parent6a9f7140a8f67a9af33c30dbd0acd61496ba1e91 (diff)
Add reading of run properties element
Diffstat (limited to 'lib')
-rw-r--r--lib/docx-reader.js13
-rw-r--r--lib/xmlreader.js5
2 files changed, 16 insertions, 2 deletions
diff --git a/lib/docx-reader.js b/lib/docx-reader.js
index 606c61b..2ab27bf 100644
--- a/lib/docx-reader.js
+++ b/lib/docx-reader.js
@@ -1,4 +1,5 @@
exports.read = read;
+exports.readXmlElement = readXmlElement;
var q = require("q");
var _ = require("underscore");
@@ -82,6 +83,18 @@ var xmlElementReaders = {
var children = readXmlElements(element.children);
return new documents.Run(children);
},
+ "w:rPr": function(element) {
+ var properties = {
+ type: "runProperties"
+ };
+
+ var styleElement = element.first("w:rStyle");
+ if (styleElement) {
+ properties.styleName = styleElement.attributes["w:val"];
+ }
+
+ return properties;
+ },
"w:t": function(element) {
return new documents.Text(element.children[0].value);
}
diff --git a/lib/xmlreader.js b/lib/xmlreader.js
index 67dda38..3efad63 100644
--- a/lib/xmlreader.js
+++ b/lib/xmlreader.js
@@ -3,6 +3,7 @@ var sax = require("sax");
var _ = require("underscore");
exports.read = read;
+exports.Element = Element;
function read(xmlString) {
var parser = sax.parser(true, {xmlns: true, position: false});
@@ -61,11 +62,11 @@ function mapValues(input, mapper, context) {
}, {}, context);
}
-function Element(name, attributes) {
+function Element(name, attributes, children) {
this.type = "element";
this.name = name;
this.attributes = attributes;
- this.children = [];
+ this.children = children || [];
}
Element.prototype.first = function(name) {