Is there a way to colour part of a string in e.g. @info
? similar to what Crayons or printstyled
does.
I’d like to do something like:
information = "some info"
@info "A string with $(highlight(information))"
thanks in advance
Is there a way to colour part of a string in e.g. @info
? similar to what Crayons or printstyled
does.
I’d like to do something like:
information = "some info"
@info "A string with $(highlight(information))"
thanks in advance
You can use printstyled
function highlight(s, colour)
io = IOBuffer()
printstyled(IOContext(io, :color => true), s, color = colour)
return io |> take! |> String
end
wonderful, thank you