Quote:
Originally Posted by blueuniverse
The full one at the beginning. What I want really is just a lite version, which strips all the tags but won't affect the formatting in the post.
|
Originally I offered the hack in two parts... a full aggressive version and a lite version.
The hack was then modified by some users to run both parts according to which php file was being run... and this is a good idea so I changed the hack to reflect these modifications.
If you want just a lite version then the code is still there, just take out the bits that the aggressive version and the switch would need.
What this means is that where I now have this in the hack:
PHP Code:
// HACK : START : COMPRESS
$thisscriptis = array(
'editpost',
'register',
'newreply',
'newthread',
'sendmessage',
'private',
);
if (!in_array(THIS_SCRIPT, $thisscriptis)) {
$patterns = array('/\>\s+\</', '/^\s*/m');
$replace = array('> <', '');
$vartext = preg_replace($patterns, $replace, $vartext);
} else {
$vartext = preg_replace('/\>\s+\</', '> <', $vartext);
}
// HACK : END : COMPRESS
You only need this to have a lite version:
PHP Code:
// HACK : START : COMPRESS
$vartext = preg_replace('/\>\s+\</', '> <', $vartext);
// HACK : END : COMPRESS
Note that we still recognised one scenario where this would be annoying... and that is when your forum is one where people are likely to post HTML or XML within their posts within PRE tags... as the formatting of that would also be changed.
So in that scenario the recommendation was that you don't run this hack... as it is designed to remove whitespace and that means that it re-formats HTML, XHTML, XML style text.
Anyhow... hope that helps.