Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a47d663

Browse files
committed
[Console] fixed the formatter for single-char tags
1 parent c6c35b3 commit a47d663

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/Symfony/Component/Console/Formatter/OutputFormatter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class OutputFormatter implements OutputFormatterInterface
2323
/**
2424
* The pattern to phrase the format.
2525
*/
26-
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]+)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx';
26+
const FORMAT_PATTERN = '#(\\\\?)<(/?)([a-z][a-z0-9_=;-]*)?>((?: [^<\\\\]+ | (?!<(?:/?[a-z]|/>)). | .(?<=\\\\<) )*)#isx';
2727

2828
private $decorated;
2929
private $styles = array();

src/Symfony/Component/Console/Tests/Formatter/OutputFormatterTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,10 @@ public function testNewStyle()
113113
$this->assertEquals($style, $formatter->getStyle('test'));
114114
$this->assertNotEquals($style, $formatter->getStyle('info'));
115115

116-
$this->assertEquals("\033[34;47msome custom msg\033[0m", $formatter->format('<test>some custom msg</test>'));
116+
$style = new OutputFormatterStyle('blue', 'white');
117+
$formatter->setStyle('b', $style);
118+
119+
$this->assertEquals("\033[34;47msome \033[0m\033[34;47mcustom\033[0m\033[34;47m msg\033[0m", $formatter->format('<test>some <b>custom</b> msg</test>'));
117120
}
118121

119122
public function testRedefineStyle()
@@ -137,7 +140,7 @@ public function testInlineStyle()
137140
public function testNonStyleTag()
138141
{
139142
$formatter = new OutputFormatter(true);
140-
$this->assertEquals("\033[32msome \033[0m\033[32m<tag> styled\033[0m", $formatter->format('<info>some <tag> styled</info>'));
143+
$this->assertEquals("\033[32msome \033[0m\033[32m<tag> styled \033[0m\033[32m<p>single-char tag\033[0m\033[32m</p>\033[0m", $formatter->format('<info>some <tag> styled <p>single-char tag</p></info>'));
141144
}
142145

143146
public function testNotDecoratedFormatter()

0 commit comments

Comments
 (0)