mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: winky emoticons were matching with non-spaces before them.
This commit is contained in:
@@ -182,8 +182,8 @@ Discourse.Dialect = {
|
|||||||
@param {Function} emitter A function that emits the JsonML for the replacement.
|
@param {Function} emitter A function that emits the JsonML for the replacement.
|
||||||
**/
|
**/
|
||||||
inlineReplace: function(token, emitter) {
|
inlineReplace: function(token, emitter) {
|
||||||
this.registerInline(token, function() {
|
this.registerInline(token, function(text, match, prev) {
|
||||||
return [token.length, emitter.call(this, token)];
|
return [token.length, emitter.call(this, token, match, prev)];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -37,14 +37,25 @@
|
|||||||
":-$" : 'blush'
|
":-$" : 'blush'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function checkPrev(prev) {
|
||||||
|
if (prev && prev.length) {
|
||||||
|
var lastToken = prev[prev.length-1];
|
||||||
|
if (lastToken && lastToken.charAt) {
|
||||||
|
var lastChar = lastToken.charAt(lastToken.length-1);
|
||||||
|
if (lastChar !== ' ') return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
var translationsWithColon = {};
|
var translationsWithColon = {};
|
||||||
Object.keys(translations).forEach(function (t) {
|
Object.keys(translations).forEach(function (t) {
|
||||||
if (t[0] === ':') {
|
if (t[0] === ':') {
|
||||||
translationsWithColon[t] = translations[t];
|
translationsWithColon[t] = translations[t];
|
||||||
} else {
|
} else {
|
||||||
var replacement = translations[t];
|
var replacement = translations[t];
|
||||||
Discourse.Dialect.inlineReplace(t, function () {
|
Discourse.Dialect.inlineReplace(t, function (token, match, prev) {
|
||||||
return imageFor(replacement);
|
return checkPrev(prev) ? imageFor(replacement) : token;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -64,13 +75,7 @@
|
|||||||
firstSpace = text.search(/\s/),
|
firstSpace = text.search(/\s/),
|
||||||
contents;
|
contents;
|
||||||
|
|
||||||
if (prev && prev.length) {
|
if (!checkPrev(prev)) { return; }
|
||||||
var lastToken = prev[prev.length-1];
|
|
||||||
if (lastToken && lastToken.charAt) {
|
|
||||||
var lastChar = lastToken.charAt(lastToken.length-1);
|
|
||||||
if (lastChar !== ' ') return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there is no trailing colon, check our translations that begin with colons
|
// If there is no trailing colon, check our translations that begin with colons
|
||||||
if (endPos === -1 || (firstSpace !== -1 && endPos > firstSpace)) {
|
if (endPos === -1 || (firstSpace !== -1 && endPos > firstSpace)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user