From 07602979a557ec8ddd2c41b8eaee7d13815ea8e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20VA=CC=86LCIU?= Date: Sat, 14 Apr 2018 20:42:54 +0300 Subject: [PATCH 1/2] Fix issue #860: sed addresses that use custom delimiter. --- lib/rouge/lexers/sed.rb | 2 +- spec/lexers/sed_spec.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) 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..015d1cb8f1 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 (issue #860)' do + assert_tokens_equal '\#foobar#n', + ['Keyword.Namespace', '\#'], + ['Literal.String.Regex', 'foobar'], + ['Keyword.Namespace', '#'], + ['Keyword', 'n'] + end + end end From 3915003ee3cf89f6492b4276bb3b2fe710441c7f Mon Sep 17 00:00:00 2001 From: Michael Camilleri Date: Sat, 3 Aug 2019 06:41:27 +0900 Subject: [PATCH 2/2] Remove reference to issue --- spec/lexers/sed_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lexers/sed_spec.rb b/spec/lexers/sed_spec.rb index 015d1cb8f1..9ae212be55 100644 --- a/spec/lexers/sed_spec.rb +++ b/spec/lexers/sed_spec.rb @@ -23,7 +23,7 @@ describe 'lexing' do include Support::Lexing - it 'parses regex addresses with custom delimiter (issue #860)' do + it 'parses regex addresses with custom delimiter' do assert_tokens_equal '\#foobar#n', ['Keyword.Namespace', '\#'], ['Literal.String.Regex', 'foobar'],