Permalink
Browse files

implicit reset ansi sequence

  • Loading branch information...
1 parent 7b0b6c9 commit c1c35fedb344f28d4a03af951905ce1af2821957 @rtomayko committed Jun 27, 2010
Showing with 8 additions and 1 deletion.
  1. +2 −1 lib/bcat/ansi.rb
  2. +6 −0 test/test_bcat_ansi.rb
View
@@ -144,7 +144,8 @@ def tokenize(text)
[/\A\x08+/, lambda { |m| '' }],
# ansi escape sequences that mess with the display
- [/\A\x1b\[((?:\d{1,3};?)+)m/, lambda { |m|
+ [/\A\x1b\[((?:\d{1,3};?)+|)m/, lambda { |m|
+ m = '0' if m.strip.empty?
m.chomp(';').split(';').
each { |code| yield :display, code.to_i };
'' }],
View
@@ -93,6 +93,12 @@ class ANSITest < Test::Unit::TestCase
assert_equal expect, Bcat::ANSI.new(text).to_html
end
+ test "resetting without an implicit 0 argument" do
+ text = "\x1b[1mthis is bold\x1b[m, but this isn't"
+ expect = "<b>this is bold</b>, but this isn't"
+ assert_equal expect, Bcat::ANSI.new(text).to_html
+ end
+
test "multi-attribute sequences" do
text = "normal, \x1b[1;3;31mbold, underline, and red\x1b[0m, normal"
expect = "normal, <b><u><span style='color:#A00'>" +

0 comments on commit c1c35fe

Please sign in to comment.