mirror of
https://github.com/twisterarmy/twister-calm.git
synced 2025-01-11 15:37:54 +00:00
correct support of utf8 hashtags
This commit is contained in:
parent
acd8b839af
commit
b05b170504
@ -190,7 +190,7 @@ function htmlFormatMsg( msg, output, mentions ) {
|
||||
if( match[0] == "#" ) {
|
||||
output.append($.emotions(msg.substr(0, match.index)));
|
||||
tmp = msg.substr(match.index+1);
|
||||
var hashtag = _extractUsername(tmp);
|
||||
var hashtag = _extractHashtag(tmp);
|
||||
if( hashtag.length ) {
|
||||
var hashtagLinkTemplate = $("#hashtag-link-template").clone(true);
|
||||
hashtagLinkTemplate.removeAttr("id");
|
||||
@ -225,6 +225,19 @@ function _extractUsername(s) {
|
||||
return username.toLowerCase();
|
||||
}
|
||||
|
||||
// internal function for htmlFormatMsg
|
||||
function _extractHashtag(s) {
|
||||
var hashtag = "";
|
||||
for( var i = 0; i < s.length; i++ ) {
|
||||
if( " \n\t.,:/?!".indexOf(s[i]) < 0 ) {
|
||||
hashtag += s[i];
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hashtag;
|
||||
}
|
||||
|
||||
function escapeHtmlEntities(str) {
|
||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user