Index: /MediaWiki/trunk/plugins/mediawiki/fckplugin.js
===================================================================
--- /MediaWiki/trunk/plugins/mediawiki/fckplugin.js	(revision 2086)
+++ /MediaWiki/trunk/plugins/mediawiki/fckplugin.js	(revision 2087)
@@ -570,6 +570,12 @@
 								this._AppendChildNodes( htmlNode, stringBuilder, prefix ) ;
 								this._inLSpace = false ;
-								if ( !stringBuilder[stringBuilder.length-1].EndsWith("\n") )
+								var len = stringBuilder.length ;
+								if ( !stringBuilder[len-1].EndsWith("\n") && !stringBuilder[len-1].EndsWith(" ") && !stringBuilder[len-2].EndsWith("\n")) {
 									stringBuilder.push( "\n" ) ;
+									len++;
+								}
+								if (stringBuilder[len-1].EndsWith(" ") && stringBuilder[len-2].EndsWith("\n")) {
+									stringBuilder[len-1] = "";
+								}
 							}
 							else
@@ -646,4 +652,15 @@
 					if ( this._inLSpace && textValue.length == 1 && textValue.charCodeAt(0) == 13 )
 						textValue = textValue + " " ;
+
+					//1785 - remove extra line
+					if ( !this._inLSpace && !this._inPre && textValue == " " ) {
+						var len = stringBuilder.length;
+						if (len > 1) {
+							var tail = stringBuilder[len-2] + stringBuilder[len-1];
+							if ( tail.toString().EndsWith( "\n" ) )
+								textValue = "";
+						}
+					}
+
 					if ( this._IsInsideCell )
 						textValue = textValue.replace( /\|/g, '&#124;' ) ;
