Skip to content
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

suggestion: print styling like the Console API #23668

Open
iuioiua opened this issue May 3, 2024 · 0 comments
Open

suggestion: print styling like the Console API #23668

iuioiua opened this issue May 3, 2024 · 0 comments
Labels
suggestion suggestions for new features (yet to be agreed)

Comments

@iuioiua
Copy link
Collaborator

iuioiua commented May 3, 2024

I suggest we style printed text the same way the Console API does rather than using ANSI escape codes across the codebase. In the terminal, styling should look the same. However, the advantage is that escape codes are omitted in places where raw characters aren't handled in special ways. E.g., text files. The differences can be seen here.

console.log("%cHello world", "color: red");

produces output.txt:

Hello world

and

import { red } from "jsr:@std/fmt/colors";
console.log(red("Hello world"));

produces output.txt:

�[31mHello world�[39m

This behavior is especially cumbersome in scenarios where analyzing output is important. For example, deno test output is printed in the terminal in CI. When advanced troubleshooting is required, a user will download the logs but must deal with the clutter generated from ANSI escape codes.

Disclaimer: I'm unfamiliar with the Console API's inner workings, including how it applies styling to printed output.

Related #23316

@iuioiua iuioiua added the suggestion suggestions for new features (yet to be agreed) label May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed)
Projects
None yet
Development

No branches or pull requests

1 participant