From 07edcd08a9e5c43c6442b9c8d65cf9b44b2cfd9e Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Tue, 11 Nov 2014 17:42:11 +0300 Subject: [PATCH] Sync with twister-html/pull/202 (double hashtags) Sync with https://github.com/miguelfreitas/twister-html/pull/202 --- src/twister.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/twister.cpp b/src/twister.cpp index c9d7a992..fefd0cf8 100644 --- a/src/twister.cpp +++ b/src/twister.cpp @@ -1447,15 +1447,24 @@ void updateSeenHashtags(std::string &message, int64_t msgTime) boost::algorithm::split(tokens,message,boost::algorithm::is_any_of(" \n\t.,:/?!;'\"()[]{}*"), boost::algorithm::token_compress_on); BOOST_FOREACH(string const& token, tokens) { - if( token.length() >= 2 ) { + if( token.length() >= 2 && token.at(0) == '#' ) { string word = token.substr(1); #ifdef HAVE_BOOST_LOCALE word = boost::locale::to_lower(word); #else boost::algorithm::to_lower(word); #endif - if( token.at(0) == '#') { + if( word.find('#') == string::npos ) { hashtags.insert(word); + } else { + vector subtokens; + boost::algorithm::split(subtokens,word,std::bind1st(std::equal_to(),'#'), + boost::algorithm::token_compress_on); + BOOST_FOREACH(string const& word, subtokens) { + if( word.length() ) { + hashtags.insert(word); + } + } } } }