JuliaDB.jl
JuliaDB.jl copied to clipboard
Show methods print colour codes
Table with 8279 rows, 2 columns:
Columns:
[1m# [22m[1mcolname [22mtype
──────────────────
1 1 String
2 2 String
This comes up in Juno, for example, where we show to a string to display in-editor. Should check if the IO stream is for a terminal or not.
Any idea how to do this?
maybe something like this: print_with_color(:blue, "Hello world\n")
Jupyter converts these escape sequences to HTML! Maybe Juno should too as a long term solution.
@Mirage10 I think mike doesn't want any escape chars.
Good idea. cc @pfitzseb
On it.
AFAIK this should only happen when Julia is started with --color=yes, so there shouldn't be any problems with Juno release.
Should be fixed with https://github.com/JunoLab/atom-ink/pull/155/commits/f32c69f851e90a03a86250ecd5210dd735baee1d, but I can't reproduce the initial example.
Hey @pfitzseb what state is this in right now? Is it possible for JuliaDB to detect a non-terminal output and not use escaping?
It's actually not only a problem of Juno/Atom. It also occurs when generating docs from Weave/Documenter (or when exporting a notebook to markdown): would the same fix work there too?
Juno is correctly interpreting those ANSI escape codes now, so they shouldn't show up in our output anymore.
I'm not entirely sure how it's possible to figure out whether a given display supports colored output -- unless I'm misunderstanding Base's display system, that's not really possible without custom mime types. Sure, show supports an IOContext as it's first argument, and that can define :color => true (or not), but that is mostly disconnected from display except for the mimetype.