diff options
| -rw-r--r-- | lib/document-to-html.js | 8 | ||||
| -rw-r--r-- | tests/document-to-html.tests.js | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index 4559155..bd3a3d6 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -62,7 +62,7 @@ function DocumentConverter(options) { return style.to; } else { if (element.styleId) { - messages.push(results.warning("Unrecognised paragraph style: '" + element.styleName + "'")); + messages.push(unrecognisedStyleWarning("paragraph", element));; } return defaultParagraphStyle; } @@ -75,7 +75,7 @@ function DocumentConverter(options) { if (style) { runHtml.satisfyPath(style.to); } else { - messages.push(results.warning("Unrecognised run style: " + run.styleId)); + messages.push(unrecognisedStyleWarning("run", run)); } } if (run.isBold) { @@ -146,3 +146,7 @@ function DocumentConverter(options) { convertToHtml: convertToHtml }; } + +function unrecognisedStyleWarning(type, element) { + return results.warning("Unrecognised " + type + " style: '" + element.styleName + "'"); +} diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index dc70b58..b6e3254 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -156,11 +156,11 @@ describe('DocumentConverter', function() { }); test('run styles are converted to HTML if mapping exists', function() { - var run = runOfText("Hello.", {styleId: "Emphasis"}); + var run = runOfText("Hello.", {styleId: "Heading1Char", styleName: "Heading 1 Char"}); var converter = new DocumentConverter({ styleMap: [ { - from: documentMatchers.run("Emphasis"), + from: documentMatchers.run({styleName: "Heading 1 Char"}), to: htmlPaths.elements(["strong"]) } ] @@ -171,10 +171,10 @@ describe('DocumentConverter', function() { }); test('warning is emitted if run style is unrecognised', function() { - var run = runOfText("Hello.", {styleId: "Emphasis"}); + var run = runOfText("Hello.", {styleId: "Heading1Char", styleName: "Heading 1 Char"}); var converter = new DocumentConverter(); return converter.convertToHtml(run).then(function(result) { - assert.deepEqual(result.messages, [results.warning("Unrecognised run style: Emphasis")]); + assert.deepEqual(result.messages, [results.warning("Unrecognised run style: 'Heading 1 Char'")]); }); }); |
