Browse Source

Reformattted renderer fns - more compact

pull/25/head
Vitaly Puzrin 10 years ago
parent
commit
fe04849911
  1. 99
      lib/renderer.js

99
lib/renderer.js

@ -19,13 +19,8 @@ var escapeHtml = require('./common/utils').escapeHtml;
var rules = {};
rules.blockquote_open = function (/* tokens, idx, options, env */) {
return '<blockquote>\n';
};
rules.blockquote_close = function (/* tokens, idx, options, env */) {
return '</blockquote>\n';
};
rules.blockquote_open = function () { return '<blockquote>\n'; };
rules.blockquote_close = function () { return '</blockquote>\n'; };
rules.code_block = function (tokens, idx /*, options, env */) {
@ -74,13 +69,9 @@ rules.hr = function (tokens, idx, options /*, env */) {
};
rules.bullet_list_open = function (/* tokens, idx, options, env */) {
return '<ul>\n';
};
rules.bullet_list_close = function (/* tokens, idx, options, env */) {
return '</ul>\n';
};
rules.list_item_open = function (tokens, idx /*, options, env */) {
rules.bullet_list_open = function () { return '<ul>\n'; };
rules.bullet_list_close = function () { return '</ul>\n'; };
rules.list_item_open = function (tokens, idx /*, options, env */) {
var next = tokens[idx + 1];
if ((next.type === 'list_item_close') ||
(next.type === 'paragraph_open' && next.tight)) {
@ -88,18 +79,14 @@ rules.list_item_open = function (tokens, idx /*, options, env */) {
}
return '<li>\n';
};
rules.list_item_close = function (/* tokens, idx, options, env */) {
return '</li>\n';
};
rules.ordered_list_open = function (tokens, idx /*, options, env */) {
rules.list_item_close = function () { return '</li>\n'; };
rules.ordered_list_open = function (tokens, idx /*, options, env */) {
if (tokens[idx].order > 1) {
return '<ol start="' + tokens[idx].order + '">\n';
}
return '<ol>\n';
};
rules.ordered_list_close = function (/* tokens, idx, options, env */) {
return '</ol>\n';
};
rules.ordered_list_close = function () { return '</ol>\n'; };
rules.paragraph_open = function (tokens, idx /*, options, env */) {
@ -143,70 +130,40 @@ rules.image = function (tokens, idx, options, env, self) {
};
rules.table_open = function (/* tokens, idx, options, env */) {
return '<table>\n';
};
rules.table_close = function (/* tokens, idx, options, env */) {
return '</table>\n';
};
rules.thead_open = function (/* tokens, idx, options, env */) {
return '<thead>\n';
};
rules.thead_close = function (/* tokens, idx, options, env */) {
return '</thead>\n';
};
rules.tbody_open = function (/* tokens, idx, options, env */) {
return '<tbody>\n';
};
rules.tbody_close = function (/* tokens, idx, options, env */) {
return '</tbody>\n';
};
rules.tr_open = function (/* tokens, idx, options, env */) {
return '<tr>';
};
rules.tr_close = function (/* tokens, idx, options, env */) {
return '</tr>\n';
};
rules.th_open = function (tokens, idx /*, options, env */) {
rules.table_open = function () { return '<table>\n'; };
rules.table_close = function () { return '</table>\n'; };
rules.thead_open = function () { return '<thead>\n'; };
rules.thead_close = function () { return '</thead>\n'; };
rules.tbody_open = function () { return '<tbody>\n'; };
rules.tbody_close = function () { return '</tbody>\n'; };
rules.tr_open = function () { return '<tr>'; };
rules.tr_close = function () { return '</tr>\n'; };
rules.th_open = function (tokens, idx /*, options, env */) {
if (tokens[idx].align) {
return '<th style="text-align:' + tokens[idx].align + '">';
}
return '<th>';
};
rules.th_close = function (/* tokens, idx, options, env */) {
return '</th>';
};
rules.td_open = function (tokens, idx /*, options, env */) {
rules.th_close = function () { return '</th>'; };
rules.td_open = function (tokens, idx /*, options, env */) {
if (tokens[idx].align) {
return '<td style="text-align:' + tokens[idx].align + '">';
}
return '<td>';
};
rules.td_close = function (/* tokens, idx, options, env */) {
return '</td>';
};
rules.td_close = function () { return '</td>'; };
rules.strong_open = function (/* tokens, idx, options, env */) {
return '<strong>';
};
rules.strong_close = function (/* tokens, idx, options, env */) {
return '</strong>';
};
rules.em_open = function (/* tokens, idx, options, env */) {
return '<em>';
};
rules.em_close = function (/* tokens, idx, options, env */) {
return '</em>';
};
rules.strong_open = function () { return '<strong>'; };
rules.strong_close = function () { return '</strong>'; };
rules.s_open = function (/* tokens, idx, options, env */) {
return '<s>';
};
rules.s_close = function (/* tokens, idx, options, env */) {
return '</s>';
};
rules.em_open = function () { return '<em>'; };
rules.em_close = function () { return '</em>'; };
rules.s_open = function () { return '<s>'; };
rules.s_close = function () { return '</s>'; };
rules.hardbreak = function (tokens, idx, options /*, env */) {

Loading…
Cancel
Save