Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: don't re-escape the term codes around \n #1404

Merged
merged 1 commit into from Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/rouge/formatters/terminal256.rb
Expand Up @@ -85,8 +85,8 @@ def bg

def stream_value(val, &b)
yield style_string
yield val.gsub("\n", "#{reset_string}\n#{style_string}")
.gsub("\e", "\\e")
yield val.gsub("\e", "\\e")
.gsub("\n", "#{reset_string}\n#{style_string}")
yield reset_string
end

Expand Down
5 changes: 4 additions & 1 deletion spec/lexers/escape_spec.rb
Expand Up @@ -17,10 +17,13 @@

describe 'terminal256' do
let(:formatter) { Rouge::Formatters::Terminal256.new }
let(:text) { %({ "foo": <!\e123!> }) }
let(:text) { %({ "foo": \n <!\e123!> }) }

it 'unescapes' do
assert { result =~ /\e123/ }

# shouldn't escape the term codes around \n
assert { result =~ /\n\e/ }
end
end
end