Author: gs Date: Wed Feb 1 13:23:51 2012 New Revision: 67338 URL: http://svn.opensuse.org/viewcvs/yast?rev=67338&view=rev Log: ignore <tt> tag, interpret html tags inside <pre> (bnc #724119) Modified: trunk/ncurses/src/NCRichText.cc trunk/ncurses/src/NCRichText.h Modified: trunk/ncurses/src/NCRichText.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCRichText.cc?rev=67338&r1=67337&r2=67338&view=diff ============================================================================== --- trunk/ncurses/src/NCRichText.cc (original) +++ trunk/ncurses/src/NCRichText.cc Wed Feb 1 13:23:51 2012 @@ -344,36 +344,32 @@ } } - -void NCRichText::PadPlainTXT( const wchar_t * osch, const unsigned olen ) +void NCRichText::PadPreTXT( const wchar_t * osch, const unsigned olen ) { wstring wtxt( osch, olen ); + // resolve the entities even in PRE (#71718) wtxt = filterEntities( wtxt ); - + NCstring nctxt( wtxt ); NCtext ftext( nctxt ); - if ( ftext.Columns() > textwidth ) - textwidth = ftext.Columns(); - - AdjustPad( wsze( cl + ftext.Lines(), textwidth ) ); + int len = textWidth( wtxt ); + if ( cc + len > textwidth ) + { + textwidth = cc + len; + AdjustPad( wsze(cl+ftext.Lines(), textwidth) ); + } + // insert the text const wchar_t * sch = wtxt.data(); while ( *sch ) { - if ( *sch != L'\r' ) // skip carriage return - { - myPad()->addwstr( sch, 1 ); // add one wide chararacter - cc += wcwidth( *sch ); + myPad()->addwstr( sch, 1 ); // add one wide chararacter + cc += wcwidth( *sch ); - if ( *sch == L'\n' ) - { - PadNL(); // add a new line - } - } ++sch; } } @@ -420,17 +416,16 @@ while ( *wch && WDtoken.find( *wch ) == wstring::npos ); } +static wstring PREtoken( L"<\n\v\r" ); // line manipulations + TokenStart '<' + inline void SkipPreTXT( const wchar_t *& wch ) { - wstring wstr( wch, 6 ); - do { ++wch; - wstr.assign( wch, 6 ); } - while ( *wch && wstr != L"</pre>" ); + while ( *wch && PREtoken.find( *wch ) == wstring::npos ); } @@ -483,16 +478,14 @@ break; case L'<': - if ( !preTag ) - { - swch = wch; - SkipToken( wch ); + swch = wch; + SkipToken( wch ); + + if ( PadTOKEN( swch, wch ) ) + break; // strip token + else + wch = swch; // reset and fall through - if ( PadTOKEN( swch, wch ) ) - break; // strip token - else - wch = swch; // reset and fall through - } default: swch = wch; @@ -504,9 +497,7 @@ else { SkipPreTXT( wch ); - PadPlainTXT( swch, wch - swch ); - preTag = false; - PadNL(); // add new line after pre is closed + PadPreTXT( swch, wch - swch ); } break; @@ -515,6 +506,7 @@ PadBOL(); AdjustPad( wsze( cl, textwidth ) ); + yuiMilestone() << "adjust: lines: " << cl << " columns: " << textwidth << endl; yuiDebug() << "Anchors: " << anchors.size() << endl; for ( unsigned i = 0; i < anchors.size(); ++i ) @@ -841,7 +833,7 @@ else if ( value == L"li" ) token = T_LI; else if ( value == L"ol" ) { token = T_LEVEL; leveltag = 1; } else if ( value == L"qt" ) token = T_IGNORE; - else if ( value == L"tt" ) token = T_TT; + else if ( value == L"tt" ) token = T_IGNORE; else if ( value == L"ul" ) { token = T_LEVEL; leveltag = 0; } break; @@ -981,11 +973,12 @@ if ( !endtag ) { - preTag = true; // display plain text + preTag = true; // display text preserving newlines and spaces } else { preTag = false; + PadNL(); // add new line after pre } break; Modified: trunk/ncurses/src/NCRichText.h URL: http://svn.opensuse.org/viewcvs/yast/trunk/ncurses/src/NCRichText.h?rev=67338&r1=67337&r2=67338&view=diff ============================================================================== --- trunk/ncurses/src/NCRichText.h (original) +++ trunk/ncurses/src/NCRichText.h Wed Feb 1 13:23:51 2012 @@ -91,8 +91,7 @@ unsigned cindent; bool atbol; - bool preTag; // default is false; set true - // if <pre> tag is found + bool preTag; // <pre> tag unsigned Tattr; @@ -212,7 +211,7 @@ void PadBOL(); void PadWS( const bool tab = false ); void PadTXT( const wchar_t * sch, const unsigned len ); - void PadPlainTXT( const wchar_t * sch, const unsigned len ); + void PadPreTXT( const wchar_t * sch, const unsigned len ); bool PadTOKEN( const wchar_t * sch, const wchar_t *& ech ); protected: -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org