FIX: winky emoticons were matching with non-spaces before them.
This commit is contained in:
parent
535c90c298
commit
d46fc79344
|
@ -182,8 +182,8 @@ Discourse.Dialect = {
|
|||
@param {Function} emitter A function that emits the JsonML for the replacement.
|
||||
**/
|
||||
inlineReplace: function(token, emitter) {
|
||||
this.registerInline(token, function() {
|
||||
return [token.length, emitter.call(this, token)];
|
||||
this.registerInline(token, function(text, match, prev) {
|
||||
return [token.length, emitter.call(this, token, match, prev)];
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -37,14 +37,25 @@
|
|||
":-$" : '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 = {};
|
||||
Object.keys(translations).forEach(function (t) {
|
||||
if (t[0] === ':') {
|
||||
translationsWithColon[t] = translations[t];
|
||||
} else {
|
||||
var replacement = translations[t];
|
||||
Discourse.Dialect.inlineReplace(t, function () {
|
||||
return imageFor(replacement);
|
||||
Discourse.Dialect.inlineReplace(t, function (token, match, prev) {
|
||||
return checkPrev(prev) ? imageFor(replacement) : token;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -64,13 +75,7 @@
|
|||
firstSpace = text.search(/\s/),
|
||||
contents;
|
||||
|
||||
if (prev && prev.length) {
|
||||
var lastToken = prev[prev.length-1];
|
||||
if (lastToken && lastToken.charAt) {
|
||||
var lastChar = lastToken.charAt(lastToken.length-1);
|
||||
if (lastChar !== ' ') return;
|
||||
}
|
||||
}
|
||||
if (!checkPrev(prev)) { return; }
|
||||
|
||||
// If there is no trailing colon, check our translations that begin with colons
|
||||
if (endPos === -1 || (firstSpace !== -1 && endPos > firstSpace)) {
|
||||
|
|
Loading…
Reference in New Issue