Skip to content

Commit

Permalink
Using lazy match, and fixing cleaning in code
Browse files Browse the repository at this point in the history
Code blocks as parsed by Markdown add attributes, which the
regex here wasn't catching, so it was updated. Also, it did not
match line breaks.

Greedy match might end up eating text that should be parsed if you
had more than one code block or blockquote in your post.

Fixes #69
  • Loading branch information
julianlam committed May 11, 2016
1 parent 10bc5f2 commit 1443fc5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library.js
Expand Up @@ -240,11 +240,11 @@ Mentions.clean = function(input, isMarkdown, stripBlockquote, stripCode) {
return input;
}
if (stripBlockquote) {
var bqMatch = isMarkdown ? /^>.*$/gm : /^<blockquote>.*<\/blockquote>/gm;
var bqMatch = isMarkdown ? /^>.*$/gm : /^<blockquote>.*?<\/blockquote>/gm;
input = input.replace(bqMatch, '');
}
if (stripCode) {
var pfMatch = isMarkdown ? /`[^`\n]+`/gm : /<code>.*<\/code>/gm;
var pfMatch = isMarkdown ? /`[^`\n]+`/gm : /<code[\s\S]*?<\/code>/gm;
input = input.replace(pfMatch, '');
}

Expand Down

0 comments on commit 1443fc5

Please sign in to comment.