skip too short syntax highlighting matches
This commit is contained in:
parent
ce79f407ea
commit
66124e5fa0
|
@ -2485,18 +2485,27 @@ $('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);
|
||||
if(currentMatch[0].slice(-1) == '<'
|
||||
|| currentMatch[0].slice(-1) == '&'
|
||||
|| currentMatch[0].slice(-1) == '?'
|
||||
|| currentMatch[0].slice(-1) == '!'
|
||||
|| currentMatch[0].slice(-1) == ' '
|
||||
|| currentMatch[0].slice(-1) == '-'
|
||||
|| currentMatch[0].slice(-1) == ':'
|
||||
|| currentMatch[0].slice(-1) == '.'
|
||||
|| currentMatch[0].slice(-1) == ',') {
|
||||
currentMatch[0] = currentMatch[0].slice(0,-1);
|
||||
|
||||
// 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) == '?'
|
||||
|| currentMatch[0].slice(-1) == '!'
|
||||
|| currentMatch[0].slice(-1) == ' '
|
||||
|| currentMatch[0].slice(-1) == '-'
|
||||
|| currentMatch[0].slice(-1) == ':'
|
||||
|| currentMatch[0].slice(-1) == '.'
|
||||
|| currentMatch[0].slice(-1) == ',') {
|
||||
currentMatch[0] = currentMatch[0].slice(0,-1);
|
||||
}
|
||||
currentVal = currentVal.replace(currentMatch[0],'<span class="' + k + '">' + currentMatch[0].replace('#','#').replace('@','@').replace('.','.').replace('!','!') + '</span>')
|
||||
}
|
||||
currentVal = currentVal.replace(currentMatch[0],'<span class="' + k + '">' + currentMatch[0].replace('#','#').replace('@','@').replace('.','.').replace('!','!') + '</span>')
|
||||
i++;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user