diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-04-22 11:05:42 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-04-22 11:05:42 +0100 |
| commit | 57cc8dff2e5723b8468c2f1fa1020ac2a9144022 (patch) | |
| tree | d04cc33addc704c07696aa44a4503c5e5388fad5 | |
| parent | bc8e8b44a05041bc656e83a87d857ec58ba0b4fe (diff) | |
Rename styleName to the more accurate styleId
| -rw-r--r-- | lib/document-matchers.js | 14 | ||||
| -rw-r--r-- | lib/document-to-html.js | 8 | ||||
| -rw-r--r-- | lib/documents.js | 4 | ||||
| -rw-r--r-- | lib/docx/document-xml-reader.js | 4 | ||||
| -rw-r--r-- | lib/style-reader.js | 4 | ||||
| -rw-r--r-- | tests/document-matchers.tests.js | 4 | ||||
| -rw-r--r-- | tests/document-to-html.tests.js | 8 | ||||
| -rw-r--r-- | tests/docx/document-xml-reader.tests.js | 8 | ||||
| -rw-r--r-- | tests/mammoth.tests.js | 2 |
9 files changed, 28 insertions, 28 deletions
diff --git a/lib/document-matchers.js b/lib/document-matchers.js index a5b5ff5..f116d3f 100644 --- a/lib/document-matchers.js +++ b/lib/document-matchers.js @@ -2,22 +2,22 @@ exports.paragraph = paragraph; exports.run = run; -function paragraph(styleName) { - return new Matcher("paragraph", styleName); +function paragraph(styleId) { + return new Matcher("paragraph", styleId); } -function run(styleName) { - return new Matcher("run", styleName); +function run(styleId) { + return new Matcher("run", styleId); } -function Matcher(elementType, styleName) { +function Matcher(elementType, styleId) { this._elementType = elementType; - this._styleName = styleName; + this._styleId = styleId; } Matcher.prototype.matches = function(element) { return element.type === this._elementType && - (this._styleName === undefined || element.styleName === this._styleName) && + (this._styleId === undefined || element.styleId === this._styleId) && (this._listIndex === undefined || isList(element, this._listIndex, this._listIsOrdered)); }; diff --git a/lib/document-to-html.js b/lib/document-to-html.js index e8c393c..347504b 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -61,8 +61,8 @@ function DocumentConverter(options) { if (style) { return style.to; } else { - if (element.styleName) { - messages.push(results.warning("Unrecognised paragraph style: " + element.styleName)); + if (element.styleId) { + messages.push(results.warning("Unrecognised paragraph style: " + element.styleId)); } return defaultParagraphStyle; } @@ -70,12 +70,12 @@ function DocumentConverter(options) { function convertRun(run, html, messages, callback) { var runHtml = new HtmlGenerator(); - if (run.styleName) { + if (run.styleId) { var style = findStyle(run); if (style) { runHtml.satisfyPath(style.to); } else { - messages.push(results.warning("Unrecognised run style: " + run.styleName)); + messages.push(results.warning("Unrecognised run style: " + run.styleId)); } } if (run.isBold) { diff --git a/lib/documents.js b/lib/documents.js index ce985e9..8463da0 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -20,7 +20,7 @@ function Paragraph(children, properties) { return { type: types.paragraph, children: children, - styleName: properties.styleName || null, + styleId: properties.styleId || null, numbering: properties.numbering || null, alignment: properties.alignment || null }; @@ -31,7 +31,7 @@ function Run(children, properties) { return { type: types.run, children: children, - styleName: properties.styleName || null, + styleId: properties.styleId || null, isBold: properties.isBold, isItalic: properties.isItalic }; diff --git a/lib/docx/document-xml-reader.js b/lib/docx/document-xml-reader.js index 1825006..a23aa5f 100644 --- a/lib/docx/document-xml-reader.js +++ b/lib/docx/document-xml-reader.js @@ -62,7 +62,7 @@ function DocumentXmlReader(relationships, contentTypes, docxFile, numbering) { var styleElement = element.first("w:pStyle"); if (styleElement) { - properties.styleName = styleElement.attributes["w:val"]; + properties.styleId = styleElement.attributes["w:val"]; } var alignElement = element.first("w:jc"); if (alignElement) { @@ -96,7 +96,7 @@ function DocumentXmlReader(relationships, contentTypes, docxFile, numbering) { var styleElement = element.first("w:rStyle"); if (styleElement) { - properties.styleName = styleElement.attributes["w:val"]; + properties.styleId = styleElement.attributes["w:val"]; } properties.isBold = !!element.first("w:b"); properties.isItalic = !!element.first("w:i"); diff --git a/lib/style-reader.js b/lib/style-reader.js index 0e50172..13f3609 100644 --- a/lib/style-reader.js +++ b/lib/style-reader.js @@ -89,8 +89,8 @@ function documentMatcherRule() { sequence.capture(elementTypeRule), sequence.capture(lop.rules.optional(classRule)), sequence.capture(optionalListRule) - ).map(function(createMatcher, styleName, applyList) { - return applyList(createMatcher(styleName.valueOrElse())); + ).map(function(createMatcher, styleId, applyList) { + return applyList(createMatcher(styleId.valueOrElse())); }); } diff --git a/tests/document-matchers.tests.js b/tests/document-matchers.tests.js index 6d77926..581746c 100644 --- a/tests/document-matchers.tests.js +++ b/tests/document-matchers.tests.js @@ -40,6 +40,6 @@ describe("document-matchers", function() { }); }); -function paragraphWithStyle(styleName) { - return new Paragraph([], {styleName: styleName}); +function paragraphWithStyle(styleId) { + return new Paragraph([], {styleId: styleId}); } diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 35f4424..b69d0fb 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -156,7 +156,7 @@ describe('DocumentConverter', function() { }); test('run styles are converted to HTML if mapping exists', function() { - var run = runOfText("Hello.", {styleName: "Emphasis"}); + var run = runOfText("Hello.", {styleId: "Emphasis"}); var converter = new DocumentConverter({ styleMap: [ { @@ -171,7 +171,7 @@ describe('DocumentConverter', function() { }); test('warning is emitted if run style is unrecognised', function() { - var run = runOfText("Hello.", {styleName: "Emphasis"}); + var run = runOfText("Hello.", {styleId: "Emphasis"}); var converter = new DocumentConverter(); return converter.convertToHtml(run).then(function(result) { assert.deepEqual(result.messages, [results.warning("Unrecognised run style: Emphasis")]); @@ -264,10 +264,10 @@ describe('DocumentConverter', function() { }); }); -function paragraphOfText(text, styleName) { +function paragraphOfText(text, styleId) { var run = runOfText(text); return new documents.Paragraph([run], { - styleName: styleName + styleId: styleId }); } diff --git a/tests/docx/document-xml-reader.tests.js b/tests/docx/document-xml-reader.tests.js index 7cdbefc..714134e 100644 --- a/tests/docx/document-xml-reader.tests.js +++ b/tests/docx/document-xml-reader.tests.js @@ -30,7 +30,7 @@ describe("readXmlElement: ", function() { test("paragraph has no style if it has no properties", function() { var paragraphXml = new XmlElement("w:p", {}, []); var paragraph = readXmlElementValue(paragraphXml); - assert.deepEqual(paragraph.styleName, null); + assert.deepEqual(paragraph.styleId, null); }); test("paragraph has style name read from paragraph properties if present", function() { @@ -38,7 +38,7 @@ describe("readXmlElement: ", function() { var propertiesXml = new XmlElement("w:pPr", {}, [styleXml]); var paragraphXml = new XmlElement("w:p", {}, [propertiesXml]); var paragraph = readXmlElementValue(paragraphXml); - assert.deepEqual(paragraph.styleName, "Heading1"); + assert.deepEqual(paragraph.styleId, "Heading1"); }); test("paragraph has justification read from paragraph properties if present", function() { @@ -72,14 +72,14 @@ describe("readXmlElement: ", function() { test("run has no style if it has no properties", function() { var runXml = runWithProperties([]); var run = readXmlElementValue(runXml); - assert.deepEqual(run.styleName, null); + assert.deepEqual(run.styleId, null); }); test("run has style name read from run properties if present", function() { var runStyleXml = new XmlElement("w:rStyle", {"w:val": "Emphasis"}); var runXml = runWithProperties([runStyleXml]); var run = readXmlElementValue(runXml); - assert.deepEqual(run.styleName, "Emphasis"); + assert.deepEqual(run.styleId, "Emphasis"); }); test("isBold is false if bold element is not present", function() { diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js index 0f9241e..cc08565 100644 --- a/tests/mammoth.tests.js +++ b/tests/mammoth.tests.js @@ -65,7 +65,7 @@ describe('mammoth', function() { }); var options = { transformDocument: function(document) { - document.children[0].styleName = "Heading1"; + document.children[0].styleId = "Heading1"; return document; } }; |
