summaryrefslogtreecommitdiff
path: root/lib/ansi2html.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-14 21:10:41 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-14 21:10:41 +0200
commita62a304249f7fcd7fca0123986d170cac8fd75db (patch)
treee376c17bff3a2d272daf4a5f159533497d2100b9 /lib/ansi2html.rb
parent15001355da1f704c69138f696e97b040db965d43 (diff)
downloadgitlab-ci-a62a304249f7fcd7fca0123986d170cac8fd75db.tar.gz
ajax image. Changed trace logic. Make sure we always close tags for trace
Diffstat (limited to 'lib/ansi2html.rb')
-rw-r--r--lib/ansi2html.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/ansi2html.rb b/lib/ansi2html.rb
index 5650d81..9375075 100644
--- a/lib/ansi2html.rb
+++ b/lib/ansi2html.rb
@@ -15,13 +15,21 @@ module Ansi2html
def self.convert(ansi)
out = ""
+ tag_open = false
s = StringScanner.new(ansi.gsub("<", "&lt;"))
while(!s.eos?)
- if s.scan(/\e\[(3[0-7]|90|1)m/)
+ if s.scan(/\e\[(3[0-7]|90|1)m/) || s.scan(/\[1;(3[0-7])m/)
+ if tag_open
+ out << %{</span>}
+ end
out << %{<span class="#{COLOR[s[1]]}">}
+ tag_open = true
else
if s.scan(/\e\[0m/)
- out << %{</span>}
+ if tag_open
+ out << %{</span>}
+ end
+ tag_open = false
else
out << s.scan(/./m)
end