Skip to content

Commit

Permalink
Update renderer.js
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahDragon authored Apr 4, 2017
1 parent 23e7cb1 commit 683d22c
Showing 1 changed file with 24 additions and 26 deletions.
50 changes: 24 additions & 26 deletions lib/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,36 @@ function anchorId(str, transformOption) {
}

// Support AutoLink option
if (!this.config.marked.autolink) {
Renderer.prototype.link = function(href, title, text) {
var prot;

if (this.options.sanitize) {
try {
prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return '';
}

if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return '';
}
Renderer.prototype.link = function(href, title, text) {
var prot;

if (this.options.sanitize) {
try {
prot = decodeURIComponent(unescape(href))
.replace(/[^\w:]/g, '')
.toLowerCase();
} catch (e) {
return '';
}

if (href === text && title == null) {
return href;
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
return '';
}
}

var out = '<a href="' + href + '"';
if (!this.options.autolink && href === text && title == null) {
return href;
}

if (title) {
out += ' title="' + title + '"';
}
var out = '<a href="' + href + '"';

out += '>' + text + '</a>';
return out;
};
}
if (title) {
out += ' title="' + title + '"';
}

out += '>' + text + '</a>';
return out;
};

marked.setOptions({
langPrefix: '',
Expand Down

0 comments on commit 683d22c

Please sign in to comment.