irm-1.6-b3/lib/Savant2/Savant2_Filter_trimwhitespace.php
/**
	* 
	* Removes extra white space within the text.
	* 
	* Trim leading white space and blank lines from template source after it
	* gets interpreted, cleaning up code and saving bandwidth. Does not
	* affect <PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
	* 
	* @access public
	* 
	* @param string &$source The source text to be filtered.
	*
	*/
Removes extra white space within the text.

Trim leading white space and blank lines from template source after it
gets interpreted, cleaning up code and saving bandwidth. Does not
affect > and  blocks.

@access public

@param string &$source The source text to be filtered.
Removes extra white space within the text . Trim leading white space and blank lines from template source after it gets interpreted cleaning up code and saving bandwidth . Does not affect > and blocks . @access public @param string &$source The source text to be filtered .
function filter(&$source)
	{
		preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
		$_script_blocks = $match[0];
		$source = preg_replace("!<script[^>]+>.*?</script>!is",
		'@@@SAVANT:TRIM:SCRIPT@@@', $source);
		preg_match_all("!<pre[^>]+>.*?</pre>!is", $source, $match);
		$_pre_blocks = $match[0];
		$source = preg_replace("!<pre[^>]+>.*?</pre>!is",
		'@@@SAVANT:TRIM:PRE@@@', $source);
		preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
		$_textarea_blocks = $match[0];
		$source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
		'@@@SAVANT:TRIM:TEXTAREA@@@', $source);
			$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
		Savant2_Filter_trimwhitespace::_replace(
			"@@@SAVANT:TRIM:SCRIPT@@@",$_script_blocks, $source);
		Savant2_Filter_trimwhitespace::_replace(
			"@@@SAVANT:TRIM:PRE@@@",$_pre_blocks, $source);
		Savant2_Filter_trimwhitespace::_replace(
			"@@@SAVANT:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
		return $source; 
	}
function filter ( & $ source ) { preg_match_all ( " !<script[^>]+>.*?</script>!is " , $ source , $ match ) ; $ _script_blocks = $ match [ 0 ] ; $ source = preg_replace ( " !<script[^>]+>.*?</script>!is " , '@@@SAVANT:TRIM:SCRIPT@@@' , $ source ) ; preg_match_all ( " !<pre[^>]+>.*?</pre>!is " , $ source , $ match ) ; $ _pre_blocks = $ match [ 0 ] ; $ source = preg_replace ( " !<pre[^>]+>.*?</pre>!is " , '@@@SAVANT:TRIM:PRE@@@' , $ source ) ; preg_match_all ( " !<textarea[^>]+>.*?</textarea>!is " , $ source , $ match ) ; $ _textarea_blocks = $ match [ 0 ] ; $ source = preg_replace ( " !<textarea[^>]+>.*?</textarea>!is " , '@@@SAVANT:TRIM:TEXTAREA@@@' , $ source ) ; $ source = trim ( preg_replace ( '/((?<!\?>)\n)[\s]+/m' , '\1' , $ source ) ) ; Savant2_Filter_trimwhitespace :: _replace ( " @@@SAVANT:TRIM:SCRIPT@@@ " , $ _script_blocks , $ source ) ; Savant2_Filter_trimwhitespace :: _replace ( " @@@SAVANT:TRIM:PRE@@@ " , $ _pre_blocks , $ source ) ; Savant2_Filter_trimwhitespace :: _replace ( " @@@SAVANT:TRIM:TEXTAREA@@@ " , $ _textarea_blocks , $ source ) ; return $ source ; }
Removes extra white space within the text.
Removes extra white space within the text .
// Pull out the script blocks // Pull out the pre blocks // Pull out the textarea blocks // remove all leading spaces, tabs and carriage returns NOT // preceeded by a php close tag. // replace script blocks // replace pre blocks // replace textarea blocks