diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-02 22:52:57 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-02 22:52:57 +0000 |
commit | 488fb86a1eb3307030c8d4c0946ea080205b78f3 (patch) | |
tree | c502c54e146284d46d469d62ec03fb74574613bc /lib/rdoc | |
parent | 28f6b32e7e31017a9ca2bd5497e142a0f5ee7b7c (diff) |
* lib/rdoc/parser.rb: Improved modeline support. Patch by nobu.
* test/rdoc/test_rdoc_parser.rb: Test for above.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc')
-rw-r--r-- | lib/rdoc/parser.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/rdoc/parser.rb b/lib/rdoc/parser.rb index 1d4d0675b8..bf9ab77218 100644 --- a/lib/rdoc/parser.rb +++ b/lib/rdoc/parser.rb @@ -1,3 +1,5 @@ +# -*- coding: us-ascii -*- + ## # A parser is simple a class that subclasses RDoc::Parser and implements #scan # to fill in an RDoc::TopLevel with parsed data. @@ -157,11 +159,16 @@ class RDoc::Parser io.gets end - line =~ /-\*-(.*?)-\*-/ + /-\*-\s*(.*?\S)\s*-\*-/ =~ line return nil unless type = $1 - type.strip.downcase + if /;/ =~ type then + return nil unless /(?:\s|\A)mode:\s*([^\s;]+)/i =~ type + type = $1 + end + + type.downcase rescue ArgumentError # invalid byte sequence, etc. end |