From c34d4e950e71ac812b3929a7bca3bbfd018f27a9 Mon Sep 17 00:00:00 2001 From: t-bltg Date: Sat, 1 Jan 2022 10:35:55 +0100 Subject: [PATCH] UnicodePlots: fix ansi regex --- src/backends/unicodeplots.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index eb75484b..5f9314d2 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -209,7 +209,7 @@ function _show(io::IO, ::MIME"text/plain", plt::Plot{UnicodePlotsBackend}) i < n && println(io) end else - re_col = r"\e\[[0-9;]*m" # m: color, [a-zA-Z]: all escape sequences + re_ansi = r"\e\[[0-9;]*[a-zA-Z]" # m: color, [a-zA-Z]: all escape sequences have_color = Base.get_have_color() buf = IOContext(PipeBuffer(), :color => have_color) lines_colored = Array{Union{Nothing,Vector{String}}}(undef, nr, nc) @@ -232,7 +232,7 @@ function _show(io::IO, ::MIME"text/plain", plt::Plot{UnicodePlotsBackend}) colored = read(buf, String) lines_colored[r, c] = lu = lc = split(colored, '\n') if have_color - uncolored = replace(colored, re_col => '\0') + uncolored = replace(colored, re_ansi => "") lines_uncolored[r, c] = lu = split(uncolored, '\n') end lmax = max(length(lc), lmax)