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

Simplify output for nested chalk tags #365

Closed
ExE-Boss opened this issue Sep 24, 2019 · 6 comments
Closed

Simplify output for nested chalk tags #365

ExE-Boss opened this issue Sep 24, 2019 · 6 comments

Comments

@ExE-Boss
Copy link
Contributor

ExE-Boss commented Sep 24, 2019

Currently, nested chalk tags in a template reset and re‑specify everything, instead of just what needs to be modified for that level of nesting.

Code

chalk`{red  red {bold  red & bold } red again }`

Expected result:

\e[31m red \e[1m red & bold \e[22m red again \e[39m

Actual result:

\e[31m red \e[39m\e[31m\e[1m red & bold \e[22m\e[39m\e[31m red again \e[39m

See also:

@sindresorhus
Copy link
Member

sindresorhus commented Sep 24, 2019

Yes, that would be ideal, but it's not a big problem as the visual output is still correct. PR welcome :)

@Qix-
Copy link
Member

Qix- commented Sep 25, 2019

There's somewhat a reason for this; dim and bold have the same exit code and thus added some complexity to the implementation IIRC.

Be careful that this doesn't slow everything down.

@zerefwayne
Copy link

zerefwayne commented Mar 23, 2020

@sindresorhus @Qix- Is the issue still open?

@sindresorhus
Copy link
Member

⬇️

Screenshot 2020-03-23 at 19 09 06

⬆️

@Qix-
Copy link
Member

Qix- commented Jul 15, 2021

I think this should be closed. Across all the terminal emulators that exist, with all of the different IDEs and whatnot that also try to implement this (jetbrains software, vscode, etc.) I think trying to be clever about this stuff is only going to hurt performance and break more people.

Further, I've yet to come across a case where the extra few bytes were really detrimental to performance or even on-the-wire sizes (and where completely disabling styled output wasn't also an option).

Thoughts @sindresorhus?

@sindresorhus
Copy link
Member

I agree. It's simply not worth the added complexity and risk of breakage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
@sindresorhus @Qix- @ExE-Boss @zerefwayne and others