diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-08 20:34:34 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-08 20:34:34 +0100 |
| commit | c1a3e929b7268f14619daf3eff0085a747703f7e (patch) | |
| tree | 05b686b62e61d55ac2faebe49fe132d4757eeefb | |
| parent | 87105c192933b043a04b1ff00abd575805bb3c65 (diff) | |
Remove properties attribute from Run
| -rw-r--r-- | lib/document-to-html.js | 8 | ||||
| -rw-r--r-- | lib/documents.js | 13 | ||||
| -rw-r--r-- | tests/document-xml-reader.tests.js | 2 |
3 files changed, 16 insertions, 7 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index a2d7030..1fce576 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -51,16 +51,16 @@ function DocumentConverter(options) { function convertRun(run, html) { var runHtml = new HtmlGenerator(); - if (run.properties.styleName) { - var style = runStyleMap[run.properties.styleName]; + if (run.styleName) { + var style = runStyleMap[run.styleName]; if (style) { runHtml.style(style); } } - if (run.properties.isBold) { + if (run.isBold) { runHtml.push(styles.element("strong")); } - if (run.properties.isItalic) { + if (run.isItalic) { runHtml.push(styles.element("em")); } return convertElements(run.children, runHtml) diff --git a/lib/documents.js b/lib/documents.js index e4f0ef7..f1ce08b 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -5,8 +5,6 @@ function Document(children) { }; } -Run = ElementWithChildren("run"); - function Paragraph(children, properties) { properties = properties || {}; return { @@ -16,6 +14,17 @@ function Paragraph(children, properties) { }; } +function Run(children, properties) { + properties = properties || {}; + return { + type: "run", + children: children, + styleName: properties.styleName, + isBold: properties.isBold, + isItalic: properties.isItalic + }; +} + function Text(value) { return { type: "text", diff --git a/tests/document-xml-reader.tests.js b/tests/document-xml-reader.tests.js index d71f76c..cde4cf4 100644 --- a/tests/document-xml-reader.tests.js +++ b/tests/document-xml-reader.tests.js @@ -71,7 +71,7 @@ describe("readXmlElement: ", function() { var runPropertiesXml = new XmlElement("w:rPr", {}, [runStyleXml]); var runXml = new XmlElement("w:r", {}, [runPropertiesXml]); var result = readXmlElement(runXml); - assert.equal(result.value.properties.styleName, "Emphasis"); + assert.equal(result.value.styleName, "Emphasis"); }); test("run properties not included as child of run", function() { |
