|
|
@ -44,7 +44,7 @@ default_rules.fence = function (tokens, idx, options, env, self) { |
|
|
|
highlighted = escapeHtml(token.content); |
|
|
|
} |
|
|
|
|
|
|
|
return '<pre><code' + self.renderAttrs(token.attrs) + '>' |
|
|
|
return '<pre><code' + self.renderAttrs(token) + '>' |
|
|
|
+ highlighted |
|
|
|
+ '</code></pre>\n'; |
|
|
|
}; |
|
|
@ -126,20 +126,19 @@ function Renderer() { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Renderer.renderAttrs(attrs) -> String |
|
|
|
* - attrs (Array): array of token attributes |
|
|
|
* Renderer.renderAttrs(token) -> String |
|
|
|
* |
|
|
|
* Render token attributes to string. |
|
|
|
**/ |
|
|
|
Renderer.prototype.renderAttrs = function renderAttrs(attrs) { |
|
|
|
Renderer.prototype.renderAttrs = function renderAttrs(token) { |
|
|
|
var i, l, result; |
|
|
|
|
|
|
|
if (!attrs) { return ''; } |
|
|
|
if (!token.attrs) { return ''; } |
|
|
|
|
|
|
|
result = ''; |
|
|
|
|
|
|
|
for (i = 0, l = attrs.length; i < l; i++) { |
|
|
|
result += ' ' + escapeHtml(attrs[i][0]) + '="' + escapeHtml(attrs[i][1]) + '"'; |
|
|
|
for (i = 0, l = token.attrs.length; i < l; i++) { |
|
|
|
result += ' ' + escapeHtml(token.attrs[i][0]) + '="' + escapeHtml(token.attrs[i][1]) + '"'; |
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
@ -181,9 +180,7 @@ Renderer.prototype.renderToken = function renderToken(tokens, idx, options) { |
|
|
|
result += (token.nesting === -1 ? '</' : '<') + token.tag; |
|
|
|
|
|
|
|
// Encode attributes, e.g. `<img src="foo"`
|
|
|
|
if (typeof token.attrs !== 'undefined') { |
|
|
|
result += this.renderAttrs(token.attrs); |
|
|
|
} |
|
|
|
result += this.renderAttrs(token); |
|
|
|
|
|
|
|
// Add a slash for self-closing tags, e.g. `<img src="foo" /`
|
|
|
|
if (token.nesting === 0 && options.xhtmlOut) { |
|
|
|