wojcieh
wojcieh

Reputation: 340

Problem with markdown formatting - how to display code correctly

I have a short README.md where I have problems in formatting.

https://github.com/wojciehm/macOS-.bash_profile-cron-backup

Image with description

I can't paste the raw code because SO wants to format it as well.

Upvotes: 1

Views: 961

Answers (3)

Hamms
Hamms

Reputation: 5107

There are some examples in the GitHub Flavored Markdown docs that cover this, but the short version is that you simply need to indent the code block.

For example:

4. We commit all files with comment from script execution time: ` "generated files on date +'%Y-%m-%d %H:%M:%S'";`

  `git commit -a -m "generated files on date +'%Y-%m-%d %H:%M:%S'";`

^ note the two space characters at the beginning of the last line.

This renders to:

  1. We commit all files with comment from script execution time: "generated files on date +'%Y-%m-%d %H:%M:%S'";

    git commit -a -m "generated files on date +'%Y-%m-%d %H:%M:%S'";

Upvotes: 1

Alex Harvey
Alex Harvey

Reputation: 15472

You can use an HTML <br> tag, i.e.

4. We commit all files with comment from script execution time
`date +'%Y-%m-%d %H:%M:%S'`;<br>`git commit -a -m "generated files on date +'%Y-%m-%d %H:%M:%S'"`;

Note that I think the whole thing is more readable like this.

Upvotes: 2

billydh
billydh

Reputation: 1035

if you want to ignore the `backtick inside, you can do it this way

``inline containing backtick ` ``

this will output inline containing backtick `

Upvotes: 1

Related Questions