Skip to content

Commit

Permalink
Fix issue rouge-ruby#860: sed addresses that use custom delimiter.
Browse files Browse the repository at this point in the history
  • Loading branch information
axiac committed Apr 14, 2018
1 parent a58789a commit cdcd8fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rouge/lexers/sed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def replacement
end

# alternate regex rage delimiters
rule %r((\\)(.)(\\.|.)*?(\2)) do |m|
rule %r((\\)(.)((?:\\.|.)*?)(\2)) do |m|
token addr_tok, m[1] + m[2]
delegate regex, m[3]
token addr_tok, m[4]
Expand Down
12 changes: 12 additions & 0 deletions spec/lexers/sed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@
assert_guess :source => '#!/usr/bin/sed'
end
end

describe 'lexing' do
include Support::Lexing

it 'parses regex addresses with custom delimiter (issue #860)' do
assert_tokens_equal '\#foobar#n',
['Keyword.Namespace', '\#'],
['Literal.String.Regex', 'foobar'],
['Keyword.Namespace', '#'],
['Keyword', 'n']
end
end
end

0 comments on commit cdcd8fd

Please sign in to comment.