diff options
Diffstat (limited to 'lib/rdoc/parser.rb')
-rw-r--r-- | lib/rdoc/parser.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 425bc48632..425105effa 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -125,9 +125,11 @@ class RDoc::Parser return parser if ext_name.empty? if parser == RDoc::Parser::Simple and ext_name !~ /txt|rdoc/ then - case check_modeline file_name + case mode = check_modeline(file_name) when nil, 'rdoc' then # continue - else return nil + else + RDoc::Parser.parsers.find { |_, p| return p if mode.casecmp?(p.name[/\w+\z/]) } + return nil end end @@ -263,9 +265,26 @@ class RDoc::Parser @preprocess.options = @options end - autoload :RubyTools, 'rdoc/parser/ruby_tools' - autoload :Text, 'rdoc/parser/text' + autoload :RubyTools, "#{__dir__}/parser/ruby_tools" + autoload :Text, "#{__dir__}/parser/text" + ## + # Normalizes tabs in +body+ + + def handle_tab_width(body) + if /\t/ =~ body + tab_width = @options.tab_width + body.split(/\n/).map do |line| + 1 while line.gsub!(/\t+/) do + b, e = $~.offset(0) + ' ' * (tab_width * (e-b) - b % tab_width) + end + line + end.join "\n" + else + body + end + end end # simple must come first in order to show up last in the parsers list |