File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
src/Symfony/Component/Console Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,10 @@ public function format($message)
150
150
$ pos = $ match [1 ];
151
151
$ text = $ match [0 ];
152
152
153
+ if (0 != $ pos && '\\' == $ message [$ pos - 1 ]) {
154
+ continue ;
155
+ }
156
+
153
157
// add the text up to the next tag
154
158
$ output .= $ this ->applyCurrentStyle (substr ($ message , $ offset , $ pos - $ offset ));
155
159
$ offset = $ pos + strlen ($ text );
@@ -164,9 +168,6 @@ public function format($message)
164
168
if (!$ open && !$ tag ) {
165
169
// </>
166
170
$ this ->styleStack ->pop ();
167
- } elseif ($ pos && '\\' == $ message [$ pos - 1 ]) {
168
- // escaped tag
169
- $ output .= $ this ->applyCurrentStyle ($ text );
170
171
} elseif (false === $ style = $ this ->createStyleFromString (strtolower ($ tag ))) {
171
172
$ output .= $ this ->applyCurrentStyle ($ text );
172
173
} elseif ($ open ) {
Original file line number Diff line number Diff line change @@ -101,6 +101,11 @@ public function testStyleEscaping()
101
101
"( \033[32mz>=2.0,<a2.3 \033[0m) " ,
102
102
$ formatter ->format ('(<info> ' .$ formatter ->escape ('z>=2.0,<a2.3 ' ).'</info>) ' )
103
103
);
104
+
105
+ $ this ->assertEquals (
106
+ "\033[32m<error>some error</error> \033[39m " ,
107
+ $ formatter ->format ('<info> ' .$ formatter ->escape ('<error>some error</error> ' ).'</info> ' )
108
+ );
104
109
}
105
110
106
111
public function testDeepNestedStyles ()
You can’t perform that action at this time.
0 commit comments