From b73f46bb76d681f44394c4d7946aa0580c6c3f45 Mon Sep 17 00:00:00 2001 From: hhaensel Date: Thu, 31 Oct 2024 09:18:40 +0100 Subject: [PATCH] correctly handle JSONText in join_js() and other cases --- src/stipple/rendering.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/stipple/rendering.jl b/src/stipple/rendering.jl index 5925e628..156d078c 100644 --- a/src/stipple/rendering.jl +++ b/src/stipple/rendering.jl @@ -39,7 +39,7 @@ julia> join_js([1, f, "2 "], " - ", pre = strip) "1 - hi - 2" ``` """ -function join_js(xx, delim = ""; skip_empty = true, pre::Function = identity, strip_delimiter = true, pre_delim::Union{Function,Nothing} = nothing) +function join_js(xx::Union{Tuple, AbstractArray}, delim = ""; skip_empty = true, pre::Function = identity, strip_delimiter = true, pre_delim::Union{Function,Nothing} = nothing) io = IOBuffer() firstrun = true s_delim = pre_delim === nothing ? pre(delim) : pre_delim(delim) @@ -67,9 +67,9 @@ function join_js(xx, delim = ""; skip_empty = true, pre::Function = identity, st String(take!(io)) end -join_js(s::AbstractString, delim = ""; kwargs...) = join_js([s], delim; kwargs...) -join_js(p::Pair, delim = ""; kwargs...) = join_js([p], delim; kwargs...) -join_js(f::Base.Callable, delim = ""; kwargs...) = join_js([f], delim; kwargs...) +function join_js(x, delim = ""; skip_empty = true, pre::Function = identity, strip_delimiter = true, pre_delim::Union{Function,Nothing} = nothing) + join_js([x], delim; skip_empty, pre, strip_delimiter, pre_delim) +end const RENDERING_MAPPINGS = Dict{String,String}() mapping_keys() = collect(keys(RENDERING_MAPPINGS))