diff options
Diffstat (limited to 'lib/rdoc/text.rb')
-rw-r--r-- | lib/rdoc/text.rb | 29 |
1 files changed, 7 insertions, 22 deletions
diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index b40c89806a..a38bb921ad 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -52,7 +52,7 @@ module RDoc::Text :open_squote => encode_fallback('‘', encoding, '\''), :trademark => encode_fallback('®', encoding, '(r)'), } - end if Object.const_defined? :Encoding + end ## # Transcodes +character+ to +encoding+ with a +fallback+ character. @@ -71,7 +71,7 @@ module RDoc::Text text.each_line do |line| nil while line.gsub!(/(?:\G|\r)((?:.{8})*?)([^\t\r\n]{0,7})\t/) do r = "#{$1}#{$2}#{' ' * (8 - $2.size)}" - r.force_encoding text.encoding if Object.const_defined? :Encoding + r.force_encoding text.encoding r end @@ -93,7 +93,7 @@ module RDoc::Text end empty = '' - empty.force_encoding text.encoding if Object.const_defined? :Encoding + empty.force_encoding text.encoding text.gsub(/^ {0,#{indent}}/, empty) end @@ -160,7 +160,7 @@ module RDoc::Text return text if text =~ /^(?>\s*)[^\#]/ empty = '' - empty.force_encoding text.encoding if Object.const_defined? :Encoding + empty.force_encoding text.encoding text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty) end @@ -178,7 +178,7 @@ module RDoc::Text def strip_stars text return text unless text =~ %r%/\*.*\*/%m - encoding = text.encoding if Object.const_defined? :Encoding + encoding = text.encoding text = text.gsub %r%Document-method:\s+[\w:.#=!?]+%, '' @@ -199,24 +199,9 @@ module RDoc::Text # trademark symbols in +text+ to properly encoded characters. def to_html text - if Object.const_defined? :Encoding then - html = ''.encode text.encoding + html = ''.encode text.encoding - encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding] - else - html = '' - encoded = { - :close_dquote => '”', - :close_squote => '’', - :copyright => '©', - :ellipsis => '…', - :em_dash => '—', - :en_dash => '–', - :open_dquote => '“', - :open_squote => '‘', - :trademark => '®', - } - end + encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding] s = StringScanner.new text insquotes = false |