Opened 16 years ago

Closed 16 years ago

#1785 closed Bug (fixed)

New lines and extra whitespaces removed inside a <pre> tag

Reported by: Laurentiu SOICA Owned by: Wiktor Walc
Priority: Normal Milestone:
Component: Project : MediaWiki+FCKeditor Version:
Keywords: Confirmed Cc:

Description

Inside a "formatted" block (pre tag), if i paste the following code

First line with no whitespaces 
  Second line starting with two whitespaces

Fourth line   with three whitespaces after word "line"

and save the article:

  1. the two whitespaces in the beginning of the second line are removed
  1. the third line is removed
  1. The two extra whitespaces after the word line in the fourth line are removed

more than that, if i reopen the article and try to split the first line in two new lines, "First line with no" and "whitespaces", and then i save the article, the new line is simply skipped (i'll still have a single line "First line with no whitespaces")

You can reproduce it on the sandbox.

Change History (26)

comment:1 Changed 16 years ago by Wojciech Olchawa

Component: GeneralProject : MediaWiki+FCKeditor

I tried to reproduce your bug both in Internet Explorer and Firefox in the sandbox of the wiki-site. In IE everything seems to be OK and the lines don't break while saving. The extra white spaces don't disappear as well. In FF I was able to reproduce this bug partially. I only managed to notice that in the second line: {{{First line with no whitespaces

Second line starting with two whitespaces

Fourth line with three whitespaces after word "line"}}}

the white spaces disappear and turn the text to this

First line with no whitespaces 
Second line starting with two whitespaces

Fourth line   with three whitespaces after word "line"

So could you please write what kind of browser do you use? Than it would be easier for us to reproduce your bug and start to work on it.

comment:2 Changed 16 years ago by Wojciech Olchawa

sorry about the code example: again the white spaces disappear so I only noticed that it changes from this:

First line with no whitespaces 
  Second line starting with two whitespaces

Fourth line   with three whitespaces after word "line"

to this

First line with no whitespaces 
Second line starting with two whitespaces

Fourth line   with three whitespaces after word "line"

comment:3 Changed 16 years ago by Wojciech Olchawa

Keywords: Pending added

comment:4 Changed 16 years ago by Laurentiu SOICA

Hello,

In a first place i want to be sure i am using the right sandbox. I am using this one http://mediawiki.fckeditor.net/index.php/Sandbox so if it is not ok please provide me a link to the right one.

Now, on Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11 , the result is this :

First line with no whitespaces 
Second line starting with two whitespaces
Fourth line with three whitespaces after word "line"

and on IE 7.0.5730.13 the result is this :

First line with no whitespaces 
Second line starting with two whitespaces
Fourth line with three whitespaces after word "line"

comment:5 Changed 16 years ago by Wojciech Olchawa

Yes, you are using a good sandbox. I've edited th page http://mediawiki.fckeditor.net/index.php/Sandbox as you did as well. Both in IE7 and in FF. I'm using the same Firefox version and IE in another version 7.0.6000.16575 but the results should be similar. Take a look at the above link and view the examples. I labeled them test1 and test2. Of course I can confirm that the editor cuts the additional whitespaces (in IE and in FF) and that two whitespaces are cut from the beginning of a new line (in FF only). So could you be so kind and check again. Thx

comment:6 Changed 16 years ago by Laurentiu SOICA

Hi,

Seems that we are not getting exactly the same results. I've created a dedicated page on the sandbox for this ticket http://mediawiki.fckeditor.net/index.php/Ticket_1785 where you can see the outputs of my browsers.

You'll see that by pasting the text, in both browser, on my side the empty line is removed. Writing it by hand is a totally different result.

Just to let you know, i didn't altered my environment in any way regarding the browsers, for development or other requirements, so the results i'm getting should be the one of a "from scratch" install.

Thanks

comment:7 Changed 16 years ago by Wojciech Olchawa

Keywords: Confirmed added; Pending removed

Hi again, We didn't have the same results because I've edited the page in WikiText and You did it in normal view, so my mistake obviously. The bug is very annoying so we will try to work it out some how. Thanks for the examples.

comment:8 Changed 16 years ago by Wojciech Olchawa

#1802 has been marked as DUP

comment:9 Changed 16 years ago by lutzclem

Hi,

I'm having the same problem (cutting whitespaces and disregarding newlines) using MediaWiki 1.11.1 / latest build of FCKeditor (as of 2008-02-25) / Firefox v.2.0.0.12 .

Has there been any progress in solving this bug since the last post?

Also, when pasting / entering number signs (#), they get previewed and saved as ones:

#####
turns into this:
1.    1.    1.    1.

This is reproducible in the Sandbox. Shall I open a new bugreport for this?

comment:10 Changed 16 years ago by lutzclem

Update: both issues still persist with the newest nightly build of mediawiki.fckeditor.net as of 2008-03-07. As described in my last post, I still can make them appear in both my local install and the sandbox.

comment:11 Changed 16 years ago by SJB

This ticket seems to have handled a similar problem for the base FCKeditor

http://dev.fckeditor.net/ticket/328

It appears to me that the mediawiki plugin just needs to be modified in a similar manner. Perhaps.

comment:12 Changed 16 years ago by lutzclem

mertam, thanks for your reply.

That bugfix is a year old and I suppose it's in the main tree. Upon your answer I checked if my problem is solved in the demo. It's not. If you select "formatted text", FCKeditor does not appear to insert any linebreaks in it's output.

I would like to correct myself on the number sign issue: MediaWiki interprets # as an ordered list. To avoid that, a space has to be inserted after the newline.

comment:13 Changed 16 years ago by SJB

I hacked my code in fckplugin.js to somewhat solve this problem. I think it is ugly, but it works for me on IE and Firefox.

case 'pre' :
        var attribs = this._GetAttributesStr( htmlNode ) ;
        
        if ( htmlNode.className == "_fck_mw_lspace")
        {
		.
		.
		.
        }
        else
        {
                stringBuilder.push( '<' ) ;
                stringBuilder.push( sNodeName ) ;

                if ( attribs.length > 0 )
                        stringBuilder.push( attribs ) ;

                stringBuilder.push( '>' ) ;
                this._inPre = true ;
                
                if ( FCKBrowserInfo.IsIE ) {
                       stringBuilder.push( htmlNode.innerText );
                } else {
                       var insertText = htmlNode.innerHTML ;     
                       insertText = insertText.replace( /\<br\>/g, '\n' );^M  
                       stringBuilder.push( insertText ) ;
                };

                this._inPre = false ;
                stringBuilder.push( '<\/' ) ;
                stringBuilder.push( sNodeName ) ;
                stringBuilder.push( '>' ) ;             
        }

I think the real problem is that the _inPre property is not functioning as anticipated in the _AppendChildNodes and _AppendNode functions. Therefore, I completely avoid these functions for pre tags.

comment:14 Changed 16 years ago by lutzclem

mertam,

thank you for your effort. I changed fckplugin.js to include your fix. For me it works in IE6, but not in Firefox-2.0.0.12. The behavior in FF is the same as in the unpatched version.

Nevertheless I made a patch for easier handling of the code and to make the changes a bit more clear:

diff -Naur FCKeditor_backup/plugins/mediawiki/fckplugin.js FCKeditor/plugins/mediawiki/fckplugin.js
--- FCKeditor_backup/plugins/mediawiki/fckplugin.js     2008-02-29 09:35:10.000000000 +0000
+++ FCKeditor/plugins/mediawiki/fckplugin.js    2008-03-13 07:26:10.000000000 +0000
@@ -456,7 +456,15 @@

                                                                stringBuilder.push( '>' ) ;
                                                                this._inPre = true ;
-                                                               this._AppendChildNodes( htmlNode, stringBuilder ) ;
+
+                                                               if ( FCKBrowserInfo.IsIE ) {
+                                                                       stringBuilder.push( htmlNode.innerText );
+                                                               } else {
+                                                                       var insertText = htmlNode.innerHTML;
+                                                                       insertText = insertText.replace( /\<br\>/g, '\n' );
+                                                                       stringBuilder.push( insertText );
+                                                               };
+
                                                                this._inPre = false ;
                                                                stringBuilder.push( '<\/' ) ;
                                                                stringBuilder.push( sNodeName ) ;
@@ -691,4 +699,4 @@
                        }
                }
        }
