Skip to content

Commit

Permalink
Highlight Ruby's and/or/not logical operators (#1950)
Browse files Browse the repository at this point in the history
* Highlight Ruby's and/or/not logical operators

* Use Operator.Word token for Ruby's and/or/not operators
  • Loading branch information
epidemian committed May 15, 2023
1 parent 96b11b5 commit c745bb8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rouge/lexers/ruby.rb
Expand Up @@ -188,6 +188,7 @@ def self.detect?(text)

rule %r/(?:#{keywords.join('|')})(?=\W|$)/, Keyword, :expr_start
rule %r/(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
rule %r/(not|and|or)\b/, Operator::Word, :expr_start

rule %r(
(module)
Expand Down
5 changes: 5 additions & 0 deletions spec/visual/samples/ruby
Expand Up @@ -277,6 +277,11 @@ puts [[x%w].reverse]
def x(s) puts x end
x %w].]

# wordy logical operators
5.prime? or fail "something is terribly wrong"
chip = Bag.find_potato and chip.eat!
puts "odd" if not num % 2 == 0

##################################################################
# HEREDOCS
<<-CONTENT.strip_heredoc
Expand Down

0 comments on commit c745bb8

Please sign in to comment.