Automatically remove line breaks

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Get Involved
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
Locked
silas3
Registered User
Posts: 13
Joined: Mon Dec 20, 2010 10:57 am

Automatically remove line breaks

Post by silas3 » Mon Dec 20, 2010 8:27 pm

If I start a new post with line breaks, the line breaks will be autamatically removed (after submit).

If I quote a post, and make for example 10 line breaks between the quote and my post, the 10 line breaks does appear.

Which script code must be changed for removing the line breaks between the quote and the post automatically? (only 1 line break is ok)

User avatar
AmigoJack
Registered User
Posts: 5332
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Automatically remove line breaks

Post by AmigoJack » Tue Dec 21, 2010 7:06 am

silas3 wrote:(only 1 line break is ok)
Are you sure? Because that would mean you have no chance to post blank lines (like you just did in your post), because those need at least 2 linebreaks.
The worst thing about censorship is ███████████

silas3
Registered User
Posts: 13
Joined: Mon Dec 20, 2010 10:57 am

Re: Automatically remove line breaks

Post by silas3 » Tue Dec 21, 2010 9:57 am

Only the line breaks between the quote and the post should be automatically removed.

For example:
That`s the quote.
line break 1
line break 2
line break 3
line break 4
line break 5

That`s my post - part 1.
line break 6.
That`s my post - part 2.

The script should remove line break 2, 3, 4 and 5, but NOT the line break 6.

User avatar
AmigoJack
Registered User
Posts: 5332
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Automatically remove line breaks

Post by AmigoJack » Tue Dec 21, 2010 10:32 am

Open /includes/message_parser.php and find:

Code: Select all

            'quote'            => array('bbcode_id' => 0,    'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")), 
Replace with:

Code: Select all

            'quote'            => array('bbcode_id' => 0,    'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\][\n\r\x0C]*#ise' => "\$this->bbcode_quote('\$0')")), 
This will only affect new posts (but has the advantage to not modify every post upon display again).
The worst thing about censorship is ███████████

silas3
Registered User
Posts: 13
Joined: Mon Dec 20, 2010 10:57 am

Re: Automatically remove line breaks

Post by silas3 » Tue Dec 21, 2010 3:00 pm

Hello AmigoJack,
it does work excellent. You did a great job. Many many thanks!!!

User avatar
SwordCoastPL
Registered User
Posts: 5
Joined: Tue Sep 29, 2015 10:23 pm
Contact:

Re: Automatically remove line breaks

Post by SwordCoastPL » Fri Nov 20, 2015 11:16 pm

AmigoJack wrote:Open /includes/message_parser.php and find:

Code: Select all

            'quote'            => array('bbcode_id' => 0,    'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\]#ise' => "\$this->bbcode_quote('\$0')")),
Replace with:

Code: Select all

            'quote'            => array('bbcode_id' => 0,    'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\][\n\r\x0C]*#ise' => "\$this->bbcode_quote('\$0')")),
This will only affect new posts (but has the advantage to not modify every post upon display again).
Hello. Sorry for digging up old post, but I need it.
Overall, great, it works! Strips all the lines. But only for last quote in the post for some reason.

The code in PhPBB3.1 is:

Code: Select all

			'quote'			=> array('bbcode_id' => 0,	'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\][\n\r\x0C]*#uise' => "\$this->bbcode_quote('\$0')")),
And I edited it to:

Code: Select all

			'quote'			=> array('bbcode_id' => 0,	'regexp' => array('#\[quote(?:="(.*?)")?\](.+)\[/quote\][\n\r\x0C]*#uise' => "\$this->bbcode_quote('\$0')")),
How to make it work for every quote in post?
Polski Portal Sword Coast Legends: www.swordcoast.pl
Polskie Forum Sword Coast Legends: forum.swordcoast.pl
Facebook: https://www.facebook.com/SwordCoastPL
Twitter: https://twitter.com/SwordCoastPL

You must gather your party before venturing forth.

User avatar
AmigoJack
Registered User
Posts: 5332
Joined: Tue Jun 15, 2010 11:33 am
Location: グリーン ヒル ゾーン
Contact:

Re: Automatically remove line breaks

Post by AmigoJack » Mon Nov 23, 2015 2:29 pm

It probably never worked for multiple quotes in the first way. You also have to find:

Code: Select all

                    // we have found a closing tag
                    $out .= array_pop($close_tags) . ']';
                    $tok = '[';
                    $buffer = '';
 After, add: 

Code: Select all

                    /*** 2015-11-23 BEGIN AmigoJack
                        https://www.phpbb.com/community/viewtopic.php?f=46&t=2114631 ***/
                    $in= preg_replace( '#^[\\n\\r\\x0C]+#', '', $in );
                    /*** 2015-11-23 END ***/ 
Tested with 3.1.6 (but should work the same way in 3.0).
The worst thing about censorship is ███████████

corleoner
Registered User
Posts: 189
Joined: Wed Jan 29, 2014 9:57 pm

Re: Automatically remove line breaks

Post by corleoner » Wed Jul 06, 2016 3:53 pm

AmigoJack wrote:It probably never worked for multiple quotes in the first way. You also have to find:

Code: Select all

                    // we have found a closing tag
                    $out .= array_pop($close_tags) . ']';
                    $tok = '[';
                    $buffer = '';
 After, add: 

Code: Select all

                    /*** 2015-11-23 BEGIN AmigoJack
                        https://www.phpbb.com/community/viewtopic.php?f=46&t=2114631 ***/
                    $in= preg_replace( '#^[\\n\\r\\x0C]+#', '', $in );
                    /*** 2015-11-23 END ***/ 
Tested with 3.1.6 (but should work the same way in 3.0).
Tested on 3.0.14 and works like a champ! Thanks for this, the extra space from quotes was causing a gap that was larger than necessary.

Locked

Return to “[3.0.x] Support Forum”

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], oBot and 55 guests