Commit cdec9e47 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Replace \n to <br>

parent 46de0366
...@@ -33,8 +33,10 @@ class CiBuild ...@@ -33,8 +33,10 @@ class CiBuild
url: build_url + "/trace.json?state=" + encodeURIComponent(@state) url: build_url + "/trace.json?state=" + encodeURIComponent(@state)
dataType: "json" dataType: "json"
success: (log) => success: (log) =>
if last_state is @state and log.status is "running" return unless last_state is @state
@state = if log.state then log.state else ""
if log.state and log.status is "running"
@state = log.state
if log.append if log.append
$('.fa-refresh').before log.html $('.fa-refresh').before log.html
else else
......
...@@ -90,7 +90,7 @@ module Ci ...@@ -90,7 +90,7 @@ module Ci
def convert(raw, new_state) def convert(raw, new_state)
reset_state reset_state
restore_state(raw, new_state) if new_state restore_state(raw, new_state) if new_state.present?
start = @offset start = @offset
ansi = raw[@offset..-1] ansi = raw[@offset..-1]
...@@ -105,6 +105,8 @@ module Ci ...@@ -105,6 +105,8 @@ module Ci
break break
elsif s.scan(/</) elsif s.scan(/</)
@out << '&lt;' @out << '&lt;'
elsif s.scan(/\n/)
@out << '<br>'
else else
@out << s.scan(/./m) @out << s.scan(/./m)
end end
......
...@@ -175,5 +175,14 @@ describe Ci::Ansi2html, lib: true do ...@@ -175,5 +175,14 @@ describe Ci::Ansi2html, lib: true do
it_behaves_like 'stateable converter' it_behaves_like 'stateable converter'
end end
context 'with new line' do
let(:pre_text) { "Hello\r" }
let(:pre_html) { "Hello\r" }
let(:text) { "\nWorld" }
let(:html) { "<br>World" }
it_behaves_like 'stateable converter'
end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment