awesome_print 0.4.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/.gitignore +22 -0
  2. data/CHANGELOG +8 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +26 -0
  5. data/README.md +52 -14
  6. data/Rakefile +2 -46
  7. data/lib/ap.rb +3 -17
  8. data/lib/awesome_print.rb +16 -12
  9. data/lib/{ap → awesome_print}/core_ext/array.rb +0 -0
  10. data/lib/{ap → awesome_print}/core_ext/class.rb +0 -0
  11. data/lib/{ap → awesome_print}/core_ext/kernel.rb +2 -2
  12. data/lib/awesome_print/core_ext/logger.rb +20 -0
  13. data/lib/{ap → awesome_print}/core_ext/method.rb +0 -0
  14. data/lib/{ap → awesome_print}/core_ext/object.rb +0 -0
  15. data/lib/{ap → awesome_print}/core_ext/string.rb +8 -5
  16. data/lib/awesome_print/ext/action_view.rb +18 -0
  17. data/lib/awesome_print/ext/active_record.rb +40 -0
  18. data/lib/awesome_print/ext/active_support.rb +40 -0
  19. data/lib/awesome_print/ext/mongo_mapper.rb +38 -0
  20. data/lib/awesome_print/ext/mongoid.rb +39 -0
  21. data/lib/awesome_print/ext/nokogiri.rb +45 -0
  22. data/lib/awesome_print/formatter.rb +350 -0
  23. data/lib/awesome_print/inspector.rb +140 -0
  24. data/{rails/init.rb → lib/awesome_print/version.rb} +5 -4
  25. data/spec/colors_spec.rb +106 -0
  26. data/spec/{awesome_print_spec.rb → formats_spec.rb} +187 -37
  27. data/spec/methods_spec.rb +20 -0
  28. data/spec/objects_spec.rb +79 -0
  29. data/spec/spec_helper.rb +1 -1
  30. metadata +49 -53
  31. data/VERSION +0 -1
  32. data/init.rb +0 -1
  33. data/lib/ap/awesome_print.rb +0 -352
  34. data/lib/ap/core_ext/logger.rb +0 -18
  35. data/lib/ap/mixin/action_view.rb +0 -17
  36. data/lib/ap/mixin/active_record.rb +0 -54
  37. data/lib/ap/mixin/active_support.rb +0 -46
  38. data/lib/ap/mixin/mongo_mapper.rb +0 -54
  39. data/spec/action_view_spec.rb +0 -25
  40. data/spec/active_record_spec.rb +0 -136
  41. data/spec/colorization_spec.rb +0 -84
  42. data/spec/logger_spec.rb +0 -43
  43. data/spec/mongo_mapper_spec.rb +0 -63
  44. data/spec/string_spec.rb +0 -20
@@ -0,0 +1,140 @@
1
+ # Copyright (c) 2010-2011 Michael Dvorkin
2
+ #
3
+ # Awesome Print is freely distributable under the terms of MIT license.
4
+ # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ module AwesomePrint
7
+
8
+ class << self # Class accessors for custom defaults.
9
+ attr_accessor :defaults, :force_colors
10
+
11
+ # Class accessor to force colorized output (ex. forked subprocess where TERM
12
+ # might be dumb).
13
+ #------------------------------------------------------------------------------
14
+ def force_colors!(value = true)
15
+ @force_colors = value
16
+ end
17
+ end
18
+
19
+ class Inspector
20
+ attr_accessor :options
21
+
22
+ AP = :__awesome_print__
23
+
24
+ def initialize(options = {})
25
+ @options = {
26
+ :indent => 4, # Indent using 4 spaces.
27
+ :index => true, # Display array indices.
28
+ :html => false, # Use ANSI color codes rather than HTML.
29
+ :multiline => true, # Display in multiple lines.
30
+ :plain => false, # Use colors.
31
+ :sort_keys => false, # Do not sort hash keys.
32
+ :limit => false, # Limit large output for arrays and hashes. Set to a boolean or integer.
33
+ :color => {
34
+ :args => :pale,
35
+ :array => :white,
36
+ :bigdecimal => :blue,
37
+ :class => :yellow,
38
+ :date => :greenish,
39
+ :falseclass => :red,
40
+ :fixnum => :blue,
41
+ :float => :blue,
42
+ :hash => :pale,
43
+ :keyword => :cyan,
44
+ :method => :purpleish,
45
+ :nilclass => :red,
46
+ :string => :yellowish,
47
+ :struct => :pale,
48
+ :symbol => :cyanish,
49
+ :time => :greenish,
50
+ :trueclass => :green,
51
+ :variable => :cyanish
52
+ }
53
+ }
54
+
55
+ # Merge custom defaults and let explicit options parameter override them.
56
+ merge_custom_defaults!
57
+ merge_options!(options)
58
+
59
+ @formatter = AwesomePrint::Formatter.new(self)
60
+ Thread.current[AP] ||= []
61
+ end
62
+
63
+ # Dispatcher that detects data nesting and invokes object-aware formatter.
64
+ #------------------------------------------------------------------------------
65
+ def awesome(object)
66
+ if Thread.current[AP].include?(object.object_id)
67
+ nested(object)
68
+ else
69
+ begin
70
+ Thread.current[AP] << object.object_id
71
+ unnested(object)
72
+ ensure
73
+ Thread.current[AP].pop
74
+ end
75
+ end
76
+ end
77
+
78
+ # Return true if we are to colorize the output.
79
+ #------------------------------------------------------------------------------
80
+ def colorize?
81
+ AwesomePrint.force_colors ||= false
82
+ AwesomePrint.force_colors || (STDOUT.tty? && ((ENV['TERM'] && ENV['TERM'] != 'dumb') || ENV['ANSICON']))
83
+ end
84
+
85
+ private
86
+
87
+ # Format nested data, for example:
88
+ # arr = [1, 2]; arr << arr
89
+ # => [1,2, [...]]
90
+ # hash = { :a => 1 }; hash[:b] = hash
91
+ # => { :a => 1, :b => {...} }
92
+ #------------------------------------------------------------------------------
93
+ def nested(object)
94
+ case printable(object)
95
+ when :array then @formatter.colorize("[...]", :array)
96
+ when :hash then @formatter.colorize("{...}", :hash)
97
+ when :struct then @formatter.colorize("{...}", :struct)
98
+ else @formatter.colorize("...#{object.class}...", :class)
99
+ end
100
+ end
101
+
102
+ #------------------------------------------------------------------------------
103
+ def unnested(object)
104
+ @formatter.format(object, printable(object))
105
+ end
106
+
107
+ # Turn class name into symbol, ex: Hello::World => :hello_world. Classes that
108
+ # inherit from Array, Hash, File, Dir, and Struct are treated as the base class.
109
+ #------------------------------------------------------------------------------
110
+ def printable(object)
111
+ case object
112
+ when Array then :array
113
+ when Hash then :hash
114
+ when File then :file
115
+ when Dir then :dir
116
+ when Struct then :struct
117
+ else object.class.to_s.gsub(/:+/, "_").downcase.to_sym
118
+ end
119
+ end
120
+
121
+ # Update @options by first merging the :color hash and then the remaining keys.
122
+ #------------------------------------------------------------------------------
123
+ def merge_options!(options = {})
124
+ @options[:color].merge!(options.delete(:color) || {})
125
+ @options.merge!(options)
126
+ end
127
+
128
+ # Load ~/.aprc file with custom defaults that override default options.
129
+ #------------------------------------------------------------------------------
130
+ def merge_custom_defaults!
131
+ dotfile = File.join(ENV["HOME"], ".aprc")
132
+ if File.readable?(dotfile)
133
+ load dotfile
134
+ merge_options!(AwesomePrint.defaults)
135
+ end
136
+ rescue => e
137
+ $stderr.puts "Could not load #{dotfile}: #{e}"
138
+ end
139
+ end
140
+ end
@@ -3,7 +3,8 @@
3
3
  # Awesome Print is freely distributable under the terms of MIT license.
4
4
  # See LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