-}) ;
\ No newline at end of file
+}) ;

comment:15 Changed 16 years ago by lutzclem

After some more testing and playing around with the patch, the bug is also fixed in Firefox.

Sometimes the editor inserts seemingly random junk like spaces, breaks and HTML tags into the text. Also, sometimes newly inserted text just disappears after the first save, but when you edit the page again, it's there.

I am not certain if this behavior is caused by the patch or not, however.

comment:16 Changed 16 years ago by Wiktor Walc

Resolution: fixed
Status: newclosed

Fixed with [1868].

comment:17 Changed 16 years ago by lutzclem

Resolution: fixed
Status: closedreopened

wwalc,

When pasting text into a <pre> box, everything works just fine for both IE6 and Firefox.

However, when typing in text manually changeset 1868 works only in IE6. Firefox 2.0.0.13 and 1.5.0.12 both insert a space where there should be a newline.

comment:18 Changed 16 years ago by Wojciech Olchawa

Keywords: Pending WorksForMe added; Confirmed removed

I've updated to the latest SVN and it works fine to me.

comment:19 Changed 16 years ago by Wiktor Walc

Keywords: Confirmed added; Pending WorksForMe removed
Owner: set to Wiktor Walc
Status: reopenednew

comment:20 Changed 16 years ago by Wiktor Walc

