Skip to content

Commit 2ff3a9c

Browse files
adam187fabpot
authored andcommitted
fix convert underline to html style
1 parent 88928fc commit 2ff3a9c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

SensioLabs/AnsiConverter/AnsiToHtmlConverter.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ protected function convertAnsiToColor($ansi)
8787
{
8888
$bg = 0;
8989
$fg = 7;
90+
$as = '';
9091
if ('0' != $ansi && '' != $ansi) {
9192
$options = explode(';', $ansi);
9293

@@ -109,7 +110,7 @@ protected function convertAnsiToColor($ansi)
109110
}
110111

111112
if (in_array(4, $options)) {
112-
$text = sprintf('<u>%s</u>', $text);
113+
$as = '; text-decoration: underline';
113114
}
114115

115116
if (in_array(7, $options)) {
@@ -118,7 +119,7 @@ protected function convertAnsiToColor($ansi)
118119
}
119120

120121
if ($this->inlineStyles) {
121-
return sprintf('</span><span style="background-color: %s; color: %s">', $this->inlineColors[$this->colorNames[$bg]], $this->inlineColors[$this->colorNames[$fg]]);
122+
return sprintf('</span><span style="background-color: %s; color: %s%s">', $this->inlineColors[$this->colorNames[$bg]], $this->inlineColors[$this->colorNames[$fg]], $as);
122123
} else {
123124
return sprintf('</span><span class="ansi_color_bg_%s ansi_color_fg_%s">', $this->colorNames[$bg], $this->colorNames[$fg]);
124125
}

SensioLabs/AnsiConverter/Tests/AnsiToHtmlConverterTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public function getConvertData()
4848

4949
// carriage returns
5050
array("<span style=\"background-color: black; color: white\">foobar</span>", "foo\rbar\rfoobar"),
51+
52+
// underline
53+
array("<span style=\"background-color: black; color: white; text-decoration: underline\">foo</span>", "\e[4mfoo\e[0m"),
5154
);
5255
}
5356
}

0 commit comments

Comments
 (0)