Skip to content

Commit

Permalink
Revert empty patterns in Ruby lexer (#1624)
Browse files Browse the repository at this point in the history
The maintenance changes in #1548 resulted in updates to two rules in
the Ruby lexer, one regarding regular expression flags and the other
regarding heredoc strings. However, these patterns should not have been
changed. The change in #1548 was to prevent rules that matched an empty
string unless they contained a 'predicate' of some sort. Both rules in
the Ruby lexer contained such a predicate and so should not have been
changed. This commit fixes that error.
  • Loading branch information
pyrmont authored Nov 10, 2020
1 parent 03b91ed commit ba8096c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/rouge/lexers/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def self.detect?(text)
end

state :regex_flags do
rule %r/[mixounse]+/, Str::Regex, :pop!
rule %r/[mixounse]*/, Str::Regex, :pop!
end

# double-quoted string and symbol
Expand Down Expand Up @@ -267,7 +267,7 @@ def self.detect?(text)
end

state :test_heredoc do
rule %r/[^#\\\n]+$/ do |m|
rule %r/[^#\\\n]*$/ do |m|
tolerant, heredoc_name = @heredoc_queue.first
check = tolerant ? m[0].strip : m[0].rstrip

Expand Down

0 comments on commit ba8096c

Please sign in to comment.