As @Stefan wrote in the comment, probably you should use an HTML <pre>
tag instead, or CSS white-space: pre
directive on a non-pre element. Anyway:
$stderr.print
:
def $stderr.print(*args)
super *args.map { |v| v.to_s.gsub("\n", "<br>") }
end
$stderr.print "ciao\n" #=> nil
ciao<br>
$stderr.puts
:
def $stderr.puts(*args)
print *args.map { |v| v.to_s + "\n" }
end
$stderr.puts "ciao" #=> nil
ciao<br>