public static function write($message){
      if( preg_match('~<[^>]+>~',$message)) {
         // Use preg_replace_callback for fast regex matches navigation
         echo strtr(preg_replace_callback('~^(.*)<([^>]+)>(.+)</\2>(.*)$~USm',function($m){
            static::write($m[1]);
            $color = strtoupper(trim($m[2]));
            if( isset(static::$shell_colors[$color]) ) echo static::$shell_colors[$color];
            static::$color_stack[] = $color;
            static::write($m[3]);
            array_pop(static::$color_stack);
            $back_color = array_pop(static::$color_stack) ?: static::$color_stack[]='NORMAL';
            if( isset(static::$shell_colors[$back_color]) ) echo static::$shell_colors[$back_color];
            static::write($m[4]);
         },strtr($message,["\n"=>"&BR;"])),["&BR;"=>PHP_EOL]);
      } else {
         echo strtr($message,["&BR;"=>PHP_EOL]);
      }
   }