diff options
Diffstat (limited to 'lib/rdoc/text.rb')
-rw-r--r-- | lib/rdoc/text.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb index 20cd8a258a..6dec4217e6 100644 --- a/lib/rdoc/text.rb +++ b/lib/rdoc/text.rb @@ -97,7 +97,8 @@ module RDoc::Text text = strip_hashes text text = expand_tabs text text = flush_left text - strip_newlines text + text = strip_newlines text + text end ## @@ -139,14 +140,18 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse def strip_hashes text return text if text =~ /^(?>\s*)[^\#]/ - text.gsub(/^\s*(#+)/) { $1.tr '#',' ' }.gsub(/^\s+$/, '') + + empty = '' + empty.force_encoding text.encoding if Object.const_defined? :Encoding + + text.gsub(/^\s*(#+)/) { $1.tr '#', ' ' }.gsub(/^\s+$/, empty) end ## # Strips leading and trailing \n characters from +text+ def strip_newlines text - text.gsub(/\A\n*(.*?)\n*\z/m, '\1') + text.gsub(/\A\n*(.*?)\n*\z/m) do $1 end # block preserves String encoding end ## |