Skip to content

Commit

Permalink
Fix string interpolation in Ruby percent literal (#1945)
Browse files Browse the repository at this point in the history
  • Loading branch information
tancnle committed Apr 30, 2023
1 parent 1e2c367 commit aa1a124
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/ruby.rb
Expand Up @@ -42,7 +42,7 @@ def self.detect?(text)
rule %r/%([rqswQWxiI])?([^\w\s])/ do |m|
open = Regexp.escape(m[2])
close = Regexp.escape(delimiter_map[m[2]] || m[2])
interp = /[rQWxI]/ === m[1]
interp = /[rQWxI]/ === m[1] || !m[1]
toktype = Str::Other

puts " open: #{open.inspect}" if @debug
Expand Down
2 changes: 2 additions & 0 deletions spec/visual/samples/ruby
Expand Up @@ -329,6 +329,8 @@ X "foo" # This is a method call, heredoc ends at the prev line

%q[haha! [nesting [rocks] ! ] ] # commeht here

%(a #{interpolation_variable} b)
%Q(a #{interpolation_variable} b)

##################################################################
class NP
Expand Down

0 comments on commit aa1a124

Please sign in to comment.