-
-
Notifications
You must be signed in to change notification settings - Fork 13
Closed
Description
First of all, thanks for the addition of StyledStrings to the standard library, looks fantastic!
While trying it out, I found a possible unexpected behavior.
As I would expect, the styled string str1 = styled"{yellow:is this {blue:blue or yellow}}"
prints yellow for "is this " and blue for "blue or yellow". However, str2 = styled"{yellow:{blue:blue or yellow}}"
prints yellow while I would expect it to print blue.
Is this expected?
Extra info in case it helps:
julia> sprint(print, str1, context = :color => true)
"\e[33mis this \e[34mblue or yellow\e[39m"
julia> sprint(print, str2, context = :color => true)
"\e[33mblue or yellow\e[39m"
and
julia> Base.annotations(str1)
2-element Vector{Tuple{UnitRange{Int64}, Pair{Symbol, Any}}}:
(1:22, :face => :yellow)
(9:22, :face => :blue)
julia> Base.annotations(str2)
2-element Vector{Tuple{UnitRange{Int64}, Pair{Symbol, Any}}}:
(1:14, :face => :blue)
(1:14, :face => :yellow)
it looks like the order of the annotations in the second case wasn't set properly?
versioninfo:
julia> versioninfo()
Julia Version 1.11.0-alpha2
Commit 9dfd28ab751 (2024-03-18 20:35 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
WORD_SIZE: 64
LLVM: libLLVM-16.0.6 (ORCJIT, tigerlake)
Threads: 1 default, 0 interactive, 1 GC (on 8 virtual cores)
Environment:
JULIA_PROJECT = @.
I installed Julia using juliaup
.
Metadata
Metadata
Assignees
Labels
No labels