Browse Source

speed opt (renderer)

pull/14/head
Vitaly Puzrin 10 years ago
parent
commit
7a41005a46
  1. 10
      lib/renderer.js

10
lib/renderer.js

@ -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);
}
}

Loading…
Cancel
Save