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

Issue with "\" in content #44

Open
Jakabi107 opened this issue May 7, 2023 · 2 comments
Open

Issue with "\" in content #44

Jakabi107 opened this issue May 7, 2023 · 2 comments

Comments

@Jakabi107
Copy link

Jakabi107 commented May 7, 2023

I've wanted to display my own logo (banner) in my project usage, yet it couldn't handle the "\"-characters properly.

Now I took the banner example from your Wiki and changed the previous logo with mine.

just removed const chalk = require('chalk') and replaced chalk.red( ... ) with header

code

Screenshot 2023-05-07 at 15 33 12

The problem is - when I execute it:

green is a normal console.log() and normal is the one generated.

result

Screenshot 2023-05-07 at 15 42 18

The banner is made with String.raw, so every "\" is replaced with "\\", that means it is written by eg. console.log(). Yet the libary does skip them anyway.
I brute forced a little bit and found out it takes 4 or in String.raw 2 (2*2) "\" to write one into the usage.
Maybe the formater refactors between strings and deletes some "\" or delets them by some replace functions?

EDIT:

Quick fix for users:
use Straing.raw methode as explained above and append .replaceAll("\\","\\\\") at the End.

File: test.js.zip

Hope I could help,
Jakabi

@75lb
Copy link
Owner

75lb commented May 8, 2023

The code you supplied in the zip file works correctly for me in both iTerm2 and Terminal on the mac, I think the issue is with your terminal.. Please try it in a few different terminals then let me know which terminals fail on which operating systems - thanks.

Screenshot 2023-05-08 at 10 04 39

@Jakabi107
Copy link
Author

Jakabi107 commented May 8, 2023

Just realised send you the wrong file...
I already fixed it in this one😕
I'm very sorry.

real file test.js.zip

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

No branches or pull requests

2 participants