--- fckplugin.js	2008-01-02 12:37:06.000000000 -0600
+++ fckplugin.js	2008-01-02 12:40:47.000000000 -0600
@@ -56,6 +56,7 @@
 {
 	_inPre : false,
 	_inLSpace : false,	
+	_appendSpace : false,
 
 	/*
 	 * Returns a string representing the HTML format of "data". The returned
@@ -189,17 +190,52 @@
 				var basicElement = this._BasicElements[ sNodeName ] ;
 				if ( basicElement )
 				{
+
 					if ( basicElement[0] )
-						stringBuilder.push( basicElement[0] ) ;
+					{
+						var pNode = htmlNode.previousSibling;
+
+						if ( pNode != null && pNode.nodeType == 3 && ( pNode.nodeValue == " " || pNode.nodeValue == "" ) )
+						{
+							pNode = pNode.previousSibling;
+						}
+
+						if ( pNode == null || !pNode.tagName || pNode.tagName.toLowerCase() != sNodeName || pNode.nodeValue != "" )
+						{
+							stringBuilder.push( basicElement[0] );
+						}
+
+					}
 
 					if ( !basicElement[2] )
 						this._AppendChildNodes( htmlNode, stringBuilder ) ;
 
 					if ( basicElement[1] )
-						stringBuilder.push( basicElement[1] ) ;
+					{
+						var nNode = htmlNode.nextSibling;
+
+						if ( nNode != null && nNode.nodeType == 3 && ( nNode.nodeValue == " " || nNode.nodeValue == "" ) )
+						{
+							nNode = nNode.previousSibling;
+						}
+
+						if ( nNode == null || !nNode.tagName || nNode.tagName.toLowerCase() != sNodeName || nNode.nodeValue != "" )
+						{
+							stringBuilder.push( basicElement[1] );
+						}
+
+					}
+
+					if ( this._appendSpace == true )
+					{
+						stringBuilder.push( " " );
+						this._appendSpace = false;
+					}
+
 				}
 				else
 				{
+					this._appendSpace = false;
 					switch ( sNodeName )
 					{
 						case 'ol' :
@@ -496,14 +532,30 @@
 					textValue = FCKTools.HTMLEncode( textValue ) ;
 					textValue = textValue.replace( /\u00A0/g, '&nbsp;' ) ;
 
-					if ( !htmlNode.previousSibling ||
-					( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace )
+					if ( textValue != "" && ( !htmlNode.previousSibling ||
+					( stringBuilder.length > 0 && stringBuilder[ stringBuilder.length - 1 ].EndsWith( '\n' ) ) && !this._inLSpace ) )
 					{
-						textValue = textValue.LTrim() ;
+						var newTextValue = textValue.LTrim() ;
+						if ( newTextValue != textValue ) 
+						{
+							var old = stringBuilder[ stringBuilder.length - 1 ];
+							stringBuilder[ stringBuilder.length - 1 ] = " ";
+							stringBuilder.push( old );
+						}
+
+						textValue = newTextValue;
 					}
 
 					if ( !htmlNode.nextSibling && !this._inLSpace )
-						textValue = textValue.RTrim() ;
+					{
+						var newTextValue = textValue.RTrim() ;
+						if ( newTextValue != textValue )
+						{
+							this._appendSpace = true;
+						}
+
+						textValue = newTextValue;
+					}
 
 					textValue = textValue.replace( / {2,}/g, ' ' ) ;
 
@@ -512,7 +564,7 @@
 					
 					if ( this._IsInsideCell )
 						textValue = textValue.replace( /\|/g, '&#124;' ) ;
-	
+
 				}
 				else 
 				{