- #
7
- # Load awesome_print when installed as Rails 2.3.x plugin.
8
- #
9
- require File.join(File.dirname(__FILE__), "..", "init") unless defined?(AwesomePrint)
6
+ module AwesomePrint
7
+ def self.version
8
+ '1.0.0'
9
+ end
10
+ end
@@ -0,0 +1,106 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "AwesomePrint" do
4
+ def stub_tty!(output = true, stream = STDOUT)
5
+ if output
6
+ stream.instance_eval { def tty?; true; end }
7
+ else
8
+ stream.instance_eval { def tty?; false; end }
9
+ end
10
+ end
11
+
12
+ before do
13
+ stub_dotfile!
14
+ end
15
+
16
+ describe "colorization" do
17
+ PLAIN = '[ 1, :two, "three", [ nil, [ true, false ] ] ]'
18
+ COLORIZED = "[ \e[1;34m1\e[0m, \e[0;36m:two\e[0m, \e[0;33m\"three\"\e[0m, [ \e[1;31mnil\e[0m, [ \e[1;32mtrue\e[0m, \e[1;31mfalse\e[0m ] ] ]"
19
+
20
+ before do
21
+ ENV['TERM'] = "xterm-colors"
22
+ ENV.delete('ANSICON')
23
+ @arr = [ 1, :two, "three", [ nil, [ true, false] ] ]
24
+ end
25
+
26
+ describe "default settings (no forced colors)" do
27
+ before do
28
+ AwesomePrint.force_colors! false
29
+ end
30
+
31
+ it "colorizes tty processes by default" do
32
+ stub_tty!
33
+ @arr.ai(:multiline => false).should == COLORIZED
34
+ end
35
+
36
+ it "colorizes processes with ENV['ANSICON'] by default" do
37
+ begin
38
+ stub_tty!
39
+ term, ENV['ANSICON'] = ENV['ANSICON'], "1"
40
+ @arr.ai(:multiline => false).should == COLORIZED
41
+ ensure
42
+ ENV['ANSICON'] = term
43
+ end
44
+ end
45
+
46
+ it "does not colorize tty processes running in dumb terminals by default" do
47
+ begin
48
+ stub_tty!
49
+ term, ENV['TERM'] = ENV['TERM'], "dumb"
50
+ @arr.ai(:multiline => false).should == PLAIN
51
+ ensure
52
+ ENV['TERM'] = term
53
+ end
54
+ end
55
+
56
+ it "does not colorize subprocesses by default" do
57
+ begin
58
+ stub_tty! false
59
+ @arr.ai(:multiline => false).should == PLAIN
60
+ ensure
61
+ stub_tty!
62
+ end
63
+ end
64
+ end
65
+
66
+ describe "forced colors override" do
67
+ before do
68
+ AwesomePrint.force_colors!
69
+ end
70
+
71
+ it "still colorizes tty processes" do
72
+ stub_tty!
73
+ @arr.ai(:multiline => false).should == COLORIZED
74
+ end
75
+
76
+ it "colorizes processes with ENV['ANSICON'] set to 0" do
77
+ begin
78
+ stub_tty!
79
+ term, ENV['ANSICON'] = ENV['ANSICON'], "1"
80
+ @arr.ai(:multiline => false).should == COLORIZED
81
+ ensure
82
+ ENV['ANSICON'] = term
83
+ end
84
+ end
85
+
86
+ it "colorizes dumb terminals" do
87
+ begin
88
+ stub_tty!
89
+ term, ENV['TERM'] = ENV['TERM'], "dumb"
90
+ @arr.ai(:multiline => false).should == COLORIZED
91
+ ensure
92
+ ENV['TERM'] = term
93
+ end
94
+ end
95
+
96
+ it "colorizes subprocess" do
97
+ begin
98
+ stub_tty! false
99
+ @arr.ai(:multiline => false).should == COLORIZED
100
+ ensure
101
+ stub_tty!
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
@@ -3,12 +3,12 @@ require "bigdecimal"
3
3
  require "rational"
4
4
 
5
5
  describe "AwesomePrint" do
6
- before(:each) do
6
+ before do
7
7
  stub_dotfile!
8
8
  end
9
9
 
10
10
  describe "Array" do
11
- before(:each) do
11
+ before do
12
12
  @arr = [ 1, :two, "three", [ nil, [ true, false] ] ]
13
13
  end
14
14
 
@@ -91,14 +91,14 @@ EOS
91
91
  it "colored multiline (default)" do
92
92
  @arr.ai.should == <<-EOS.strip
