20     public $name = 
'ExtractStyleBlocks';
 
   25         $this->_tidy = 
new csstidy();
 
   33         $this->_styleMatches[] = $matches[1];
 
   41         $tidy = 
$config->get(
'Filter.ExtractStyleBlocks.TidyImpl');
 
   43         $html = preg_replace_callback(
'#<style(?:\s.*)?>(.+)</style>#isU', array($this, 
'styleCallback'), $html);
 
   45         $this->_styleMatches = array(); 
 
   46         $context->register(
'StyleBlocks', $style_blocks); 
 
   48             foreach ($style_blocks as &$style) {
 
   65         $scope = 
$config->get(
'Filter.ExtractStyleBlocks.Scope');
 
   66         if ($scope !== null) {
 
   67             $scopes = array_map(
'trim', explode(
',', $scope));
 
   73         if (strncmp(
'<!--', $css, 4) === 0) {
 
   74             $css = substr($css, 4);
 
   76         if (strlen($css) > 3 && substr($css, -3) == 
'-->') {
 
   77             $css = substr($css, 0, -3);
 
   80         $this->_tidy->parse($css);
 
   81         $css_definition = 
$config->getDefinition(
'CSS');
 
   82         foreach ($this->_tidy->css as $k => $decls) {
 
   85             foreach ($decls as $selector => $style) {
 
   86                 $selector = trim($selector);
 
   87                 if ($selector === 
'') 
continue; 
 
   88                 if ($selector[0] === 
'+') {
 
   89                     if ($selector !== 
'' && $selector[0] === 
'+') 
continue;
 
   91                 if (!empty($scopes)) {
 
   92                     $new_selector = array(); 
 
   93                     $selectors = array_map(
'trim', explode(
',', $selector));
 
   94                     foreach ($scopes as $s1) {
 
   95                         foreach ($selectors as $s2) {
 
   96                             $new_selector[] = 
"$s1 $s2";
 
   99                     $selector = implode(
', ', $new_selector); 
 
  101                 foreach ($style as 
$name => $value) {
 
  102                     if (!isset($css_definition->info[
$name])) {
 
  103                         unset($style[
$name]);
 
  106                     $def = $css_definition->info[
$name];
 
  108                     if (
$ret === 
false) unset($style[
$name]);
 
  111                 $new_decls[$selector] = $style;
 
  113             $this->_tidy->css[$k] = $new_decls;
 
  117         $this->_tidy->import = array();
 
  118         $this->_tidy->charset = null;
 
  119         $this->_tidy->namespace = null;
 
  120         $css = $this->_tidy->print->plain();
 
  123         if (
$config->get(
'Filter.ExtractStyleBlocks.Escaping')) {
 
  125                 array(
'<',    
'>',    
'&'),
 
  126                 array(
'\3C ', 
'\3E ', 
'\26 '),