Improved CODE Boxes
2.1a for SP1.3-SP1.3.2
This mod limits the height of the code boxs which are used by the [code] tag and adds scrollbars if necessary. It also displays linebreaks and tabs properly, the code text is no longer wrapped if a line is too long. Instead a scrollbar is used.
This will improve the readability of the code boxes and long threads.
THIS MOD IS COMPATILE WITH SP1.3-SP1.3.2
If you're looking for an example, check out forum.boardmod.org
Version History:
v2.1a: - made compatible with SP1.3.2
v2.1: - fixed turning into normal space when using the preview button (note: this bug has nothing todo with this mod, it's a general yabb bug)
v2.0: - completely rewritten, now supports all browsers, now IE will no longer wrap long lines too
- fixed display of characters (not only inside [code] tags!)
v1.1: - use white-space:wrap for Safari
- removed modification of language file, no longer needed ;-)
v1.0: - initial release
Michael Prager
http://www.boardmod.org
Sources/YaBBC.pl
$_ = $txt{'706'};
# count lines in code
$linecount = () = $code =~ /\n/g;
# if more that 25 lines then limit code box height
if ($linecount > 25) {
$height = "height: 480px;";
} else {
$height = "";
}
# try to display text as it was originally intended
$code =~ s~ \ \ \ ~\t~ig;
$code =~ s~\ ~ ~ig;
$code =~ s~ ?\n ?~\[code_br\]~ig; # we need to keep normal linebreaks inside tag
$code = qq~$code\[code_br\][code_br\]
~;
$message =~ s~\n~
~ig;
$message =~ s~\[code_br\]~\n~ig;
english.lng
$txt{'706'} = qq~Code:~;
$txt{'706'} = qq~Code:CODE~;
Sources/Subs.pl
$message =~ s~ ~\t~g;
$message =~ s~ ~\[tab\]~ig;
$message =~ s~\t~ ~g;
$message =~ s~\[tab\]~ ~ig;
Sources/ModifyMessage.pl
$message =~ s/
/\n/ig;
$message =~ s/ \ \ \ /\t/ig;
Sources/Post.pl
$message =~ s~
~\n~g;
$message =~ s/ \ \ \ /\t/ig;
$message = $mess;
&ToHTML($message);