From 2a92cb697d767a8967bbd2549f3069e76bd17c14 Mon Sep 17 00:00:00 2001 From: Konstantin Isakov Date: Thu, 14 May 2009 21:47:35 +0000 Subject: [PATCH] +! Only make dsl tooltip nonbreakable if its length is less than 70 symbols long. --- src/dsl.cc | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/dsl.cc b/src/dsl.cc index ccce9119..1b0da221 100644 --- a/src/dsl.cc +++ b/src/dsl.cc @@ -695,17 +695,23 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) // Replace all spaces with non-breakable ones, since that's how // Lingvo shows tooltips string title; - title.reserve( i->second.size() ); - for( char const * c = i->second.c_str(); *c; ++c ) - if ( *c == ' ' || *c == '\t' ) - { - // u00A0 in utf8 - title.push_back( 0xC2 ); - title.push_back( 0xA0 ); - } - else - title.push_back( *c ); + if ( Utf8::decode( i->second ).size() < 70 ) + { + title.reserve( i->second.size() ); + + for( char const * c = i->second.c_str(); *c; ++c ) + if ( *c == ' ' || *c == '\t' ) + { + // u00A0 in utf8 + title.push_back( 0xC2 ); + title.push_back( 0xA0 ); + } + else + title.push_back( *c ); + } + else + title = i->second; result += " title=\"" + Html::escape( title ) + "\""; }