summaryrefslogtreecommitdiffstats
path: root/src/Utils/Formatter.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Utils/Formatter.php')
-rw-r--r--src/Utils/Formatter.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Utils/Formatter.php b/src/Utils/Formatter.php
index 0a8e054..ac3284c 100644
--- a/src/Utils/Formatter.php
+++ b/src/Utils/Formatter.php
@@ -529,6 +529,7 @@ class Formatter
public function toString($token)
{
$text = $token->token;
+ static $prev;
foreach ($this->options['formats'] as $format) {
if ($token->type === $format['type']
@@ -544,7 +545,12 @@ class Formatter
if ($this->options['type'] === 'html') {
return '<span ' . $format['html'] . '>' . htmlspecialchars($text, ENT_NOQUOTES) . '</span>';
} elseif ($this->options['type'] === 'cli') {
- return $format['cli'] . $this->escapeConsole($text);
+ if ($prev != $format['cli']) {
+ $prev = $format['cli'];
+ return $format['cli'] . $this->escapeConsole($text);
+ }
+
+ return $this->escapeConsole($text);
}
break;
@@ -552,7 +558,12 @@ class Formatter
}
if ($this->options['type'] === 'cli') {
- return "\x1b[39m" . $this->escapeConsole($text);
+ if ($prev != "\x1b[39m") {
+ $prev = "\x1b[39m";
+ return "\x1b[39m" . $this->escapeConsole($text);
+ }
+
+ return $this->escapeConsole($text);
} elseif ($this->options['type'] === 'html') {
return htmlspecialchars($text, ENT_NOQUOTES);
}