Browse Source

Render `code_inline` & `code_block` attributes if exist, #261

pull/270/head
Vitaly Puzrin 9 years ago
parent
commit
5cd9007edf
  1. 6
      CHANGELOG.md
  2. 18
      lib/renderer.js

6
CHANGELOG.md

@ -1,3 +1,9 @@
6.1.1 / WIP
------------------
- Render `code_inline` & `code_block` attributes if exist.
6.1.0 / 2016-06-19 6.1.0 / 2016-06-19
------------------ ------------------

18
lib/renderer.js

@ -18,13 +18,23 @@ var escapeHtml = require('./common/utils').escapeHtml;
var default_rules = {}; var default_rules = {};
default_rules.code_inline = function (tokens, idx /*, options, env */) { default_rules.code_inline = function (tokens, idx, options, env, slf) {
return '<code>' + escapeHtml(tokens[idx].content) + '</code>'; var token = tokens[idx],
attrs = slf.renderAttrs(token);
return '<code' + (attrs ? ' ' + attrs : '') + '>' +
escapeHtml(tokens[idx].content) +
'</code>';
}; };
default_rules.code_block = function (tokens, idx /*, options, env */) { default_rules.code_block = function (tokens, idx, options, env, slf) {
return '<pre><code>' + escapeHtml(tokens[idx].content) + '</code></pre>\n'; var token = tokens[idx],
attrs = slf.renderAttrs(token);
return '<pre' + (attrs ? ' ' + attrs : '') + '><code>' +
escapeHtml(tokens[idx].content) +
'</code></pre>\n';
}; };

Loading…
Cancel
Save