Browse Source

correct support of utf8 hashtags

master
Denis Ryabov 11 years ago
parent
commit
b05b170504
  1. 15
      js/twister_formatpost.js

15
js/twister_formatpost.js

@ -190,7 +190,7 @@ function htmlFormatMsg( msg, output, mentions ) { @@ -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) { @@ -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, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
}

Loading…
Cancel
Save