aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/text.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rdoc/text.rb')
-rw-r--r--lib/rdoc/text.rb26
1 files changed, 20 insertions, 6 deletions
diff --git a/lib/rdoc/text.rb b/lib/rdoc/text.rb
index 501871c8df..adbc630cf1 100644
--- a/lib/rdoc/text.rb
+++ b/lib/rdoc/text.rb
@@ -46,7 +46,9 @@ module RDoc::Text
text.each_line do |line|
line.gsub!(/^(.{8}*?)([^\t\r\n]{0,7})\t/) do
- "#{$1}#{$2}#{' ' * (8 - $2.size)}"
+ r = "#{$1}#{$2}#{' ' * (8 - $2.size)}"
+ r.force_encoding text.encoding if Object.const_defined? :Encoding
+ r
end until line !~ /\t/
expanded << line
@@ -69,8 +71,11 @@ module RDoc::Text
flush = []
+ empty = ''
+ empty.force_encoding text.encoding if Object.const_defined? :Encoding
+
text.each_line do |line|
- line[/^ {0,#{indent}}/] = ''
+ line[/^ {0,#{indent}}/] = empty
flush << line
end
@@ -158,11 +163,20 @@ http://rubyforge.org/tracker/?atid=2472&group_id=627&func=browse
# Strips /* */ style comments
def strip_stars text
+ encoding = text.encoding if Object.const_defined? :Encoding
+
text = text.gsub %r%Document-method:\s+[\w:.#]+%, ''
- text.sub! %r%/\*+% do " " * $&.length end
- text.sub! %r%\*+/% do " " * $&.length end
- text.gsub! %r%^[ \t]*\*%m do " " * $&.length end
- text.gsub(/^\s+$/, '')
+
+ space = ' '
+ space.force_encoding encoding if encoding
+
+ text.sub! %r%/\*+% do space * $&.length end
+ text.sub! %r%\*+/% do space * $&.length end
+ text.gsub! %r%^[ \t]*\*%m do space * $&.length end
+
+ empty = ''
+ empty.force_encoding encoding if encoding
+ text.gsub(/^\s+$/, empty)
end
##