/**
  * Converts $this->css array to a raw array ($this->tokens).
  *
  * @since 1.0.0
  *
  * @param string $default_media Optional. Default @media to add to selectors without any @media.
  */
 protected function _convert_raw_css($default_media = '')
 {
     $this->tokens = array();
     $sort_selectors = $this->parser->get_cfg('sort_selectors');
     $sort_properties = $this->parser->get_cfg('sort_properties');
     foreach ($this->css as $medium => $val) {
         if ($sort_selectors) {
             ksort($val);
         }
         if (intval($medium) < DEFAULT_AT) {
             // un medium vide (contenant @font-face ou autre @) ne produit aucun conteneur
             if (strlen(trim($medium))) {
                 $this->parser->_add_token(AT_START, $medium, true);
             }
         } elseif ($default_media) {
             $this->parser->_add_token(AT_START, $default_media, true);
         }
         foreach ($val as $selector => $vali) {
             if ($sort_properties) {
                 ksort($vali);
             }
             $this->parser->_add_token(SEL_START, $selector, true);
             $invalid = array('*' => array(), '_' => array(), '/' => array(), '-' => array());
             foreach ($vali as $property => $valj) {
                 if (0 !== strncmp($property, '//', 2)) {
                     $matches = array();
                     if ($sort_properties && preg_match('/^(\\*|_|\\/|-)(?!(ms|moz|o\\b|xv|atsc|wap|khtml|webkit|ah|hp|ro|rim|tc)-)/', $property, $matches)) {
                         $invalid[$matches[1]][$property] = $valj;
                     } else {
                         $this->parser->_add_token(PROPERTY, $property, true);
                         $this->parser->_add_token(VALUE, $valj, true);
                     }
                 }
             }
             foreach ($invalid as $prefix => $props) {
                 foreach ($props as $property => $valj) {
                     $this->parser->_add_token(PROPERTY, $property, true);
                     $this->parser->_add_token(VALUE, $valj, true);
                 }
             }
             $this->parser->_add_token(SEL_END, $selector, true);
         }
         if (intval($medium) < DEFAULT_AT) {
             // un medium vide (contenant @font-face ou autre @) ne produit aucun conteneur
             if (strlen(trim($medium))) {
                 $this->parser->_add_token(AT_END, $medium, true);
             }
         } elseif ($default_media) {
             $this->parser->_add_token(AT_END, $default_media, true);
         }
     }
 }
 /**
  * Optimises a sub-value.
  *
  * @since 1.0.0
  */
 public function subvalue()
 {
     $replace_colors =& $this->parser->data['csstidy']['replace_colors'];
     $this->sub_value = trim($this->sub_value);
     if ('' === $this->sub_value) {
         // caution : '0'
         return;
     }
     $important = '';
     if ($this->parser->is_important($this->sub_value)) {
         $important = ' !important';
     }
     $this->sub_value = $this->parser->gvw_important($this->sub_value);
     // Compress font-weight.
     if ('font-weight' === $this->property && $this->parser->get_cfg('compress_font-weight')) {
         if ('bold' === $this->sub_value) {
             $this->sub_value = '700';
             $this->parser->log('Optimised font-weight: Changed "bold" to "700"', 'Information');
         } elseif ('normal' === $this->sub_value) {
             $this->sub_value = '400';
             $this->parser->log('Optimised font-weight: Changed "normal" to "400"', 'Information');
         }
     }
     $temp = $this->compress_numbers($this->sub_value);
     if (0 !== strcasecmp($temp, $this->sub_value)) {
         if (strlen($temp) > strlen($this->sub_value)) {
             $this->parser->log('Fixed invalid number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning');
         } else {
             $this->parser->log('Optimised number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information');
         }
         $this->sub_value = $temp;
     }
     if ($this->parser->get_cfg('compress_colors')) {
         $temp = $this->cut_color($this->sub_value);
         if ($temp !== $this->sub_value) {
             if (isset($replace_colors[$this->sub_value])) {
                 $this->parser->log('Fixed invalid color name: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning');
             } else {
                 $this->parser->log('Optimised color: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information');
             }
             $this->sub_value = $temp;
         }
     }
     $this->sub_value .= $important;
 }