diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-01-06 22:06:44 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-01-06 22:06:44 +0000 |
| commit | ad7500f87900f3db170c11c6cf997e0c7493babc (patch) | |
| tree | 3721cfd360f6eb48dbc40100098a1e489825f0ba /lib | |
| parent | 552f0309fcc96fdf12dd2ed9db309093ba3af281 (diff) | |
Reduce to a single export
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/index.js | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/lib/index.js b/lib/index.js index 0cb55f9..0f45501 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,16 +1,11 @@ +var extend = require("xtend"); + var docxReader = require("./docx-reader"); var DocumentConverter = require("./document-to-html").DocumentConverter; -var htmlPaths = require("./html-paths"); -var documentMatchers = require("./document-matchers"); var style = require("./style-reader").readStyle; -exports.Converter = Converter; exports.convertToHtml = convertToHtml; -exports.read = read; -exports.convertDocumentToHtml = convertDocumentToHtml; -exports.htmlPaths = htmlPaths; -exports.style = style; -var standardOptions = exports.standardOptions = { +var standardOptions = { styleMap: [ style("p.Heading1 => h1:fresh"), style("p.Heading2 => h2:fresh"), @@ -29,27 +24,22 @@ var standardOptions = exports.standardOptions = { ] }; -function Converter(options) { - this._options = options || standardOptions; -} - -Converter.prototype.convertToHtml = function(inputOptions) { - var options = this._options; - return read(inputOptions) +function convertToHtml(input, options) { + options = options || {}; + if (options.styleMap) { + options.styleMap = options.styleMap.split("\n").map(function(line) { + return style(line.trim()); + }); + } + + var fullOptions = extend(standardOptions, options); + + return docxReader.read(input) .then(function(documentResult) { - return convertDocumentToHtml(documentResult, options); + return convertDocumentToHtml(documentResult, fullOptions); }); } -function convertToHtml(input, options) { - var converter = new Converter(options); - return converter.convertToHtml(input); -} - -function read(inputOptions) { - return docxReader.read(inputOptions); -} - function convertDocumentToHtml(documentResult, options) { var documentConverter = new DocumentConverter(options); return documentResult.flatMapThen(function(document) { |
