19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/ansible/output.rb', line 19
def self.to_html(line, stream='')
s = StringScanner.new(ERB::Util.h line)
while(!s.eos?)
if s.scan(/\e\[([0-1])?[;]?(3[0-7]|90|1)m/)
bold, colour = s[1], s[2]
styles = []
styles << COLOR[bold] if bold.to_i == 1
styles << COLOR[colour]
span =
if styles.compact.empty?
%{<span>}
else
%{<span style="#{styles*'; '};">}
end
stream << span
elsif s.scan(/\e\[0m/)
stream << %{</span>}
elsif s.scan(/\e\[[^0]*m/)
stream << '<span>'
else
stream << s.scan(/./m)
end
end
stream
end
|