summaryrefslogtreecommitdiff
path: root/lib/rdoc/text.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-07 22:23:38 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-09-07 22:23:38 +0000
commitba6ae341bab83dfc7a624c5bf20d8d162dacaff9 (patch)
tree540581a54cefcdc817577f646f09372f7e9936d1 /lib/rdoc/text.rb
parentbf51c067b92361007a57909c539591d3d00cdbd8 (diff)
* lib/rdoc/*, test/rdoc/*: Update rdoc-5.0.0.beta2
Fixed ri parse defect with left-hand matched classes. https://github.com/rdoc/rdoc/pull/420 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/text.rb')
-rw-r--r--lib/rdoc/text.rb29
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