Skip to content

Commit

Permalink
set token.escaped properly for sync highlighting. see markedjs#375.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Mar 26, 2014
1 parent 03375c9 commit 929f8a5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,26 +754,26 @@ function Renderer(options) {
this.options = options || {};
}

Renderer.prototype.code = function(code, lang, escaped) {
Renderer.prototype.code = function(code, lang, escaped, token) {
if (this.options.highlight) {
var out = this.options.highlight(code, lang);
if (out != null && out !== code) {
escaped = true;
token.escaped = true;
code = out;
}
}

if (!lang) {
return '<pre><code>'
+ (escaped ? code : escape(code, true))
+ (token.escaped ? code : escape(code, true))
+ '\n</code></pre>';
}

return '<pre><code class="'
+ this.options.langPrefix
+ escape(lang, true)
+ '">'
+ (escaped ? code : escape(code, true))
+ (token.escaped ? code : escape(code, true))
+ '\n</code></pre>\n';
};

Expand Down Expand Up @@ -978,7 +978,8 @@ Parser.prototype.tok = function() {
case 'code': {
return this.renderer.code(this.token.text,
this.token.lang,
this.token.escaped);
this.token.escaped,
this.token);
}
case 'table': {
var header = ''
Expand Down

0 comments on commit 929f8a5

Please sign in to comment.