mirror of
https://github.com/discourse/discourse.git
synced 2025-02-10 05:14:59 +00: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) {
|
converter.hooks.chain("postConversion", function(text) {
|
||||||
if (!text) return "";
|
if (!text) return "";
|
||||||
|
|
||||||
// don't do @username mentions inside <pre> blocks
|
// don't do @username mentions inside <pre> or <code> blocks
|
||||||
text = text.replace(/<pre>([\s\S]*@[\s\S]*)<\/pre>/gi, function(wholeMatch, inner) {
|
text = text.replace(/<(pre|code>([\s\S]*?@[\s\S]*?)<\/(pre|code)>)/gi, function(wholeMatch, m1, m2, m3) {
|
||||||
return "<pre>" + (inner.replace(/@/g, '@')) + "</pre>";
|
return "<" + m1 + ">" + (m2.replace(/@/g, '@')) + "</" + m3 + ">";
|
||||||
});
|
});
|
||||||
|
|
||||||
// add @username mentions, if valid; must be bounded on left and right by non-word characters
|
// add @username mentions, if valid; must be bounded on left and right by non-word characters
|
||||||
|
Loading…
x
Reference in New Issue
Block a user