Home > front end >  How to properly format code in a GitHub comment
How to properly format code in a GitHub comment

Time:08-05

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

This:

enter image description here

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?

CodePudding user response:

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.

  • Related