public function censorHtml($html, $censorAttributes = false)
	{
		$attributesExpr = '';
		if ($censorAttributes)
		{
			$attributesExpr = '|[^<">]*+(?="(?> [-\\w]+="[^"]*+")*+\\/?>)';
		}

		// Modify the original regexp so that it only matches text nodes and optionally attribute
		// values
		$delim  = $this->regexpHtml[0];
		$pos    = strrpos($this->regexpHtml, $delim);
		$regexp = $delim
		        . '(?<!&|&#)'
		        . substr($this->regexpHtml, 1, $pos - 1)
		        . '(?=[^<>]*+(?=<|$)' . $attributesExpr . ')'
		        . substr($this->regexpHtml, $pos);

		return preg_replace_callback(
			$regexp,
			function ($m)
			{
				return htmlspecialchars($this->getReplacement(html_entity_decode($m[0], ENT_QUOTES, 'UTF-8')), ENT_QUOTES);
			},
			$html
		);
	}
public function censorHtml($html, $censorAttributes = false)
	{
		$attributesExpr = '';
		if ($censorAttributes)
		{
			$attributesExpr = '|[^<">]*+(?="(?> [-\\w]+="[^"]*+")*+\\/?>)';
		}

		// Modify the original regexp so that it only matches text nodes and optionally attribute
		// values
		$delim  = $this->regexpHtml[0];
		$pos    = strrpos($this->regexpHtml, $delim);
		$regexp = $delim
		        . '(?<!&|&#)'
		        . substr($this->regexpHtml, 1, $pos - 1)
		        . '(?=[^<>]*+(?=<|$)' . $attributesExpr . ')'
		        . substr($this->regexpHtml, $pos);

		return preg_replace_callback(
			$regexp,
			function ($m)
			{
				return htmlspecialchars($this->getReplacement(html_entity_decode($m[0], ENT_QUOTES, 'UTF-8')), ENT_QUOTES);
			},
			$html
		);
	}
public function censorHtml ( $ html , $ censorAttributes = false ) { $ attributesExpr = '' ; if ( $ censorAttributes ) { $ attributesExpr = '|[^<">]*+(?="(?> [-\\w]+="[^"]*+")*+\\/?>)' ; } // Modify the original regexp so that it only matches text nodes and optionally attribute // values $ delim = $ this -> regexpHtml [ 0 ] ; $ pos = strrpos ( $ this -> regexpHtml , $ delim ) ; $ regexp = $ delim . '(?<!&|&#)' . substr ( $ this -> regexpHtml , 1 , $ pos - 1 ) . '(?=[^<>]*+(?=<|$)' . $ attributesExpr . ')' . substr ( $ this -> regexpHtml , $ pos ) ; return preg_replace_callback ( $ regexp , function ( $ m ) { return htmlspecialchars ( $ this -> getReplacement ( html_entity_decode ( $ m [ 0 ] , ENT_QUOTES , 'UTF-8' ) ) , ENT_QUOTES ) ; } , $ html ) ; }
Censor text nodes inside of HTML code

NOTE: will only recognize attributes that are enclosed in double quotes

@param  string $html             Original HTML
@param  bool   $censorAttributes Whether to censor the content of attributes
@return string                   Censored HTML
Censor text nodes inside of HTML code