Say you're trying to copy / paste some code written to confirm to a certain coding standard that uses tabs to indent. With the current [ code] tag, each tab gets converted to spaces, so you'll have to do some post-processing on the text that you get back to make it be formatted correctly.
Also, in Firefox, if you hit the "Select all" link, there are four spaces pre-pended to each line in the text.
The following seems sufficient to fix it (and also serves as a demonstration of the problem since it's in a [ code] tag):
- Code: Select all
#
#-----[ OPEN ]------------------------------------------
#
styles/prosilver/template/bbcode.html
#
#-----[ FIND ]------------------------------------------
#
<!-- BEGIN code_open --><dl class="codebox"><dt>{L_CODE}: <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></dt><dd><code><!-- END code_open -->
<!-- BEGIN code_close --></code></dd></dl><!-- END code_close -->
#
#-----[ REPLACE WITH ]----------------------------------
#
<!-- BEGIN code_open --><dl class="codebox"><dt>{L_CODE}: <a href="#" onclick="selectCode(this); return false;">{L_SELECT_ALL_CODE}</a></dt><dd><code><pre><!-- END code_open -->
<!-- BEGIN code_close --></pre></code></dd></dl><!-- END code_close -->
#
#-----[ OPEN ]------------------------------------------
#
styles/prosilver/template/forum_fn.js
#
#-----[ FIND ]------------------------------------------
#
var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
#
#-----[ REPLACE WITH ]----------------------------------
#
var e = a.parentNode.parentNode.getElementsByTagName('PRE')[0];
#
#-----[ OPEN ]------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]------------------------------------------
#
switch ($type)
{
case 'php':
// Not the english way, but valid because of hardcoded syntax highlighting
if (strpos($code, '<span class="syntaxdefault"><br /></span>') === 0)
{
$code = substr($code, 41);
}
// no break;
default:
$code = str_replace("\t", ' ', $code);
$code = str_replace(' ', ' ', $code);
$code = str_replace(' ', ' ', $code);
// remove newline at the beginning
if (!empty($code) && $code[0] == "\n")
{
$code = substr($code, 1);
}
break;
}
#
#-----[ REPLACE WITH ]----------------------------------
#
if ($type == 'php' && strpos($code, '<span class="syntaxdefault"><br /></span>') === 0)
{
$code = substr($code, 41);
}
By using the <pre> html tag, I eliminate the need to convert white space over with nbsp and the regular sp. This also seems to eliminate the whole four spaces pre-pended issue in Firefox.