Skip to content

Colored output in the playground console? #407

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
gendx opened this issue Feb 14, 2023 · 1 comment
Open

Colored output in the playground console? #407

gendx opened this issue Feb 14, 2023 · 1 comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@gendx
Copy link
Collaborator

gendx commented Feb 14, 2023

One selling point of the Rust compiler is colorful error messages that point directly to the problem. However, the embedded playground doesn't illustrate that, because everything becomes monochrome.

While running the course, I occasionally switched to presenting my terminal to illustrate that, but this required some back-and-forth to present a different window, copy-paste the code, run Cargo, etc. This slowed down the course, so I rarely did that.

In principle, there could be a way to take cargo/rustc's colored output, and turn it into suitable HTML/CSS to display the colors in the embedded "console" as well.

@mgeisler
Copy link
Collaborator

Yes, I would love to have color output in the playground — the output is probably without color because the compiler detects that stdout is not connected to a terminal. A simple CARGO_TERM_COLOR=always (or the equivalent for rustc) would probably help here. We would then need to translate the ANSI color codes to HTML, but there are libraries for that.

The issues here is related to rust-lang/rust-playground#879, though that issue seems to be mostly about allowing the programs to output colored text. I created rust-lang/rust-playground#900 upstream to track the issue of keeping colors in the compiler error messages.

@mgeisler mgeisler added the good first issue Good for newcomers label Feb 19, 2023
@mgeisler mgeisler added the help wanted Extra attention is needed label Aug 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants