|
|
@ -18,6 +18,11 @@ var escapeHtml = require('./common/utils').escapeHtml; |
|
|
|
var default_rules = {}; |
|
|
|
|
|
|
|
|
|
|
|
default_rules.code_inline = function (tokens, idx /*, options, env */) { |
|
|
|
return '<code>' + escapeHtml(tokens[idx].content) + '</code>'; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
default_rules.code_block = function (tokens, idx /*, options, env */) { |
|
|
|
return '<pre><code>' + escapeHtml(tokens[idx].content) + '</code></pre>\n'; |
|
|
|
}; |
|
|
@ -176,10 +181,12 @@ Renderer.prototype.renderToken = function renderToken(tokens, idx, options) { |
|
|
|
result += (token.nesting === -1 ? '</' : '<') + token.tag; |
|
|
|
|
|
|
|
// Encode attributes, e.g. `<img src="foo"`
|
|
|
|
result += this.renderAttrs(token.attrs); |
|
|
|
if (typeof token.attrs !== 'undefined') { |
|
|
|
result += this.renderAttrs(token.attrs); |
|
|
|
} |
|
|
|
|
|
|
|
// Add a slash for self-closing tags, e.g. `<img src="foo" /`
|
|
|
|
if (token.nesting === 0 && options.xhtmlOut && token.content === null) { |
|
|
|
if (token.nesting === 0 && options.xhtmlOut) { |
|
|
|
result += ' /'; |
|
|
|
} |
|
|
|
|
|
|
@ -205,11 +212,6 @@ Renderer.prototype.renderToken = function renderToken(tokens, idx, options) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// If it's self-contained token, add its contents + closing tag
|
|
|
|
if (token.nesting === 0 && token.content !== null) { |
|
|
|
result += '>' + escapeHtml(token.content) + '</' + token.tag; |
|
|
|
} |
|
|
|
|
|
|
|
result += needLf ? '>\n' : '>'; |
|
|
|
|
|
|
|
return result; |
|
|
|