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

Specific Characters Inhibiting Bash Script from Generating Previews #16

Closed
danieljbk opened this issue Aug 1, 2021 · 1 comment
Closed

Comments

@danieljbk
Copy link

I am reading the content of my code files and storing it inside a variable. Then, I am using the variable inside the bash script to create a preview with the code.

However, as I am manually executing the bash script from inside of my script, specific characters included in my code files are hindering the bash script to execute/complete. This is resulting in corrupted, unopenable .png files.

And sometimes, characters in the file name are prohibiting the bash script from executing. Spaces in the name caused this issue. I believe numbers also were a problem. I am not exactly sure.

The temporary solution I came up with is to use lookalike Unicode characters. However, this causes another issue, as the API cannot interpret the characters to mean what they are supposed to mean, and the coloring is ruined.

Therefore, I am currently left with a script that succeeds 50% of the time yet still produces wrong previews.

The specific characters that causes issues for me are:

  • {
  • }
  • "
  • '
  • (
  • )
  • /

If I had found all of the characters, my script would be executing with a higher successful rate. As I am not educated about using bash, I was unable to identify the additional characters that were causing issues.

In addition, as I am reading the content of my code, the actual typed out newlines '\n' are getting mixed up with the interpreted newlines (actually pressing enter).

@petersolopov
Copy link
Owner

It works fine in terminal:

curl -L https://carbonara.vercel.app/api/cook \
-X POST \
-H 'Content-Type: application/json' \
-d '{
      "code": "first line {}()\"\nsecond line"
    }' \
> code.png

But some of characters need to escape. With backslash in my case.

I think you should use some python libs for HTTP requests instead invoke bash inside your python script. Anyway, it is not about carbonara-api.

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