Firefox inserting extra blank line between paragraphs

Discussion of bugs in Mozilla Firefox
RRB13
Posts: 1
Joined: April 18th, 2020, 5:56 am

Re: Firefox inserting extra blank line between paragraphs

Post by RRB13 »

DSperber wrote:Well, recently there is an EXTRA BLANK LINE now visible between the two paragraphs!
Well hang tight DSperber, because I've managed to fix this.


There's 2 ways to do it:

For Yourself : in your browser
(credit to this thread!)

1) Type about:config into the Firefox url bar
2) Type editor.use_div_for_default_newlines into the search box on the page
3) Hit the [<>] toggle button on the right to switch the value to False

Above steps illustrated below:
Image


For Everyone : On the server code

At least on vBulletin 3.6, the file is located at /forum/includes/functions_wysiwyg.php

Somewhere around line 140, you'll see the following:

Code: Select all

	// deal with newline characters
	if (is_browser('mozilla'))
	{
		$text = preg_replace('#(?<!<br>|<br />|\r)(\r\n|\n|\r)#', ' ', $text);
	}
Just add in the additional/last line shown here:

Code: Select all

	// deal with newline characters
	if (is_browser('mozilla'))
	{
		$text = preg_replace('#(?<!<br>|<br />|\r)(\r\n|\n|\r)#', ' ', $text);
		$text = preg_replace('#<br>#', '', $text);
	}
That should fix it!! And hopefully not break anything else, since this is only for 'mozilla' browsers.


Also, here's a bit of an answer as to WHY this is happening.

As you know, Mozilla seems to do the following:
Single line break: It just wraps the preceeding and following lines in < div > tag.
Double line breaks: In addition to the above, it creates a < div > < br > </ div> in between them

When the forum editor's WYSIWYG code parses this, it switches out the DIVS for BRs, and since there's that extra div with a br in it -- you get too many!

Here's what it looks like if you inspect it with WYSIWYG turned ON. Obviously once it's submitted the html gets switched out, and divs and brs become \n:
Image
User avatar
DanRaisch
Moderator
Posts: 127249
Joined: September 23rd, 2004, 8:57 pm
Location: Somewhere on the right coast

Re: Firefox inserting extra blank line between paragraphs

Post by DanRaisch »

Thank you for the detailed information but it's doubtful the OP was still waiting for the answer after two years. Locking due to the age of the original post.
Locked