Skip to content
Browse files

Switched to ANSI bold red from backspace formatting (which does not w…

…ork on my terminal
  • Loading branch information...
1 parent b235ce2 commit 5c9314e3499ddf0f8422236a79ee65cf6cb218fb @drbrain drbrain committed
Showing with 21 additions and 6 deletions.
  1. +5 −2 lib/rdoc/generator/spellcheck.rb
  2. +16 −4 test/test_rdoc_generator_spellcheck.rb
View
7 lib/rdoc/generator/spellcheck.rb
@@ -34,6 +34,7 @@ def self.setup_options options
default_language, = ENV['LANG'].split '.'
options.spell_language = default_language
+ options.quiet = true # suppress statistics
op = options.option_parser
@@ -172,11 +173,13 @@ def suggestion_text text, word, offset
before = "#{prefix.zero? ? nil : '...'}#{$1}"
after = "#{$2}#{$2.length < 10 ? nil : '...'}"
- underline = word.chars.map { |char| "_\b#{char}" }.join
+
+ highlight = "\e[1;31m#{word}\e[m"
+
suggestions = @spell.suggest(word).first 5
<<-TEXT
-"#{before}#{underline}#{after}"
+"#{before}#{highlight}#{after}"
"#{word}" suggestions:
\t#{suggestions.join ', '}
View
20 test/test_rdoc_generator_spellcheck.rb
@@ -31,6 +31,18 @@ def test_class_setup_options_default
assert_equal 'en_US', options.spell_language
end
+ def test_class_setup_options_default
+ orig_lang = ENV['LANG']
+ ENV['LANG'] = 'en_US.UTF-8'
+
+ options = RDoc::Options.new
+
+ options.parse %w[--format spellcheck]
+
+ assert_equal 'en_US', options.spell_language
+ assert options.quiet
+ end
+
def test_class_setup_options_spell_language
options = RDoc::Options.new
@@ -215,7 +227,7 @@ def test_suggestion_text
suggestions = suggest('gud').join ', '
expected = <<-EXPECTED
-"...has real _\bg_\bu_\bd spelling!..."
+"...has real \e[1;31mgud\e[m spelling!..."
"gud" suggestions:
\t#{suggestions}
@@ -231,7 +243,7 @@ def test_suggestion_text_end
suggestions = suggest('gud').join ', '
expected = <<-EXPECTED
-"...did real _\bg_\bu_\bd"
+"...did real \e[1;31mgud\e[m"
"gud" suggestions:
\t#{suggestions}
@@ -248,7 +260,7 @@ def test_suggestion_text_newline
suggestions = suggest('secnd').join ', '
expected = <<-EXPECTED
-"...o\non the _\bs_\be_\bc_\bn_\bd line"
+"...o\non the \e[1;31msecnd\e[m line"
"secnd" suggestions:
\t#{suggestions}
@@ -264,7 +276,7 @@ def test_suggestion_text_start
suggestions = suggest('gud').join ', '
expected = <<-EXPECTED
-"_\bg_\bu_\bd night wor..."
+"\e[1;31mgud\e[m night wor..."
"gud" suggestions:
\t#{suggestions}

0 comments on commit 5c9314e

Please sign in to comment.
Something went wrong with that request. Please try again.