diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-01-10 17:17:09 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-01-10 17:17:09 -0800 |
commit | 2fe4743a1303ca5dcba4018519a044e9de8e11db (patch) | |
tree | e5ce227f23b113c3bc2b8bbb9f819d15618cec7c /js/lib | |
parent | 0f3d82b846fb70835a059542405e849a59fa2e0a (diff) |
Made 'options' a parameter of the renderer constructors...
as opposed to the 'render' function.
Added a 'colors' parameter for the ast renderer.
Diffstat (limited to 'js/lib')
-rw-r--r-- | js/lib/html.js | 7 | ||||
-rwxr-xr-x | js/lib/index.js | 14 |
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 || {} + }; +} |