diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-02 00:32:30 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-02-02 00:32:30 +0000 |
commit | cc2a16d94d744d14d4a5eb06eca22137f8a9b79e (patch) | |
tree | 2907a20e2d9ae3a2831707056bb3fe2d384b066d /lib/rdoc/text.rb | |
parent | 918f625a5eeba35b9b191cb39c1d634b4cc7efee (diff) |
Import RDoc 3.5.1
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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 ## |