aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-04-22 18:56:47 +0100
committerMichael Williamson <mike@zwobble.org>2014-04-22 18:56:47 +0100
commit782417f12f2fcfb157760c5ce6d435aac1f3fd62 (patch)
tree70115de8d5d77449f634929cf7c116e43fb00323
parent4f251acc131f57a4f160cb919a3cef9350215d01 (diff)
Show style name when emitted unknown paragraph style warning
-rw-r--r--lib/document-to-html.js2
-rw-r--r--tests/document-to-html.tests.js17
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index 347504b..4559155 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.styleId));
+ messages.push(results.warning("Unrecognised paragraph style: '" + element.styleName + "'"));
}
return defaultParagraphStyle;
}
diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js
index b69d0fb..dc70b58 100644
--- a/tests/document-to-html.tests.js
+++ b/tests/document-to-html.tests.js
@@ -62,12 +62,12 @@ describe('DocumentConverter', function() {
test('uses style mappings to pick HTML element for docx paragraph', function() {
var document = new documents.Document([
- paragraphOfText("Hello.", "Heading1"),
+ paragraphOfText("Hello.", "Heading1", "Heading 1"),
]);
var converter = new DocumentConverter({
styleMap: [
{
- from: documentMatchers.paragraph("Heading1"),
+ from: documentMatchers.paragraph({styleName: "Heading 1"}),
to: htmlPaths.topLevelElement("h1")
}
]
@@ -96,22 +96,22 @@ describe('DocumentConverter', function() {
test('warning is emitted if paragraph style is unrecognised', function() {
var document = new documents.Document([
- paragraphOfText("Hello.", "Heading1"),
+ paragraphOfText("Hello.", "Heading1", "Heading 1"),
]);
var converter = new DocumentConverter();
return converter.convertToHtml(document).then(function(result) {
- assert.deepEqual(result.messages, [results.warning("Unrecognised paragraph style: Heading1")]);
+ assert.deepEqual(result.messages, [results.warning("Unrecognised paragraph style: 'Heading 1'")]);
});
});
test('can use stacked styles to generate nested HTML elements', function() {
var document = new documents.Document([
- paragraphOfText("Hello.", "Heading1")
+ paragraphOfText("Hello.")
]);
var converter = new DocumentConverter({
styleMap: [
{
- from: documentMatchers.paragraph("Heading1"),
+ from: documentMatchers.paragraph(),
to: htmlPaths.elements(["h1", "span"])
}
]
@@ -264,10 +264,11 @@ describe('DocumentConverter', function() {
});
});
-function paragraphOfText(text, styleId) {
+function paragraphOfText(text, styleId, styleName) {
var run = runOfText(text);
return new documents.Paragraph([run], {
- styleId: styleId
+ styleId: styleId,
+ styleName: styleName
});
}