Is it possible to exclude <pre>
tags from this code igniter compression hook? I don't understand regular expressions well enough to not break my page. I have tried, but it always jacks up the output.
EDIT: This CodeIgniter Compression hook strips all unecisary white space and formatting from the code in order to compress the output. Including <pre>
tags that rely on that spacing and formatting to display the code right.
I'm trying to show code examples in a compressed output page.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function compress()
{
$CI =& get_instance();
$buffer = $CI->output->get_output();
$search = array(
'/\n/',
'/\>[^\S ]+/s',
'/[^\S ]+\</s',
'/(\s)+/s'
);
$replace = array(
' ',
'>',
'<',
'\\1'
);
$buffer = preg_replace($search, $replace, $buffer);
$CI->output->set_output($buffer);
$CI->output->_display();
}
?>