mirror of
https://github.com/twisterarmy/twister-calm.git
synced 2025-02-04 11:04:20 +00:00
line breaks
This commit is contained in:
parent
2a77302783
commit
4e8eec970d
@ -157,7 +157,7 @@ function htmlFormatMsg( msg, output, mentions ) {
|
|||||||
if( match ) {
|
if( match ) {
|
||||||
index = (match[0] === match[1]) ? match.index : match.index + 1;
|
index = (match[0] === match[1]) ? match.index : match.index + 1;
|
||||||
if( match[1] == "@" ) {
|
if( match[1] == "@" ) {
|
||||||
output.append($.emotions(msg.substr(0, index)));
|
output.append(_formatText(msg.substr(0, index)));
|
||||||
tmp = msg.substr(index+1);
|
tmp = msg.substr(index+1);
|
||||||
var username = _extractUsername(tmp);
|
var username = _extractUsername(tmp);
|
||||||
if( username.length ) {
|
if( username.length ) {
|
||||||
@ -177,12 +177,13 @@ function htmlFormatMsg( msg, output, mentions ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( reHttp.exec(match[1]) ) {
|
if( reHttp.exec(match[1]) ) {
|
||||||
output.append($.emotions(msg.substr(0, index)));
|
output.append(_formatText(msg.substr(0, index)));
|
||||||
tmp = msg.substring(index);
|
tmp = msg.substring(index);
|
||||||
var space = tmp.indexOf(" ");
|
var space = tmp.indexOf(" ");
|
||||||
var url;
|
var url;
|
||||||
if( space != -1 ) url = tmp.substring(0,space); else url = tmp;
|
if( space != -1 ) url = tmp.substring(0,space); else url = tmp;
|
||||||
if( url.length ) {
|
if( url.length ) {
|
||||||
|
url = url.replace('&', '&');
|
||||||
var extLinkTemplate = $("#external-page-link-template").clone(true);
|
var extLinkTemplate = $("#external-page-link-template").clone(true);
|
||||||
extLinkTemplate.removeAttr("id");
|
extLinkTemplate.removeAttr("id");
|
||||||
extLinkTemplate.attr("href",url);
|
extLinkTemplate.attr("href",url);
|
||||||
@ -195,7 +196,7 @@ function htmlFormatMsg( msg, output, mentions ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( reEmail.exec(match[1]) ) {
|
if( reEmail.exec(match[1]) ) {
|
||||||
output.append($.emotions(msg.substr(0, index)));
|
output.append(_formatText(msg.substr(0, index)));
|
||||||
tmp = msg.substring(index);
|
tmp = msg.substring(index);
|
||||||
var space = tmp.indexOf(" ");
|
var space = tmp.indexOf(" ");
|
||||||
var email;
|
var email;
|
||||||
@ -213,7 +214,7 @@ function htmlFormatMsg( msg, output, mentions ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if( match[1] == "#" ) {
|
if( match[1] == "#" ) {
|
||||||
output.append($.emotions(msg.substr(0, index)));
|
output.append(_formatText(msg.substr(0, index)));
|
||||||
tmp = msg.substr(index+1);
|
tmp = msg.substr(index+1);
|
||||||
var hashtag = _extractHashtag(tmp);
|
var hashtag = _extractHashtag(tmp);
|
||||||
if( hashtag.length ) {
|
if( hashtag.length ) {
|
||||||
@ -236,12 +237,19 @@ function htmlFormatMsg( msg, output, mentions ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
output.append($.emotions(msg));
|
output.append(_formatText(msg));
|
||||||
msg = "";
|
msg = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// internal function for htmlFormatMsg
|
// internal function for htmlFormatMsg
|
||||||
|
function _formatText(msg)
|
||||||
|
{
|
||||||
|
msg = $.emotions(msg);
|
||||||
|
msg = msg.replace(/\n/g, '<br />');
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
function _extractUsername(s) {
|
function _extractUsername(s) {
|
||||||
var username = "";
|
var username = "";
|
||||||
for( var i = 0; i < s.length; i++ ) {
|
for( var i = 0; i < s.length; i++ ) {
|
||||||
@ -272,5 +280,5 @@ function _extractHashtag(s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function escapeHtmlEntities(str) {
|
function escapeHtmlEntities(str) {
|
||||||
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
return str.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", ''');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user