[Console] Make style formatter matching less greedy to avoid having to escape when not needed
This commit is contained in:
parent
87160a7051
commit
8ca1b805ce
|
@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface
|
|||
/**
|
||||
* The pattern to phrase the format.
|
||||
*/
|
||||
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<).)*)#is';
|
||||
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?:(?!\\\\?<(?:/?[a-z]|/>)).)*)#is';
|
||||
|
||||
private $decorated;
|
||||
private $styles = array();
|
||||
|
|
|
@ -73,6 +73,16 @@ class FormatterStyleTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
}
|
||||
|
||||
public function testStyleMatchingNotGreedy()
|
||||
{
|
||||
$formatter = new OutputFormatter(true);
|
||||
|
||||
$this->assertEquals(
|
||||
"(\033[32m>=2.0,<2.3\033[0m)",
|
||||
$formatter->format('(<info>>=2.0,<2.3</info>)')
|
||||
);
|
||||
}
|
||||
|
||||
public function testDeepNestedStyles()
|
||||
{
|
||||
$formatter = new OutputFormatter(true);
|
||||
|
|
Reference in New Issue