From b10fffa46bc53408d0dcce12db9cd3b27dba16cb Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 18 Apr 2013 20:14:37 +0100 Subject: Emit warning if run style is not recognised --- lib/document-to-html.js | 2 ++ tests/document-to-html.tests.js | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/document-to-html.js b/lib/document-to-html.js index 3eefee9..b306223 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -60,6 +60,8 @@ function DocumentConverter(options) { var style = runStyleMap[run.styleName]; if (style) { runHtml.satisfyPath(style); + } else { + messages.push(results.warning("Unrecognised run style: " + run.styleName)); } } if (run.isBold) { diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index d63813d..a01018a 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -85,7 +85,7 @@ describe('DocumentConverter', function() { }); }); - test('warning is emitted if style is unrecognised', function() { + test('warning is emitted if paragraph style is unrecognised', function() { var document = new documents.Document([ paragraphOfText("Hello.", "Heading1"), ]); @@ -155,6 +155,14 @@ describe('DocumentConverter', function() { }); }); + test('warning is emitted if run style is unrecognised', function() { + var run = runOfText("Hello.", {styleName: "Emphasis"}); + var converter = new DocumentConverter(); + return converter.convertToHtml(run).then(function(result) { + assert.deepEqual(result.messages, [results.warning("Unrecognised run style: Emphasis")]); + }); + }); + test('docx hyperlink is converted to ', function() { var hyperlink = new documents.Hyperlink( [runOfText("Hello.")], -- cgit v1.2.3