aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2014-03-25 12:56:01 +0000
committerMichael Williamson <mike@zwobble.org>2014-03-25 12:56:01 +0000
commit06cc13300efe79b591690b577a8b2094317ee551 (patch)
tree3b5c2c17037ebe71e95ff031557869e14ff9e348 /lib
parentf559596a8bb78306e596734bc44057656b6a2214 (diff)
Add prettyPrint option
Diffstat (limited to 'lib')
-rw-r--r--lib/document-to-html.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index ddb8848..1cbde9f 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -1,5 +1,6 @@
var promises = require("./promises");
var async = require("async");
+var beautifyHtml = require("js-beautify/js/lib/beautify-html")
var htmlPaths = require("./html-paths");
var HtmlGenerator = require("./html-generator").HtmlGenerator;
@@ -28,8 +29,11 @@ function DocumentConverter(options) {
return promises.nfcall(elementToHtml, document, html, messages).then(function() {
html.closeAll();
-
- return new results.Result(html.asString(), messages);
+ var htmlString = html.asString();
+ if (options.prettyPrint) {
+ htmlString = beautifyHtml.html_beautify(htmlString, {indent_size: 2});
+ }
+ return new results.Result(htmlString, messages);
});
}