diff --git a/lib/rouge/lexers/ruby.rb b/lib/rouge/lexers/ruby.rb index 5f07cc3728..e76a4742d1 100644 --- a/lib/rouge/lexers/ruby.rb +++ b/lib/rouge/lexers/ruby.rb @@ -183,7 +183,7 @@ def self.detect?(text) mixin :strings - rule %r/(?:#{keywords.join('|')})\b/, Keyword, :expr_start + rule %r/(?:#{keywords.join('|')})(?=\W|$)/, Keyword, :expr_start rule %r/(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start rule %r( diff --git a/spec/visual/samples/ruby b/spec/visual/samples/ruby index ad4604aef9..2e6b59befd 100644 --- a/spec/visual/samples/ruby +++ b/spec/visual/samples/ruby @@ -49,6 +49,35 @@ a/ b #comment x.a / 1 # comment Foo::a / 3 + 4 +######## +# Keywords that may be immediately followed by an opening +# parenthesis +######## + +# defined? +return if defined? Rouge +return unless defined?(Foobar) + +# super +class Beta < Alpha + def gamma(msg) + super + @msg = msg + end +end + +class Bar < Foo + def log(msg) + super() + end +end + +class Ipsum < Lorem + def dolor(txt) + super(txt) + end +end + ######## # The popular . :bow: ########