Test Me Board Archive
[Bug fix] pre tags in posts --Testing
· Previous · Next View Thread Index
By Tarty Date 2005-12-13 18:58


I've been thinking of doing this one for a long time. I consider it a bug fix. Right now, if <pre> tag is in a post, the html of the message will be like:

<br /><pre>  
<br>unless ($FORM{$entry} =~ /&lt;pre&gt;/i) {  
<br>	$FORM{$entry} =~ s/\s+/ /g;  
<br>	$FORM{$entry} =~ s/&lt;BR&gt;\s/&lt;BR&gt;/g;  
<br>} </pre>

The <br>s are NOT supposed to be in there. When viewed in FF, for eg, the code in the message will be shown in double line spacing, which is bad in particular for boards that use <pre> a lot for showing coding.

The fix is easy. Edit webbbs_post.pl.
Find and add the stuff shown in red below:
 
unless ($FORM{$entry} =~ /<pre>/i) { 
	$FORM{$entry} =~ s/<BR>\s\s\s+/<BR><BR>/g; 
	$FORM{$entry} =~ s/<BR>\t/<BR><BR>/g; 
	$FORM{$entry} =~ s/\s+/ /g; 
	$FORM{$entry} =~ s/<BR>\s/<BR>/g; 
	$FORM{$entry} =~ s/\s<BR>/<BR>/g; 
	$FORM{$entry} =~ s/<BR><BR>/<P>/g; 
	$FORM{$entry} =~ s/<P><BR>/<P>/g; 
	unless ($SingleLineBreaks) { 
		$FORM{$entry} =~ s/<BR>$AutoQuoteChar/<BRR>/g; 
		$FORM{$entry} =~ s/<BR>&gt;/<BRR>/g; 
		$FORM{$entry} =~ s/<BR>>/<BRR>/g; 
		$FORM{$entry} =~ s/<BR>/ /g; 
		$FORM{$entry} =~ s/<BRR>/<BR>$AutoQuoteChar/g; 
	} 
} 
# 2005-12-13 fixed: remove <br> within <pre> & </pre> 
if ($FORM{$entry} =~ /<pre>/i) { 
	$FORM{$entry} =~ s/<P>/\n<P>/g; 
	$FORM{$entry} =~ s/<BR>/\n<BR>/g; 
	my @bodytext = split(/\n/,$FORM{$entry}); 
	my ($preopen, $thisbody); 
	foreach (@bodytext) { 
		if ($preopen) { $_ =~ s/<BR>/\n/g; } 
		if ($_ =~ /<pre>/i) { $preopen = 1; } 
		if ($_ =~ /<\/pre>/i) { $preopen = 0; } 
		$thisbody .= "$_"; 
	}  
	$FORM{$entry} = $thisbody; 
}
Done.

Yes, done. It's that easy. After the fix, the html will be like:
<br /><pre>  
unless ($FORM{$entry} =~ /&lt;pre&gt;/i) {  
	$FORM{$entry} =~ s/\s+/ /g;  
	$FORM{$entry} =~ s/&lt;BR&gt;\s/&lt;BR&gt;/g;  
}</pre>
No double line spacing.

Have yet to test see how this bug fix and $AutoQuote get along...  :)
Reply View All
Messages In This Thread
[Bug fix] pre tags in posts --Testing
Tarty -- 2005-12-13 18:58
Re: [Bug fix] pre tags in posts --Testing
Tarty -- 2005-12-13 19:06
Re: [Bug fix] pre tags in posts --Testing
Tarty -- 2005-12-13 22:32
· Previous · Next View Thread Index

Test Me Board Archive is maintained by Administrator
Powered by tee-WebBBS 0.52x 080701 © 2008 Tarty

0 wallclock secs ( 0.02 usr + 0.01 sys = 0.03 CPU)