Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to properly format code in a GitHub comment

I’m having an hard time trying to insert code in a GitHub comment.

This:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

becomes this:

enter image description here

and this:

enter image description here

becomes this:

enter image description here

I’m astonished to have such a problems in a website specialized in collaborating (thus discussing) on programming code.

What’s the solution?

>Solution :

You keep trying to use single-line (also known as inline) markdown code syntax:

my code is `print("hello, world")`

While you should be using the multi-line variant:

    my code is:
    ```
    def foo():
        print("hello, world")
    ```

Read up about Markdown here.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading