Changeset 2088 for MediaWiki/trunk

Show
Ignore:
Timestamp:
2008-06-18 14:31:02 (4 months ago)
Author:
wwalc
Message:

#1785, part 2 - improved handling of preformatted text

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • MediaWiki/trunk/plugins/mediawiki/fckplugin.js

    r2087 r2088  
    571571                                                                this._inLSpace = false ; 
    572572                                                                var len = stringBuilder.length ; 
    573                                                                 if ( !stringBuilder[len-1].EndsWith("\n") && !stringBuilder[len-1].EndsWith(" ") && !stringBuilder[len-2].EndsWith("\n")) { 
    574                                                                         stringBuilder.push( "\n" ) ; 
    575                                                                         len++; 
    576                                                                 } 
    577                                                                 if (stringBuilder[len-1].EndsWith(" ") && stringBuilder[len-2].EndsWith("\n")) { 
    578                                                                         stringBuilder[len-1] = ""; 
     573                                                                if ( len>1 ) { 
     574                                                                        var tail = stringBuilder[len-2] + stringBuilder[len-1]; 
     575                                                                        if ( len>2 ) { 
     576                                                                                tail = stringBuilder[len-3] + tail ; 
     577                                                                        } 
     578                                                                        if (tail.EndsWith("\n ")) { 
     579                                                                                stringBuilder[len-1] = stringBuilder[len-1].replace(/ $/, ""); 
     580                                                                        } 
     581                                                                        else if ( !tail.EndsWith("\n") ) { 
     582                                                                                stringBuilder.push( "\n" ) ; 
     583                                                                        } 
    579584                                                                } 
    580585                                                        } 
     
    628633                                { 
    629634                                        if ( FCKBrowserInfo.IsIE && this._inLSpace ) { 
    630                                                 textValue = textValue.replace(/\r/, "\r ") ; 
     635                                                textValue = textValue.replace( /\r/g, "\r " ) ; 
     636                                                if (textValue.EndsWith( "\r " )) { 
     637                                                        textValue = textValue.replace( /\r $/, "\r" ); 
     638                                                } 
     639                                        } 
     640                                        if ( !FCKBrowserInfo.IsIE && this._inLSpace ) { 
     641                                                textValue = textValue.replace( /\n(?! )/g, "\n " ) ; 
    631642                                        } 
    632643                                         
     
    653664                                                textValue = textValue + " " ; 
    654665 
    655                                         //1785 - remove extra line 
    656666                                        if ( !this._inLSpace && !this._inPre && textValue == " " ) { 
    657667                                                var len = stringBuilder.length;