lutzclem: could you check now? ([1882]).

comment:21 Changed 16 years ago by lutzclem

Changeset 1882 works for me in all the previously listed browsers, but in all three it inserts an extra newline at the bottom of the <pre> block after every edit.

comment:22 Changed 16 years ago by Wiktor Walc

I've cleared my cache and tried to reproduce "inserting an extra newline at the bottom of the <pre> block" here: http://mediawiki.fckeditor.net/index.php/Ticket_1785

As you see it seems to work... could you let me know what should I do to observe this issue?

comment:23 Changed 16 years ago by lutzclem

Strange, in the sandbox it works for me, in my local MediaWiki with the latest nightly build of FCKeditor as of right now I have the described issue. Is the patch already included in the nightly build? Yesterday I replaced fckplugin.js with the one you linked to and I had the same issue as today. What version/build is the sandbox using?

Anyway, I guess you can close this ticket now as it seems fine in the sandbox. Sorry for causing you so much trouble and thank you wwalc, w.olchawa and mertam for your time, effort and of course the bugfix.

Best regards, lutzclem

comment:24 Changed 16 years ago by Wiktor Walc

Resolution: fixed
Status: newclosed

comment:25 Changed 16 years ago by www.hostmaster

Resolution: fixed
Status: closedreopened

see http://mediawiki.fckeditor.net/index.php/Ticket_1785#Extra_line_after_formatted_Text_without_.3Cpre.3E

There is still a problem with formatted text, where a line starts with a space.

(mk)

comment:26 Changed 16 years ago by Wiktor Walc

Resolution: fixed
Status: reopenedclosed

Additional fixes: [2087] and [2088].

Another example useful for future tests:

Normal text

 some text starting with a space
 line with a space 2
 line with a space 3
 line with a space 4
 line with a space 5
 another line with a space, note a couple of new lines starting with 
 a space at the end this sample
 
 
 
And now back to normal text.

During tests press shift+enter between line 3 and line 4 in wysiwyg mode, switch to wikitext and back.

I'm closing this ticket hoping that it is fixed, but please feel free to reopen if you find anything that is still broken.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy