Skip to content

Commit

Permalink
UnicodePlots: fix ansi regex
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg authored Jan 1, 2022
1 parent b6d7bd8 commit c34d4e9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/backends/unicodeplots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit c34d4e9

Please sign in to comment.