Skip to content

Commit 811e22a

Browse files
committed
Add styling to css
1 parent cab7017 commit 811e22a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

SensioLabs/AnsiConverter/AnsiToHtmlConverter.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ protected function convertAnsiToColor($ansi)
9595
{
9696
$bg = 0;
9797
$fg = 7;
98-
$as = '';
99-
$hi = false;
98+
$as = ''; // inline styles
99+
$cs = ''; // css classes
100+
$hi = false; // high intensity
100101
if ('0' != $ansi && '' != $ansi) {
101102
$options = explode(';', $ansi);
102103

@@ -129,14 +130,17 @@ protected function convertAnsiToColor($ansi)
129130

130131
if (in_array(3, $options)) {
131132
$as .= '; font-style: italic';
133+
$cs .= ' ansi_color_italic';
132134
}
133135

134136
if (in_array(4, $options)) {
135137
$as .= '; text-decoration: underline';
138+
$cs .= ' ansi_color_underline';
136139
}
137140

138141
if (in_array(9, $options)) {
139142
$as .= '; text-decoration: line-through';
143+
$cs .= ' ansi_color_strikethrough';
140144
}
141145

142146
if (in_array(7, $options)) {
@@ -149,7 +153,7 @@ protected function convertAnsiToColor($ansi)
149153
if ($this->inlineStyles) {
150154
return sprintf('</span><span style="background-color: %s; color: %s%s">', $this->inlineColors[$this->colorNames[$bg]], $this->inlineColors[$this->colorNames[$fg]], $as);
151155
} else {
152-
return sprintf('</span><span class="ansi_color_bg_%s ansi_color_fg_%s">', $this->colorNames[$bg], $this->colorNames[$fg]);
156+
return sprintf('</span><span class="ansi_color_bg_%s ansi_color_fg_%s%s">', $this->colorNames[$bg], $this->colorNames[$fg], $cs);
153157
}
154158
}
155159

SensioLabs/AnsiConverter/Theme/Theme.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public function asCss($prefix = 'ansi_color')
2424
$css[] = sprintf('.%s_bg_%s { background-color: %s }', $prefix, $name, $color);
2525
}
2626

27+
$css[] = sprintf('.%s_italic { font-style: italic }', $prefix);
28+
$css[] = sprintf('.%s_underline { text-decoration: underline }', $prefix);
29+
$css[] = sprintf('.%s_strikethrough { text-decoration: line-through }', $prefix);
30+
2731
return implode("\n", $css);
2832
}
2933

0 commit comments

Comments
 (0)