CI trace ansi colours 256 bold have no CSS due wrongly ansi2html light color variant conversion feature

Summary

when in a CI JOB trace an ansi xterm_colors_256 bold f.i. \e[38;5;xxx;1m is used, the Ansi2html conversion changes html class xterm-fg-xxx to xterm-fg-l-xxx while no CSS is defined for xterm-fg-l-xxx in xterm.scss and thus results in bold white for any ansi_256_color.

Steps to reproduce

In a ansi color capable runner, script:

echo -e "\033[38;5;82;1m * Prepare Environment: \033[0;m \n"

which will result in:

image

or

<span class="xterm-fg-l-82 term-bold"><br>* Prepare Environment:<br></span>

since no css object xterm-fg-l-82 is defined.

i.s.o.

image

Example Project

on request

What is the current bug behavior?

image

What is the expected correct behavior?

image

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

Output of checks

This bug happens on GitLab.com

Possible fixes

in ansi2html.rb change line 237 from /fg-(\w{2,}+)/ to /fg-([a-z]{2,}+)/ .

this will not convert an xterm-fg-123 to xterm-fg-l-123 and since it is an custom colour, that light variant conversion for bold is of no use.

          unless @fg_color.nil?
            fg_color = @fg_color
            # Most terminals show bold coloured text in the light colour variant
            # Let's mimic that here
            if @style_mask & STYLE_SWITCHES[:bold] != 0
-              fg_color.sub!(/fg-(\w{2,}+)/, 'fg-l-\1') 
+              fg_color.sub!(/fg-([a-z]{2,}+)/, 'fg-l-\1')
            end
            css_classes << fg_color
          end
          css_classes << @bg_color unless @bg_color.nil?

and spec: ansi2html_spec.rb#L119

 it "can print 256 xterm fg colors" do
    expect(convert_html("\e[38;5;16mHello")).to eq('<span class="xterm-fg-16">Hello</span>')
  end
+
+  it "can print 256 xterm fg bold colors" do
+    expect(convert_html("\e[38;5;16;1mHello")).to eq('<span class="xterm-fg-16 term-bold">Hello</span>')
+  end

  it "can print 256 xterm fg colors on normal magenta background" do
    expect(convert_html("\e[38;5;16;45mHello")).to eq('<span class="xterm-fg-16 term-bg-magenta">Hello</span>')
  end
Edited by Danny