aboutsummaryrefslogtreecommitdiff
path: root/lib/document-to-html.js
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2013-05-03 21:27:00 +0100
committerMichael Williamson <mike@zwobble.org>2013-05-03 21:27:00 +0100
commitce01e3ec266ca3cbd96832766174e49337db98f8 (patch)
tree60a6bec29909354bd95ecac7319f94f9bbde1d1e /lib/document-to-html.js
parent23438dd97f93b86115cc4196c88d12e5168acbd5 (diff)
Replace paragraphStyleMap with more general styleMap
Diffstat (limited to 'lib/document-to-html.js')
-rw-r--r--lib/document-to-html.js13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index 47e7e86..896053f 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -12,7 +12,7 @@ function DocumentConverter(options) {
options = options || {};
var defaultParagraphStyle = options.defaultParagraphStyle || htmlPaths.topLevelElement("p");
- var paragraphStyleMap = options.paragraphStyleMap || {};
+ var styleMap = options.styleMap || [];
var runStyleMap = options.runStyleMap || {};
function convertToHtml(document) {
@@ -47,11 +47,16 @@ function DocumentConverter(options) {
}
function styleForParagraph(element, messages) {
- var htmlPath = paragraphStyleMap[element.styleName];
- if (element.styleName && !htmlPath) {
+ for (var i = 0; i < styleMap.length; i++) {
+ if (styleMap[i].from(element)) {
+ return styleMap[i].to;
+ }
+ }
+
+ if (element.styleName) {
messages.push(results.warning("Unrecognised paragraph style: " + element.styleName));
}
- return htmlPath || defaultParagraphStyle;
+ return defaultParagraphStyle;
}
function convertRun(run, html, messages, callback) {