From ad99680a8265d908a4632800ca705a6d4a6453b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonatan=20K=C5=82osko?= Date: Tue, 23 Mar 2021 14:43:16 +0100 Subject: [PATCH] Remove trailing newline in captured outputs (#111) * Remove trailing newline in captured outputs * Use String.replace_suffix/3 --- lib/livebook_web/live/cell_component.ex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/livebook_web/live/cell_component.ex b/lib/livebook_web/live/cell_component.ex index b6c06f21e..55e2948dd 100644 --- a/lib/livebook_web/live/cell_component.ex +++ b/lib/livebook_web/live/cell_component.ex @@ -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}