miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | Manual |
Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /  
 

Trimming paragraphs: may the space after the paragraph be ignored?

 
Author Ivan
Advanced Member
#1 | Posted: 18 Jul 2006 17:07 
I offten copy text with short lines from other pages, poetry for example, and publish it. It often contains a space at the end of each line, before the paragraph (new line), which spaces I "transport" to my message and it's very boring to remove them one by one before posting :) Other posters do the same.

In other cases by some bad habit people hit the space before hitting the enter for paragraph (new line). I don't know why.

In third cases third people begin the new paragraph with space. I don't know why.

In all the above cases before or after the invisible sign for paragraph (new line) there are empty spaces, which could be many in some posts. So, my question is:

Could we have something like str_replace to reduce before posting:

Paragraph+Space -> Paragraph
Space+Paragraph -> Paragraph

Author Anonymous
Guest
#2 | Posted: 18 Jul 2006 18:40 
Ivan
you can use notpad and Replace " " to " " (2 space with 1 space) ;-)

Author Paul
Lead Developer 
#3 | Posted: 18 Jul 2006 19:21 
I didn't get the problem. How these spaces affect the look of the messages?

I've posted the sentence above with spaces at the beginning at the end, but script automatically removes it...?

Author Ivan
Advanced Member
#4 | Posted: 18 Jul 2006 20:09 
I'll try, too:

Child In Time

Sweet child in time you'll see the line
The line that's drawn between the good and the bad
See the blind man shooting at the world
Bullets flying taking toll
If you've been bad, Lord, I bet you have
And you've been hit by flying lead
You'd better close your eyes and bow your head
And wait for the ricochet

Author Ivan
Advanced Member
#5 | Posted: 18 Jul 2006 20:21 
I tried with spaces at the beginning and at the end. Yes, in the posted text outside there aren't spaces, but inside they remain. Please, look in my post. Omly the last end space is removed during posting.

Also, when you copy the text for posting it somewhere, the spaces at the end are copied, too, and respectively pasted.

Not a big problem, but it will be better to be removed automatically.

Author Paul
Lead Developer 
#6 | Posted: 19 Jul 2006 07:23 
So, that's all is clear now, but I still understand, how spaces affect the look of your messages? I think, they are displayed in a browser like there are no spaces.

Anyway try to insert the code below in bb_plugins.php and this might help you:

/* Removing paragraph spaces */
if(($action=='ptopic' or $action=='pthread' or $action=='editmsg2') and isset($_POST['postText'])){
$pp=explode("\n", $_POST['postText']);
for($i=0;$i<sizeof($pp)-1;$i++) $pp[$i]=trim($pp[$i]);
$_POST['postText']=implode("\n", $pp);
}
/* --Removing paragraph spaces */

Our default script trims the spaces from the beginning and the end of the text, nothing more.

Author Ivan
Advanced Member
#7 | Posted: 19 Jul 2006 08:07 
The matter is that I often use already posted texts for other pages. And every time I copy the respective text, in the web page the intervals appear. Than I say: "Ooo, you're not smarter than me! I'll get the text from inside the post!" Well, I enter inside the post but - surprise :) The intervals are there, too :)))

Thank you very much for the code and have a good day! I suppose it contains both cases: Paragraph+Space and Space+Paragraph, right?

Author Paul
Lead Developer 
#8 | Posted: 19 Jul 2006 08:28 
Yes, both cases.

Author Ivan
Advanced Member
#9 | Posted: 19 Jul 2006 09:28 
Thanks again :)

Custom Tutorials and Modifications miniBB Support Forums / Custom Tutorials and Modifications /
 Trimming paragraphs: may the space after the paragraph be ignored?
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Try the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