All pastes #994417 Raw Edit

Anonymous

public text v1 · immutable
#994417 ·published 2008-04-23 12:04 UTC
rendered paste body
class format
{


	function format ( $text )
	{
	
		$text = htmlentities( $text );
		$text = preg_replace( "\n[:alnum:]\n", "<p>$1</p>", $text );
		$text = preg_replace( "\r[:alnum:]\r", "<p>$1</p>", $text );
		$text = preg_replace( "\r\n[:alnum:]\r\n", "<p>$1</p>", $text );
		$text = preg_replace( "\n\r[:alnum:]\n\r", "<p>$1</p>", $text );
		$text = preg_replace( "<img>[:alnum:]</img>", "<img src=\"$1\" alt=\"picture\" />", $text );
		$text = preg_replace( "<bold>[:alnum:]</bold>", "<span style=\"font-weight:bold;\">$1</span>", $text );
		$text = preg_replace( "<italic>[:alnum:]</italic>", "<span style=\"font-style:italic;\">$1</span>", $text );
		$text = preg_replace( "<underline>[:alnum:]</underline>", "<span style=\"text-decoration:underline;\">$1</span>", $text );
		$text = preg_replace( "<color=[:alnum:]>[:alnum:]</color>", "<span style=\"color:$1\">$2</span>", $text );
		$text = preg_replace( "<pre>[:alnum:]</pre>", "<pre>$1</pre>", $text );
	
	}


}