Remove trailing newline in captured outputs (#111)

* Remove trailing newline in captured outputs

* Use String.replace_suffix/3
This commit is contained in:
Jonatan Kłosko 2021-03-23 14:43:16 +01:00 committed by GitHub
parent af79a0fd2f
commit ad99680a82
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -222,6 +222,9 @@ defmodule LivebookWeb.CellComponent do
end
defp render_output(output, id) when is_binary(output) do
# Captured output usually has a trailing newline that we can ignore,
# because each line is itself a block anyway.
output = String.replace_suffix(output, "\n", "")
lines = ansi_to_html_lines(output)
assigns = %{lines: lines, id: id}