aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/html.js7
-rwxr-xr-xjs/lib/index.js14
2 files changed, 13 insertions, 8 deletions
diff --git a/js/lib/html.js b/js/lib/html.js
index 9cb1676..9f0c4e3 100644
--- a/js/lib/html.js
+++ b/js/lib/html.js
@@ -21,7 +21,7 @@ var tag = function(name, attrs, selfclosing) {
var reHtmlTag = /\<[^>]*\>/;
-var renderNodes = function(block, options) {
+var renderNodes = function(block) {
var attrs;
var info_words;
@@ -48,7 +48,7 @@ var renderNodes = function(block, options) {
}
};
- options = options || {};
+ var options = this.options;
while ((event = walker.next())) {
entering = event.entering;
@@ -250,7 +250,7 @@ var replaceUnsafeChar = function(s) {
var reNeedsEscaping = /[&<>"]/;
// The HtmlRenderer object.
-function HtmlRenderer(){
+function HtmlRenderer(options){
return {
// default options:
softbreak: '\n', // by default, soft breaks are rendered as newlines in HTML
@@ -267,6 +267,7 @@ function HtmlRenderer(){
return s;
}
},
+ options: options || {},
render: renderNodes
};
}
diff --git a/js/lib/index.js b/js/lib/index.js
index d0532c6..22a2184 100755
--- a/js/lib/index.js
+++ b/js/lib/index.js
@@ -13,11 +13,15 @@
var util = require('util');
-var renderAST = function(tree) {
- return util.inspect(tree.toAST(), {depth: 20}) + '\n';
-};
-
module.exports.Node = require('./node');
module.exports.DocParser = require('./blocks');
module.exports.HtmlRenderer = require('./html');
-module.exports.ASTRenderer = renderAST;
+module.exports.ASTRenderer = function(options) {
+ return {
+ render: function(tree) {
+ return util.inspect(tree.toAST(), null, 20,
+ this.options.colors) + '\n';
+ },
+ options: options || {}
+ };
+}