Skip to content

Commit

Permalink
rely on options passed to the renderer object.
Browse files Browse the repository at this point in the history
  • Loading branch information
chjj committed Jan 10, 2014
1 parent 5e71666 commit cd507dd
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,9 @@ function Renderer(options) {
this.options = options || {};
}

Renderer.prototype.code = function(code, lang, escaped, options) {
options = options || {};

if (options.highlight) {
var out = options.highlight(code, lang);
Renderer.prototype.code = function(code, lang, escaped) {
if (this.options.highlight) {
var out = this.options.highlight(code, lang);
if (out != null && out !== code) {
escaped = true;
code = out;
Expand All @@ -758,7 +756,7 @@ Renderer.prototype.code = function(code, lang, escaped, options) {
}

return '<pre><code class="'
+ options.langPrefix
+ this.options.langPrefix
+ escape(lang, true)
+ '">'
+ (escaped ? code : escape(code, true))
Expand All @@ -773,11 +771,11 @@ Renderer.prototype.html = function(html) {
return html;
};

Renderer.prototype.heading = function(text, level, raw, options) {
Renderer.prototype.heading = function(text, level, raw) {
return '<h'
+ level
+ ' id="'
+ options.headerPrefix
+ this.options.headerPrefix
+ raw.toLowerCase().replace(/[^\w]+/g, '-')
+ '">'
+ text
Expand Down Expand Up @@ -959,15 +957,12 @@ Parser.prototype.tok = function() {
return this.renderer.heading(
this.inline.output(this.token.text),
this.token.depth,
this.token.text,
this.options
);
this.token.text);
}
case 'code': {
return this.renderer.code(this.token.text,
this.token.lang,
this.token.escaped,
this.options);
this.token.escaped);
}
case 'table': {
var header = ''
Expand Down

1 comment on commit cd507dd

@lukeapage
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its all very well relying on this.options if the rest of the code actually passes options to the renderer, which it doesn't...

this effectively stops the renderer looking at any options unless you explicitly create a renderer yourself, passing in the options..

Please sign in to comment.