aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2016-03-28 12:54:28 +0100
committerMichael Williamson <mike@zwobble.org>2016-03-28 13:47:37 +0100
commit4a61edf08990a0ed8c243f9001d9069d7a644a50 (patch)
treef6ecb4b3a1f6c54b907f02596dcb7fd036499fc5
parentb4a2cfa279ac777f1c331ffcf46da6f9394c5bf3 (diff)
Remove support for convertUnderline
-rw-r--r--NEWS2
-rw-r--r--lib/document-to-html.js16
-rw-r--r--tests/document-to-html.tests.js11
-rw-r--r--tests/mammoth.tests.js7
4 files changed, 8 insertions, 28 deletions
diff --git a/NEWS b/NEWS
index 9ddb0f2..b373221 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
# 1.0.0
+* Remove deprecated convertUnderline option.
+
* Generated IDs no longer insert a hyphen after the ID prefix.
* The default ID prefix is now the empty string rather than a random number
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index baf900e..83c3b5f 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -134,7 +134,12 @@ function DocumentConversion(options) {
}
function convertUnderline(runHtml) {
- return (options.convertUnderline || defaultConvertUnderline)(runHtml);
+ var style = findStyle({type: "underline"});
+ if (style) {
+ return Html.pathToNode(style.to, [runHtml]);
+ } else {
+ return runHtml;
+ }
}
function convertRunProperty(result, elementType, defaultTagName) {
@@ -146,15 +151,6 @@ function DocumentConversion(options) {
}
}
- function defaultConvertUnderline(runHtml) {
- var style = findStyle({type: "underline"});
- if (style) {
- return Html.pathToNode(style.to, [runHtml]);
- } else {
- return runHtml;
- }
- }
-
function findStyle(element) {
for (var i = 0; i < styleMap.length; i++) {
if (styleMap[i].from.matches(element)) {
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index fae4da5..7760b17 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -1,7 +1,6 @@
var assert = require("assert");
var promises = require("../lib/promises");
-var mammoth = require("../lib");
var documents = require("../lib/documents");
var DocumentConverter = require("../lib/document-to-html").DocumentConverter;
var test = require("./testing").test;
@@ -192,16 +191,6 @@ describe('DocumentConverter', function() {
});
});
- test('underline runs can be wrapped in <u> tags using convertUnderline option', function() {
- var run = runOfText("Hello.", {isUnderline: true});
- var converter = new DocumentConverter({
- convertUnderline: mammoth.underline.element("u")
- });
- return converter.convertToHtml(run).then(function(result) {
- assert.equal(result.value, "<u>Hello.</u>");
- });
- });
-
test('underline runs can be mapped using style mapping', function() {
var run = runOfText("Hello.", {isUnderline: true});
var converter = new DocumentConverter({
diff --git a/tests/mammoth.tests.js b/tests/mammoth.tests.js
index 0f0ad53..9d057f6 100644
--- a/tests/mammoth.tests.js
+++ b/tests/mammoth.tests.js
@@ -284,13 +284,6 @@ describe('mammoth', function() {
});
});
- test('underline can be configured with convertUnderline option', function() {
- var docxPath = path.join(__dirname, "test-data/underline.docx");
- return mammoth.convertToHtml({path: docxPath}, {convertUnderline: mammoth.underline.element("em")}).then(function(result) {
- assert.equal(result.value, '<p><strong>The <em>Sunset</em> Tree</strong></p>');
- });
- });
-
test('underline can be configured with style mapping', function() {
var docxPath = path.join(__dirname, "test-data/underline.docx");
return mammoth.convertToHtml({path: docxPath}, {styleMap: "u => em"}).then(function(result) {