diff --git a/lib/renderer.js b/lib/renderer.js
index db895ca..e2a8bb3 100644
--- a/lib/renderer.js
+++ b/lib/renderer.js
@@ -56,23 +56,16 @@ function getBreak(tokens, idx) {
var rules = {};
-rules.abbr_open = function (tokens, idx/*, options*/) {
- return '';
-};
-rules.abbr_close = function (/*tokens, idx, options*/) {
- return '';
-};
-
-rules.blockquote_open = function (/*tokens, idx, options*/) {
+rules.blockquote_open = function () {
return '
\n';
};
-rules.blockquote_close = function (tokens, idx /*, options*/) {
+rules.blockquote_close = function (tokens, idx) {
return '
' + getBreak(tokens, idx);
};
-rules.code = function (tokens, idx /*, options*/) {
+rules.code = function (tokens, idx) {
if (tokens[idx].block) {
return '' + escapeHtml(tokens[idx].content) + '
' + getBreak(tokens, idx);
}
@@ -107,10 +100,10 @@ rules.fence = function (tokens, idx, options) {
};
-rules.heading_open = function (tokens, idx /*, options*/) {
+rules.heading_open = function (tokens, idx) {
return '';
};
-rules.heading_close = function (tokens, idx /*, options*/) {
+rules.heading_close = function (tokens, idx) {
return '\n';
};
@@ -120,43 +113,43 @@ rules.hr = function (tokens, idx, options) {
};
-rules.bullet_list_open = function (/*tokens, idx, options*/) {
+rules.bullet_list_open = function () {
return '\n';
};
-rules.bullet_list_close = function (tokens, idx /*, options*/) {
+rules.bullet_list_close = function (tokens, idx) {
return '
' + getBreak(tokens, idx);
};
-rules.list_item_open = function (/*tokens, idx, options*/) {
+rules.list_item_open = function () {
return '';
};
-rules.list_item_close = function (/*tokens, idx, options*/) {
+rules.list_item_close = function () {
return '\n';
};
-rules.ordered_list_open = function (tokens, idx /*, options*/) {
+rules.ordered_list_open = function (tokens, idx) {
var token = tokens[idx];
return ' 1 ? ' start="' + token.order + '"' : '')
+ '>\n';
};
-rules.ordered_list_close = function (tokens, idx /*, options*/) {
+rules.ordered_list_close = function (tokens, idx) {
return '
' + getBreak(tokens, idx);
};
-rules.paragraph_open = function (tokens, idx/*, options*/) {
+rules.paragraph_open = function (tokens, idx) {
return tokens[idx].tight ? '' : '';
};
-rules.paragraph_close = function (tokens, idx /*, options*/) {
+rules.paragraph_close = function (tokens, idx) {
var addBreak = !(tokens[idx].tight && idx && tokens[idx - 1].type === 'inline' && !tokens[idx - 1].content);
return (tokens[idx].tight ? '' : '
') + (addBreak ? getBreak(tokens, idx) : '');
};
-rules.link_open = function (tokens, idx /*, options*/) {
+rules.link_open = function (tokens, idx) {
var title = tokens[idx].title ? (' title="' + escapeHtml(replaceEntities(tokens[idx].title)) + '"') : '';
return '';
};
-rules.link_close = function (/*tokens, idx, options*/) {
+rules.link_close = function () {
return '';
};
@@ -170,84 +163,84 @@ rules.image = function (tokens, idx, options) {
};
-rules.table_open = function (/*tokens, idx, options*/) {
+rules.table_open = function () {
return '\n';
};
-rules.table_close = function (/*tokens, idx, options*/) {
+rules.table_close = function () {
return '
\n';
};
-rules.thead_open = function (/*tokens, idx, options*/) {
+rules.thead_open = function () {
return '\n';
};
-rules.thead_close = function (/*tokens, idx, options*/) {
+rules.thead_close = function () {
return '\n';
};
-rules.tbody_open = function (/*tokens, idx, options*/) {
+rules.tbody_open = function () {
return '\n';
};
-rules.tbody_close = function (/*tokens, idx, options*/) {
+rules.tbody_close = function () {
return '\n';
};
-rules.tr_open = function (/*tokens, idx, options*/) {
+rules.tr_open = function () {
return '';
};
-rules.tr_close = function (/*tokens, idx, options*/) {
+rules.tr_close = function () {
return '
\n';
};
-rules.th_open = function (tokens, idx /*, options*/) {
+rules.th_open = function (tokens, idx) {
var token = tokens[idx];
return '';
};
-rules.th_close = function (/*tokens, idx, options*/) {
+rules.th_close = function () {
return ' | ';
};
-rules.td_open = function (tokens, idx /*, options*/) {
+rules.td_open = function (tokens, idx) {
var token = tokens[idx];
return '';
};
-rules.td_close = function (/*tokens, idx, options*/) {
+rules.td_close = function () {
return ' | ';
};
-rules.strong_open = function(/*tokens, idx, options*/) {
+rules.strong_open = function() {
return '';
};
-rules.strong_close = function(/*tokens, idx, options*/) {
+rules.strong_close = function() {
return '';
};
-rules.em_open = function(/*tokens, idx, options*/) {
+rules.em_open = function() {
return '';
};
-rules.em_close = function(/*tokens, idx, options*/) {
+rules.em_close = function() {
return '';
};
-rules.del_open = function(/*tokens, idx, options*/) {
+rules.del_open = function() {
return '';
};
-rules.del_close = function(/*tokens, idx, options*/) {
+rules.del_close = function() {
return '';
};
-rules.ins_open = function(/*tokens, idx, options*/) {
+rules.ins_open = function() {
return '';
};
-rules.ins_close = function(/*tokens, idx, options*/) {
+rules.ins_close = function() {
return '';
};
-rules.mark_open = function(/*tokens, idx, options*/) {
+rules.mark_open = function() {
return '';
};
-rules.mark_close = function(/*tokens, idx, options*/) {
+rules.mark_close = function() {
return '';
};
@@ -268,19 +261,27 @@ rules.softbreak = function (tokens, idx, options) {
};
-rules.text = function (tokens, idx /*, options*/) {
+rules.text = function (tokens, idx) {
return escapeHtml(tokens[idx].content);
};
-rules.htmlblock = function (tokens, idx /*, options*/) {
+rules.htmlblock = function (tokens, idx) {
return tokens[idx].content;
};
-rules.htmltag = function (tokens, idx /*, options*/) {
+rules.htmltag = function (tokens, idx) {
return tokens[idx].content;
};
+rules.abbr_open = function (tokens, idx) {
+ return '';
+};
+rules.abbr_close = function () {
+ return '';
+};
+
+
// Renderer class
function Renderer() {
// Clone rules object to allow local modifications
@@ -288,28 +289,28 @@ function Renderer() {
}
-Renderer.prototype.renderInline = function (tokens, options) {
+Renderer.prototype.renderInline = function (tokens, options, env) {
var result = '',
_rules = this.rules;
for (var i = 0, len = tokens.length; i < len; i++) {
- result += _rules[tokens[i].type](tokens, i, options);
+ result += _rules[tokens[i].type](tokens, i, options, env);
}
return result;
};
-Renderer.prototype.render = function (tokens, options) {
+Renderer.prototype.render = function (tokens, options, env) {
var i, len,
result = '',
_rules = this.rules;
for (i = 0, len = tokens.length; i < len; i++) {
if (tokens[i].type === 'inline') {
- result += this.renderInline(tokens[i].children, options);
+ result += this.renderInline(tokens[i].children, options, env);
} else {
- result += _rules[tokens[i].type](tokens, i, options);
+ result += _rules[tokens[i].type](tokens, i, options, env);
}
}