mirror of
https://github.com/discourse/discourse.git
synced 2024-11-27 16:53:43 +08:00
ignore username matches inside <pre> or <code>
also remember, lazy ? faster than greedy, less backtracking
This commit is contained in:
parent
dd9ea50456
commit
01e0226086
|
@ -142,9 +142,9 @@ Discourse.Markdown = {
|
|||
converter.hooks.chain("postConversion", function(text) {
|
||||
if (!text) return "";
|
||||
|
||||
// don't do @username mentions inside <pre> blocks
|
||||
text = text.replace(/<pre>([\s\S]*@[\s\S]*)<\/pre>/gi, function(wholeMatch, inner) {
|
||||
return "<pre>" + (inner.replace(/@/g, '@')) + "</pre>";
|
||||
// don't do @username mentions inside <pre> or <code> blocks
|
||||
text = text.replace(/<(pre|code>([\s\S]*?@[\s\S]*?)<\/(pre|code)>)/gi, function(wholeMatch, m1, m2, m3) {
|
||||
return "<" + m1 + ">" + (m2.replace(/@/g, '@')) + "</" + m3 + ">";
|
||||
});
|
||||
|
||||
// add @username mentions, if valid; must be bounded on left and right by non-word characters
|
||||
|
|
Loading…
Reference in New Issue
Block a user