Browse Source

[Console] fixed nested styles

Fabien Potencier 14 years ago
parent
commit
79c6dc7937

+ 1 - 1
src/Symfony/Component/Console/Formatter/OutputFormatter.php

@@ -151,7 +151,7 @@ class OutputFormatter implements OutputFormatterInterface
             }
         }
 
-        return $style->apply($match[2]);
+        return $style->apply($this->format($match[2]));
     }
 
     /**

+ 9 - 0
tests/Symfony/Tests/Component/Console/Formatter/OutputFormatterTest.php

@@ -39,6 +39,15 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase
         );
     }
 
+    public function testNestedStyles()
+    {
+        $formatter = new OutputFormatter(true);
+
+        $this->assertEquals(
+            "\033[37;41msome \033[32msome info\033[0m error\033[0m", $formatter->format('<error>some <info>some info</info> error</error>')
+        );
+    }
+
     public function testNewStyle()
     {
         $formatter = new OutputFormatter(true);