fonsp / Pluto.jl

🎈 Simple reactive notebooks for Julia
https://plutojl.org/
MIT License
4.91k stars 284 forks source link

IOContext not properly set for `stdout`, disables ANSI colors #2823

Open danielwe opened 4 months ago

danielwe commented 4 months ago

Since #2148 the stdout capture window supports ANSI terminal colors, and :color => true is set in default_stdout_iocontext as seen here:

https://github.com/fonsp/Pluto.jl/blob/216451c3c839d1c3c6c50a0b69ba1b8297cceb43/src/runner/PlutoRunner/src/PlutoRunner.jl#L1007-L1012

However, when querying stdout in a Pluto cell, :color is set to false, so well-behaved Julia code will not print colors. MWE: printstyled("hello"; color=:red). A workaround is to wrap stdout in your own IOContext and set :color => true, but this should not be necessary.

image (Please take this screenshot in place of a video. Nothing dynamic here.)

Notebook file: https://gist.github.com/danielwe/0663e49fbfb2219b2230d3fe2092c097

Using Pluto 0.19.39 on Julia 1.10.1