Skip to content
This repository has been archived by the owner on Feb 7, 2018. It is now read-only.

Commit

Permalink
Recognize @mention links for Twitter lists
Browse files Browse the repository at this point in the history
Signed-off-by: Stephan Beyer <s-beyer@gmx.net>
Signed-off-by: Dominik Kapusta <d@ayoy.net>
  • Loading branch information
sbeyer authored and ayoy committed Nov 14, 2009
1 parent 864f92d commit 86edf62
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions twitterapi/xmlparser.cpp
Expand Up @@ -279,8 +279,12 @@ QString XmlParser::textToHtml( QString newText )
QRegExp ahref( "((https?|ftp)://[^ ]+)( ?)", Qt::CaseInsensitive );
newText.replace( ahref, "<a href='\\1'>\\1</a>\\3" );

// recognize @mentions (letters, numbers and _ are allowed in nicks)
newText.replace( QRegExp( "(^| |[^a-zA-Z0-9])@([\\w\\d_]+)" ),
// recognize @mentions (letters, numbers are allowed in nicks)
// for Twitter, also allow _ in nicks and @user/list;
// the list name can only contain letters, numbers and dashes (-)
newText.replace( m_serviceUrl == TwitterAPI::URL_TWITTER ?
QRegExp( "(^|[^a-zA-Z0-9])@([\\w\\d_]+(/[\\w\\d-]+)?)" ) :
QRegExp( "(^|[^a-zA-Z0-9])@([\\w\\d]+)" ),
QString( "\\1<a href='%1/\\2'>@\\2</a>").arg( networkUrl ) );

// recognize e-mail addresses
Expand Down

0 comments on commit 86edf62

Please sign in to comment.