diff options
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 |