skip too short syntax highlighting matches
This commit is contained in:
parent
ce79f407ea
commit
66124e5fa0
|
@ -2485,6 +2485,14 @@ $('body').on('keyup paste input', 'div.queet-box-syntax', function() {
|
|||
var i = 0;
|
||||
while(currentVal.match(v) && i < 100) { // 100 matches is enough, we don't want to get caught in an infinite loop here
|
||||
var currentMatch = currentVal.match(v);
|
||||
|
||||
// too small match, probably a single ! or something, just replace that with its html code
|
||||
if($.trim(currentMatch[0]).length < 2) {
|
||||
currentVal = currentVal.replace(currentMatch[0],currentMatch[0].replace('#','#').replace('@','@').replace('.','.').replace('!','!'));
|
||||
}
|
||||
// long enough match, create a mention span
|
||||
else {
|
||||
// don't include ending char, if any of these
|
||||
if(currentMatch[0].slice(-1) == '<'
|
||||
|| currentMatch[0].slice(-1) == '&'
|
||||
|| currentMatch[0].slice(-1) == '?'
|
||||
|
@ -2497,6 +2505,7 @@ $('body').on('keyup paste input', 'div.queet-box-syntax', function() {
|
|||
currentMatch[0] = currentMatch[0].slice(0,-1);
|
||||
}
|
||||
currentVal = currentVal.replace(currentMatch[0],'<span class="' + k + '">' + currentMatch[0].replace('#','#').replace('@','@').replace('.','.').replace('!','!') + '</span>')
|
||||
}
|
||||
i++;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user