Skip to content

Commit

Permalink
Merge pull request #468 from trinketapp/master
Browse files Browse the repository at this point in the history
Ability to provide a custom sanitize routine
  • Loading branch information
chjj committed May 8, 2015
2 parents 7ff2f1d + 55ea824 commit e91a45c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,10 @@ Lexer.prototype.token = function(src, top, bq) {
if (cap = this.rules.html.exec(src)) {
src = src.substring(cap[0].length);
this.tokens.push({
type: this.options.sanitize
type: this.options.sanitize && typeof(this.options.sanitize) !== 'function'
? 'paragraph'
: 'html',
pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
pre: !this.options.sanitize && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
text: cap[0]
});
continue;
Expand Down Expand Up @@ -606,8 +606,10 @@ InlineLexer.prototype.output = function(src) {
}
src = src.substring(cap[0].length);
out += this.options.sanitize
? escape(cap[0])
: cap[0];
? typeof(this.options.sanitize) === 'function'
? this.options.sanitize(cap[0])
: escape(cap[0])
: cap[0]
continue;
}

Expand Down

0 comments on commit e91a45c

Please sign in to comment.