Index: /MediaWiki/trunk/plugins/mediawiki/fckplugin.js
===================================================================
--- /MediaWiki/trunk/plugins/mediawiki/fckplugin.js	(revision 1867)
+++ /MediaWiki/trunk/plugins/mediawiki/fckplugin.js	(revision 1868)
@@ -97,5 +97,5 @@
 		var stringBuilder = new Array() ;
 		this._AppendNode( rootNode, stringBuilder, '' ) ;
-		return stringBuilder.join( '' ).Trim() ;
+		return stringBuilder.join( '' ).RTrim() ;
 	},
 
@@ -509,7 +509,5 @@
 								this._AppendChildNodes( htmlNode, stringBuilder, prefix ) ;
 								this._inLSpace = false ;
-								if ( stringBuilder[stringBuilder.length-2] == "\n" && stringBuilder[stringBuilder.length-1] == " " )
-									stringBuilder.pop() ;
-								else
+								if ( !stringBuilder[stringBuilder.length-1].EndsWith("\n") )
 									stringBuilder.push( "\n" ) ;
 							}
@@ -526,7 +524,8 @@
 								this._AppendChildNodes( htmlNode, stringBuilder, prefix ) ;
 								this._inPre = false ;
+
 								stringBuilder.push( '<\/' ) ;
 								stringBuilder.push( sNodeName ) ;
-								stringBuilder.push( '>' ) ;								
+								stringBuilder.push( '>' ) ;
 							}
 						
@@ -561,4 +560,8 @@
 				if ( !parentIsSpecialTag ) 
 				{
+					if ( FCKBrowserInfo.IsIE && this._inLSpace ) {
+						textValue = textValue.replace(/\r/, "\r ") ;
+					}
+					
 					textValue = textValue.replace( /[\n\t]/g, ' ' ) ; 
 	
@@ -566,14 +569,15 @@
 					textValue = textValue.replace( /\u00A0/g, '&nbsp;' ) ;
 
-					if ( !htmlNode.previousSibling ||
-					( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace )
+					if ( ( !htmlNode.previousSibling ||
+					( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) ) && !this._inLSpace && !this._inPre )
 					{
 						textValue = textValue.LTrim() ;
 					}
 
-					if ( !htmlNode.nextSibling && !this._inLSpace && (!htmlNode.parentNode || !htmlNode.parentNode.nextSibling))
+					if ( !htmlNode.nextSibling && !this._inLSpace && !this._inPre && (!htmlNode.parentNode || !htmlNode.parentNode.nextSibling))
 						textValue = textValue.RTrim() ;
 
-					textValue = textValue.replace( / {2,}/g, ' ' ) ;
+					if (!this._inLSpace && !this._inPre)
+						textValue = textValue.replace( / {2,}/g, ' ' ) ;
 
 					if ( this._inLSpace && textValue.length == 1 && textValue.charCodeAt(0) == 13 )
@@ -583,5 +587,5 @@
 				}
 				else 
-				{					
+				{
 					textValue = FCKTools.HTMLDecode(textValue).replace(/fckLR/g,'\r\n');
 				}
