petersolopov / carbonara

API for carbon
MIT License
125 stars 32 forks source link

Code Snippet Does Not Recognize Python Comments #22

Closed danieljbk closed 2 years ago

danieljbk commented 2 years ago

main

danieljbk commented 2 years ago

I am sending the code, turned into text and transferred to JSON, through a HTTP POST request. I don't understand why this does not result in a perfectly normal code preview.

petersolopov commented 2 years ago

Hi! If you open carbon url with python code snippet you will see the same result (check it). Comment is not recognized. Then if you start typing you will see correctly highlighting is appeared. It's some tricky behavior of carbon and auto highlighting. You can open the issue in the corresponding repository.

Fortunately, there is a workaround for api: you should explicitly pass the language option:

curl -L https://carbonara-42.herokuapp.com/api/cook \
-X POST \
-H 'Content-Type: application/json' \
-d '{
      "code": "# comment\nprint('\''Hello, world!'\'')",
      "language": "python" 
    }' \
> code.png