Remove line break after quote

Get help developing custom BBCodes or request one.
Post Reply
marc77
Registered User
Posts: 20
Joined: Sun Nov 02, 2008 12:02 pm

Remove line break after quote

Post by marc77 »

Hello,

I am runing a few forums with phpbb3.0. I know this version is depraced but the forums are high modified and will be updated in php etc. by myself.

For a couple of years now I noticed, that under a quote phpbb add line breaks. If you add a line break, it becomes a

<br><br>

$text = str_replace(array("\n", "\r"), array('<br />', "\n"), $text);

in the preview or viewtopic the double br is to much space and looks not good.

This user here describes exact the same problem:

viewtopic.php?f=74&t=2242416

But the phpbb users said, this is the normal behauvior. The user came up with a css solution BUT in newer phpbb versions this problem is fixed, so the phpbb developers understand the problem and fixed it. I compared the relelvant files like:

bbcode.php
function_content.php
message_parser.php
editor.js

I could not find, how the newer versions of phpbb fixed the new line breaks after the blockelements like blockquote or code.

Maybe anyone from here, could put me in the right direction?

Thank you very much.
User avatar
ViolaF
Registered User
Posts: 1558
Joined: Tue Aug 14, 2012 11:52 pm

Re: Remove line break after quote

Post by ViolaF »

marc77 wrote:
Fri Feb 19, 2021 12:49 pm
$text = str_replace(array("\n", "\r"), array('<br />', "\n"), $text);

in the preview or viewtopic the double br is to much space and looks not good.
Then instruct you user to do so:::
test
just text after quote
or
test

just text after quote

Code: Select all

[quote]test[/quote]
--- unneded linebreak ---
just text after quote*

Code: Select all

[quote]test[/quote]

just text after quote*
*but make an unneeded linebreak
User avatar
JoshyPHP
Code Contributor
Posts: 1213
Joined: Mon Jul 11, 2011 12:28 am

Re: Remove line break after quote

Post by JoshyPHP »

marc77 wrote:
Fri Feb 19, 2021 12:49 pm
Maybe anyone from here, could put me in the right direction?
Modern versions of phpBB use a library that I wrote for everything related to markup: https://github.com/s9e/TextFormatter

If you specifically describe what you're trying to achieve, I may be able to point you in the right direction. It's important that you describe what you're trying to achieve.
I wrote the thing that does BBCodes in 3.2+.
marc77
Registered User
Posts: 20
Joined: Sun Nov 02, 2008 12:02 pm

Re: Remove line break after quote

Post by marc77 »

Hello,

thank you very much for getting into. Its great to speak direclty to the developer. I appreciate it. I give my best to explain the problem.

The Person from here: viewtopic.php?f=74&t=2242416

described it very well if you read it carefully. I try it now again a bit more detailed. I am pretty sure you will understand it in that way.

In older versions of phpbb, two <br><br> will be added after blockelements. To explain the different scenarios I made a few screenshots.

1. Please see this 3 types of quote possibilies in the editor (textarea) view.

https://imgur.com/OePAioU

As you can see, under the first quote is one answer with one line break. The user expect in the posting view the same distance.

2. Now please have a look at this image where you can see the posting view:

https://imgur.com/a/PCCItcC

The distance between the the answer and the first quote is too big. Please keep in mind, that the blockquote element has NO margin-bottom.

3. The reason why the first distance is so big is, that under the blockquote are two <br><br>. I know, this is normal because if the cursor is direclty behind the closing [/quote] and you press 2 times return for a line break, this 2 line breaks becomes 2 <br><br>

See this image from the chrome developer:

https://imgur.com/a/e2urxiq

4. In newer versions of phpbb this seems to be fixed, because the exact same bbcode quoting, becomes this:

https://imgur.com/a/Lifj4wm

As you can see, there is NO br anymore. All 3 quoting scenarios have the same distance to the quote, because you remove the br after the blockelements.

In that way you can add a margin-bottom to the blockquote and the problem is fixed. What is perfect. So you did a very nice job but how to adapt this to an older version? Maybe there is a quick regex or something like that?

So basicly what I am trying to achieve is, how to get rid of the br´s after the blockquotes.

Thank you very much JoshyPHP.

Regards
Marc
User avatar
JoshyPHP
Code Contributor
Posts: 1213
Joined: Mon Jul 11, 2011 12:28 am

Re: Remove line break after quote

Post by JoshyPHP »

So you want to modify phpBB 3.0 to make it behave more like phpBB 3.3? I don't know about those older versions so that's something you should post in the phpBB Custom Coding forum.

Realistically, you should rather look for an upgrade path towards a supported version of phpBB before you become unable to find a version of PHP that can run phpBB 3.0.
I wrote the thing that does BBCodes in 3.2+.
marc77
Registered User
Posts: 20
Joined: Sun Nov 02, 2008 12:02 pm

Re: Remove line break after quote

Post by marc77 »

Realistically, you should rather look for an upgrade path towards a supported version of phpBB before you become unable to find a version of PHP that can run phpBB 3.0.
I am running huge forums with nice mods and big communities. way ahead of the actual phpbb3.3. My forums run with php8.
So you want to modify phpBB 3.0 to make it behave more like phpBB 3.3?
well, modify is too much. I just want to know how you removed the 2 linebreaks under the blockquote. There must be a preg replace anywhere? Could you please tell me how to remove them? It should be one single line.
Paul
Infrastructure Team Leader
Infrastructure Team Leader
Posts: 27163
Joined: Sat Dec 04, 2004 3:44 pm
Location: The netherlands.
Name: Paul Sohier
Contact:

Re: Remove line break after quote

Post by Paul »

Support for phpBB versions earlier than 3.2.0 has ended. Any support requests regarding those versions are limited to help with conversion to the latest version.
User avatar
JoshyPHP
Code Contributor
Posts: 1213
Joined: Mon Jul 11, 2011 12:28 am

Re: Remove line break after quote

Post by JoshyPHP »

marc77 wrote:
Wed Feb 24, 2021 8:03 am
There must be a preg replace anywhere?
No, it doesn't work like that. There's nothing in modern versions of phpBB that will help you maintain your custom version.
I wrote the thing that does BBCodes in 3.2+.
Post Reply

Return to “Custom BBCode Development and Requests”