Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix highlighting of keyword defined? in Ruby #1247

Merged
merged 3 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/rouge/lexers/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
29 changes: 29 additions & 0 deletions spec/visual/samples/ruby
Original file line number Diff line number Diff line change
Expand Up @@ -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:
########
Expand Down