[Console] Fix style escaping parsing

This commit is contained in:
Jordi Boggiano 2013-01-08 17:21:26 +01:00
parent 8ca1b805ce
commit eb93e66aa7
2 changed files with 11 additions and 1 deletions

View File

@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface
/**
* The pattern to phrase the format.
*/
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<(?:/?[a-z]|/>)).)*)#is';
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx';
private $decorated;
private $styles = array();

View File

@ -83,6 +83,16 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase
);
}
public function testStyleEscaping()
{
$formatter = new OutputFormatter(true);
$this->assertEquals(
"(\033[32mz>=2.0,<a2.3\033[0m)",
$formatter->format('(<info>'.$formatter->escape('z>=2.0,<a2.3').'</info>)')
);
}
public function testDeepNestedStyles()
{
$formatter = new OutputFormatter(true);