93
93
  [
94
- \e[1;37m [0] \e[0m\e[1;34m1\e[0m,
95
- \e[1;37m [1] \e[0m\e[0;36m:two\e[0m,
96
- \e[1;37m [2] \e[0m\e[0;33m\"three\"\e[0m,
97
- \e[1;37m [3] \e[0m[
98
- \e[1;37m [0] \e[0m\e[1;31mnil\e[0m,
99
- \e[1;37m [1] \e[0m[
100
- \e[1;37m [0] \e[0m\e[1;32mtrue\e[0m,
101
- \e[1;37m [1] \e[0m\e[1;31mfalse\e[0m
94
+ \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
95
+ \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
96
+ \e[1;37m[2] \e[0m\e[0;33m\"three\"\e[0m,
97
+ \e[1;37m[3] \e[0m[
98
+ \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
99
+ \e[1;37m[1] \e[0m[
100
+ \e[1;37m[0] \e[0m\e[1;32mtrue\e[0m,
101
+ \e[1;37m[1] \e[0m\e[1;31mfalse\e[0m
102
102
  ]
103
103
  ]
104
104
  ]
@@ -108,14 +108,14 @@ EOS
108
108
  it "colored multiline indented" do
109
109
  @arr.ai(:indent => 8).should == <<-EOS.strip
110
110
  [
111
- \e[1;37m [0] \e[0m\e[1;34m1\e[0m,
112
- \e[1;37m [1] \e[0m\e[0;36m:two\e[0m,
113
- \e[1;37m [2] \e[0m\e[0;33m\"three\"\e[0m,
114
- \e[1;37m [3] \e[0m[
115
- \e[1;37m [0] \e[0m\e[1;31mnil\e[0m,
116
- \e[1;37m [1] \e[0m[
117
- \e[1;37m [0] \e[0m\e[1;32mtrue\e[0m,
118
- \e[1;37m [1] \e[0m\e[1;31mfalse\e[0m
111
+ \e[1;37m[0] \e[0m\e[1;34m1\e[0m,
112
+ \e[1;37m[1] \e[0m\e[0;36m:two\e[0m,
113
+ \e[1;37m[2] \e[0m\e[0;33m\"three\"\e[0m,
114
+ \e[1;37m[3] \e[0m[
115
+ \e[1;37m[0] \e[0m\e[1;31mnil\e[0m,
116
+ \e[1;37m[1] \e[0m[
117
+ \e[1;37m[0] \e[0m\e[1;32mtrue\e[0m,
118
+ \e[1;37m[1] \e[0m\e[1;31mfalse\e[0m
119
119
  ]
120
120
  ]
121
121
  ]
@@ -129,7 +129,7 @@ EOS
129
129
 
130
130
  #------------------------------------------------------------------------------
131
131
  describe "Nested Array" do
132
- before(:each) do
132
+ before do
133
133
  @arr = [ 1, 2 ]
134
134
  @arr << @arr
135
135
  end
@@ -160,8 +160,97 @@ EOS
160
160
  end
161
161
 
162
162
  #------------------------------------------------------------------------------
163
- describe "Hash" do
163
+ describe "Limited Output Array" do
164
+ before(:each) do
165
+ @arr = (1..1000).to_a
166
+ end
167
+
168
+ it "plain limited output large" do
169
+ @arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
170
+ [
171
+ [ 0] 1,
172
+ [ 1] 2,
173
+ [ 2] 3,
174
+ [ 3] .. [996],
175
+ [997] 998,
176
+ [998] 999,
177
+ [999] 1000
178
+ ]
179
+ EOS
180
+ end
181
+
182
+ it "plain limited output small" do
183
+ @arr = @arr[0..3]
184
+ @arr.ai(:plain => true, :limit => true).should == <<-EOS.strip
185
+ [
186
+ [0] 1,
187
+ [1] 2,
188
+ [2] 3,
189
+ [3] 4
190
+ ]
191
+ EOS
192
+ end
193
+
194
+ it "plain limited output with 10 lines" do
195
+ @arr.ai(:plain => true, :limit => 10).should == <<-EOS.strip
196
+ [
197
+ [ 0] 1,
198
+ [ 1] 2,
199
+ [ 2] 3,
200
+ [ 3] 4,
201
+ [ 4] 5,
202
+ [ 5] .. [995],
203
+ [996] 997,
204
+ [997] 998,
205
+ [998] 999,
206
+ [999] 1000
207
+ ]
208
+ EOS
209
+ end
210
+
211
+ it "plain limited output with 11 lines" do
212
+ @arr.ai(:plain => true, :limit => 11).should == <<-EOS.strip
213
+ [
214
+ [ 0] 1,
215
+ [ 1] 2,
216
+ [ 2] 3,
217
+ [ 3] 4,
218
+ [ 4] 5,
219
+ [ 5] .. [994],
220
+ [995] 996,
221
+ [996] 997,
222
+ [997] 998,
223
+ [998] 999,
224
+ [999] 1000
225
+ ]
226
+ EOS
227
+ end
228
+ end
229
+
230
+ #------------------------------------------------------------------------------
231
+ describe "Limited Output Hash" do
164
232
  before(:each) do
233
+ @hash = ("a".."z").inject({}) { |h, v| h.merge({ v => v.to_sym }) }
234
+ end
235
+
236
+ it "plain limited output" do
237
+ @hash.ai(:sort_keys => true, :plain => true, :limit => true).should == <<-EOS.strip
238
+ {
239
+ "a" => :a,
240
+ "b" => :b,
241
+ "c" => :c,
242
+ "d" => :d .. "w" => :w,
243
+ "x" => :x,
244
+ "y" => :y,
245
+ "z" => :z
246
+ }
247
+ EOS
248
+ end
249
+ end
250
+
251
+ #------------------------------------------------------------------------------
252
+ describe "Hash" do
253
+ before do
165
254
  @hash = { 1 => { :sym => { "str" => { [1, 2, 3] => { { :k => :v } => Hash } } } } }
166
255
  end
167
256
 
@@ -245,7 +334,7 @@ EOS
245
334
 
246
335
  #------------------------------------------------------------------------------
247
336
  describe "Nested Hash" do
248
- before(:each) do
337
+ before do
249
338
  @hash = {}
250
339
  @hash[:a] = @hash
251
340
  end
@@ -265,7 +354,7 @@ EOS
265
354
 
266
355
  #------------------------------------------------------------------------------
267
356
  describe "Hash with several keys" do
268
- before(:each) do
357
+ before do
269
358
  @hash = {"b" => "b", :a => "a", :z => "z", "alpha" => "alpha"}
270
359
  end
271
360
 
@@ -290,7 +379,7 @@ EOS
290
379
  end
291
380
 
292
381
  it "plain multiline with sorted keys" do
293
- @hash.ai(:plain => true, :sorted_hash_keys => true).should == <<-EOS.strip
382
+ @hash.ai(:plain => true, :sort_keys => true).should == <<-EOS.strip
294
383
  {
295
384
  :a => "a",
296
385
  "alpha" => "alpha",
@@ -304,17 +393,58 @@ EOS
304
393
 
305
394
  #------------------------------------------------------------------------------
306
395
  describe "Negative options[:indent]" do
307
- before(:each) do
308
- @hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
396
+ #
397
+ # With Ruby < 1.9 the order of hash keys is not defined so we can't
398
+ # reliably compare the output string.
399
+ #
400
+ it "hash keys must be left aligned" do
401
+ hash = { [0, 0, 255] => :yellow, :red => "rgb(255, 0, 0)", "magenta" => "rgb(255, 0, 255)" }
402
+ out = hash.ai(:plain => true, :indent => -4, :sort_keys => true)
403
+ out.should == <<-EOS.strip
404
+ {
405
+ [ 0, 0, 255 ] => :yellow,
406
+ "magenta" => "rgb(255, 0, 255)",
407
+ :red => "rgb(255, 0, 0)"
408
+ }
409
+ EOS
309
410
  end
310
411
 
311
- it "hash keys must be left aligned" do
312
- out = @hash.ai(:plain => true, :indent => -4)
313
- out.start_with?("{\n").should == true
314
- out.include?(' :red => "rgb(255, 0, 0)"').should == true
315
- out.include?(' "magenta" => "rgb(255, 0, 255)"').should == true
316
- out.include?(' [ 0, 0, 255 ] => :yellow').should == true
317
- out.end_with?("\n}").should == true
412
+ it "nested hash keys should be indented (array of hashes)" do
413
+ arr = [ { :a => 1, :bb => 22, :ccc => 333}, { 1 => :a, 22 => :bb, 333 => :ccc} ]
414
+ out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
415
+ out.should == <<-EOS.strip
416
+ [
417
+ [0] {
418
+ :a => 1,
419
+ :bb => 22,
420
+ :ccc => 333
421
+ },
422
+ [1] {
423
+ 1 => :a,
424
+ 22 => :bb,
425
+ 333 => :ccc
426
+ }
427
+ ]
428
+ EOS
429
+ end
430
+
431
+ it "nested hash keys should be indented (hash of hashes)" do
432
+ arr = { :first => { :a => 1, :bb => 22, :ccc => 333}, :second => { 1 => :a, 22 => :bb, 333 => :ccc} }
433
+ out = arr.ai(:plain => true, :indent => -4, :sort_keys => true)
434
+ out.should == <<-EOS.strip
435
+ {
436
+ :first => {
437
+ :a => 1,
438
+ :bb => 22,
439
+ :ccc => 333
440
+ },
441
+ :second => {
442
+ 1 => :a,
443
+ 22 => :bb,
444
+ 333 => :ccc
445
+ }
446
+ }
447
+ EOS
318
448
  end
319
449
  end
320
450
 
@@ -363,7 +493,7 @@ EOS
363
493
  #------------------------------------------------------------------------------
364
494
  describe "Utility methods" do
365
495
  it "should merge options" do
366
- ap = AwesomePrint.new
496
+ ap = AwesomePrint::Inspector.new
367
497
  ap.send(:merge_options!, { :color => { :array => :black }, :indent => 0 })
368
498
  options = ap.instance_variable_get("@options")
369
499
  options[:color][:array].should == :black
@@ -374,7 +504,7 @@ EOS
374
504
 
375
505
  #------------------------------------------------------------------------------
376
506
  describe "Struct" do
377
- before(:each) do
507
+ before do
378
508
  @struct = unless defined?(Struct::SimpleStruct)
379
509
  Struct.new("SimpleStruct", :name, :address).new
380
510
  else
@@ -455,6 +585,15 @@ EOS
455
585
  weird.new.ai(:plain => true).should == ''
456
586
  end
457
587
 
588
+ it "handle frozen object.inspect" do
589
+ weird = Class.new do
590
+ def inspect
591
+ "ice".freeze
592
+ end
593
+ end
594
+ weird.new.ai(:plain => false).should == "ice"
595
+ end
596
+
458
597
  # See https://github.com/michaeldv/awesome_print/issues/35
459
598
  it "handle array grep when pattern contains / chapacter" do
460
599
  hash = { "1/x" => 1, "2//x" => :"2" }
@@ -481,9 +620,20 @@ EOS
481
620
  markup.ai(:html => true, :plain => true).should == "<pre>#{markup}</pre>"
482
621
  end
483
622
 
484
- it "wraps ap output with colorized <pre> tag" do
623
+ it "wraps ap output with <pre> tag with colorized <kbd>" do
485
624
  markup = rand
486
- markup.ai(:html => true).should == %Q|<pre style="color:blue">#{markup}</pre>|
625
+ markup.ai(:html => true).should == %Q|<pre><kbd style="color:blue">#{markup}</kbd></pre>|
626
+ end
627
+
628
+ it "wraps multiline ap output with <pre> tag with colorized <kbd>" do
629
+ markup = [ 1, :two, "three" ]
630
+ markup.ai(:html => true).should == <<-EOS.strip
631
+ <pre>[
632
+ <kbd style="color:white">[0] </kbd><pre><kbd style="color:blue">1</kbd></pre>,
633
+ <kbd style="color:white">[1] </kbd><pre><kbd style="color:darkcyan">:two</kbd></pre>,
634
+ <kbd style="color:white">[2] </kbd><pre><kbd style="color:brown">&quot;three&quot;</kbd></pre>
635
+ ]</pre>
636
+ EOS
487
637
  end
488
638
 
489
639
  it "encodes HTML entities (plain)" do
@@ -493,7 +643,7 @@ EOS
493
643
 
494
644
  it "encodes HTML entities (color)" do
495
645
  markup = ' &<hello>'
496
- markup.ai(:html => true).should == '<pre style="color:brown">&quot; &amp;&lt;hello&gt;&quot;</pre>'
646
+ markup.ai(:html => true).should == '<pre><kbd style="color:brown">&quot; &amp;&lt;hello&gt;&quot;</kbd></pre>'
497
647
  end
498
648
  end
499
649