aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-12-14 18:13:01 +0000
committerMichael Williamson <mike@zwobble.org>2013-12-14 18:13:01 +0000
commit841d7c1c60984c55bbc7e28461fd7d999b206154 (patch)
tree96ea5477d5514627381cba709053fd7b838ba5cd
parentcd79d48d9799b715188a63461f2023eb4187ad39 (diff)
Remove redundant defaultParagraphStyle option
-rw-r--r--lib/document-to-html.js2
-rw-r--r--tests/document-to-html.tests.js29
-rw-r--r--tests/mammoth.tests.js15
3 files changed, 31 insertions, 15 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index b34f951..bce92c8 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -10,7 +10,7 @@ exports.DocumentConverter = DocumentConverter;
function DocumentConverter(options) {
options = options || {};
- var defaultParagraphStyle = options.defaultParagraphStyle || htmlPaths.topLevelElement("p");
+ var defaultParagraphStyle = htmlPaths.topLevelElement("p");
var styleMap = options.styleMap || [];
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index 51e1a73..dde395d 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -39,18 +39,6 @@ describe('DocumentConverter', function() {
});
});
- test('can use non-default HTML element for unstyled paragraphs', function() {
- var document = new documents.Document([
- paragraphOfText("Hello.")
- ]);
- var converter = new DocumentConverter({
- defaultParagraphStyle: htmlPaths.topLevelElement("h1")
- });
- return converter.convertToHtml(document).then(function(result) {
- assert.equal(result.value, "<h1>Hello.</h1>");
- });
- });
-
test('text is HTML-escaped', function() {
var document = new documents.Document([
paragraphOfText("1 < 2")
@@ -89,6 +77,23 @@ describe('DocumentConverter', function() {
});
});
+ test('can use non-default HTML element for unstyled paragraphs', function() {
+ var document = new documents.Document([
+ paragraphOfText("Hello.")
+ ]);
+ var converter = new DocumentConverter({
+ styleMap: [
+ {
+ from: documentMatchers.paragraph(),
+ to: htmlPaths.topLevelElement("h1")
+ }
+ ]
+ });
+ return converter.convertToHtml(document).then(function(result) {
+ assert.equal(result.value, "<h1>Hello.</h1>");
+ });
+ });
+
test('warning is emitted if paragraph style is unrecognised', function() {
var document = new documents.Document([
paragraphOfText("Hello.", "Heading1"),
diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js
index 3a7eabb..a7385ca 100644
--- a/tests/mammoth.tests.js
+++ b/tests/mammoth.tests.js
@@ -6,6 +6,7 @@ var q = require("q");
var mammoth = require("../")
var htmlPaths = require("../lib/html-paths");
+var documentMatchers = require("../lib/document-matchers");
var testing = require("./testing");
var test = testing.test;
@@ -43,7 +44,12 @@ describe('mammoth', function() {
"word/document.xml": testData("simple/word/document.xml")
});
var converter = new mammoth.Converter({
- defaultParagraphStyle: htmlPaths.topLevelElement("h1")
+ styleMap: [
+ {
+ from: documentMatchers.paragraph(),
+ to: htmlPaths.topLevelElement("h1")
+ }
+ ]
});
return converter.convertToHtml({file: docxFile}).then(function(result) {
assert.equal("<h1>Hello.</h1>", result.value);
@@ -55,7 +61,12 @@ describe('mammoth', function() {
"word/document.xml": testData("simple/word/document.xml")
});
var options = {
- defaultParagraphStyle: htmlPaths.topLevelElement("h1")
+ styleMap: [
+ {
+ from: documentMatchers.paragraph(),
+ to: htmlPaths.topLevelElement("h1")
+ }
+ ]
};
return mammoth.convertToHtml({file: docxFile}, options).then(function(result) {
assert.equal("<h1>Hello.</h1>", result.value);