|
|
@ -227,8 +227,9 @@ function Renderer() { |
|
|
|
this.rules = assign({}, rules); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Renderer.prototype.render = function (tokens, options) { |
|
|
|
var i, len, rule, name, next, |
|
|
|
var i, len, name, next, |
|
|
|
result = '', |
|
|
|
rules = this.rules, |
|
|
|
tightStack = []; |
|
|
@ -238,7 +239,6 @@ Renderer.prototype.render = function (tokens, options) { |
|
|
|
|
|
|
|
for (i = 0, len = tokens.length; i < len; i++) { |
|
|
|
name = tokens[i].type; |
|
|
|
rule = rules[name]; |
|
|
|
|
|
|
|
// Dirty stack machine to track lists style (loose/tight)
|
|
|
|
if (name === 'ordered_list_open' || name === 'bullet_list_open') { |
|
|
@ -279,11 +279,7 @@ Renderer.prototype.render = function (tokens, options) { |
|
|
|
if (tokens[i].type === 'inline') { |
|
|
|
result += this.render(tokens[i].children, options); |
|
|
|
} else { |
|
|
|
// TODO: temporary check
|
|
|
|
if (!rule) { |
|
|
|
throw new Error('Renderer error: unknown token ' + name); |
|
|
|
} |
|
|
|
result += rule(tokens, i, options); |
|
|
|
result += rules[name](tokens, i, options); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|