diff --git a/lib/rouge/lexers/sed.rb b/lib/rouge/lexers/sed.rb index d6e570ba26..b3efe50df5 100644 --- a/lib/rouge/lexers/sed.rb +++ b/lib/rouge/lexers/sed.rb @@ -141,7 +141,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] diff --git a/spec/lexers/sed_spec.rb b/spec/lexers/sed_spec.rb index 9223ffcaa7..9ae212be55 100644 --- a/spec/lexers/sed_spec.rb +++ b/spec/lexers/sed_spec.rb @@ -19,4 +19,16 @@ assert_guess :source => '#!/usr/bin/sed' end end + + describe 'lexing' do + include Support::Lexing + + it 'parses regex addresses with custom delimiter' do + assert_tokens_equal '\#foobar#n', + ['Keyword.Namespace', '\#'], + ['Literal.String.Regex', 'foobar'], + ['Keyword.Namespace', '#'], + ['Keyword', 'n'] + end + end end