diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-14 21:27:52 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-11-14 21:27:52 +0200 |
commit | 3c16243fc8dbddcacf6da58866efea3aa46cfcde (patch) | |
tree | ed9dccae58c3e808113da95caea986f5fe3cc9e6 /lib | |
parent | a62a304249f7fcd7fca0123986d170cac8fd75db (diff) | |
download | gitlab-ci-3c16243fc8dbddcacf6da58866efea3aa46cfcde.tar.gz |
Improve parser. tests added
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ansi2html.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/ansi2html.rb b/lib/ansi2html.rb index 9375075..59491f1 100644 --- a/lib/ansi2html.rb +++ b/lib/ansi2html.rb @@ -1,7 +1,6 @@ # ANSI color library module Ansi2html COLOR = { - '1' => 'bold', '30' => 'black', '31' => 'red', '32' => 'green', @@ -18,12 +17,14 @@ module Ansi2html tag_open = false s = StringScanner.new(ansi.gsub("<", "<")) while(!s.eos?) - if s.scan(/\e\[(3[0-7]|90|1)m/) || s.scan(/\[1;(3[0-7])m/) + if s.scan(/\e\[(3[0-7]|90)m/) || s.scan(/\e\[1;(3[0-7])m/) if tag_open out << %{</span>} end out << %{<span class="#{COLOR[s[1]]}">} tag_open = true + elsif s.scan(/\e\[1m/) + # Just ignore bold style else if s.scan(/\e\[0m/) if tag_open @@ -35,6 +36,9 @@ module Ansi2html end end end + if tag_open + out << %{</span>} + end out end end |