gitlabhq/gitlab-ci — pull request #269 by pschultz (2013-08-30 12:28:51+00:00)
Title: Better support for ansi colors and text styles

I have rewritten ansi2html. It now supports

- foreground colors,
- background colors,
- normal and bright colors,
- the 256 xterm color table
- bold, italic, underlined, crossed-out and concealed text

The command sequence interpretation is based on [this Wikipedia article][1]. I took the color codes for the 16 color palette from there as well. The 256 color palette is based on [this][2] and [this][3].

At the end of this post you can find a screenshot comparing the new build trace on the left to the default Terminal program of Gnome 3.8 using the built-in xterm profile on the right. I also attached a screenshot of a real world example.

Note that the normal blue colors in the screenshot are not the same. According to Wikipedia it should be `#0000ee` but all the terminals I tried used more like `#1e90ff`. I decided to go with the standard color (the alternative is still in the stylesheet, but disabled).

The next to last line in the output demonstrates the concealed style. I've seen that used to hide sensitive information. However, the concealed text in the build trace is merely hidden with `visibility: hidden` and still present in the html source - something to keep in mind.

![screenshot from 2013-08-30 13 36 43](https://f.cloud.github.com/assets/607733/1057243/065f4118-116e-11e3-8888-b3a2f79be1ca.png)
Screenshot comparing the new build trace with Gnome's Terminal. Output generated by [this script][4].

![screenshot from 2013-08-30 13 41 08](https://f.cloud.github.com/assets/607733/1057246/116571d6-116e-11e3-821d-6c2be6bdbee7.png)
Screenshot showing one of our PHP projects

[1]: http://en.wikipedia.org/wiki/ANSI_escape_code
[2]: http://en.wikipedia.org/wiki/File:Xterm_256color_chart.svg
[3]: https://gist.github.com/jasonm23/2868981
[4]: https://gist.github.com/pschultz/6388910

/ref #18

PS: I've added minitest to the Gemfile. Without it I wasn't able to run the tests after executing `bundle install`. If you don't want that drop a note and I remove the commit.