1

I am trying to add text formatted in a special way to a GitHub repo on README.md file but it is not rendering the text format the way I want it.

I have attached images below. I want it to look like this:

Desired Image

BUT this is how it is rendering it:

Actual Image

So how can I achieve my goal?

0

2 Answers 2

2

https://help.github.com/articles/github-flavored-markdown/

Put four spaces before each line.

10
  • Do you know how to select and add 4 spaces to a bunch of lines of texts? I need that too for formatting serverfault or all of stackexchange websites..its a pain selecting each line and doing it especially if the code is super long..thanks Feb 6, 2015 at 18:39
  • @granttailor Programming text editors often offer multiple-line selection features.
    – ceejayoz
    Feb 6, 2015 at 19:46
  • but when am typing questions on stackexchange from my browser..am not sure how to use a texteditor to post questions from the browser...stackexchange obviously disbale this with their editor..have no idea why? other than knowingly make it more difficult to post questions +++ i use nano editor in Linux when working on git repos, so not sure how to do that either Feb 6, 2015 at 20:25
  • @granttailor StackExchange doesn't disable it, it's just not built in to browser textareas. I just type longer posts into my text editor and copy them back when they're ready.
    – ceejayoz
    Feb 6, 2015 at 20:28
  • 2
    @granttailor Uh, before you go claiming people are arrogant, you should probably check first. StackOverflow's editor has buttons for both blockquotes and code.
    – ceejayoz
    Feb 6, 2015 at 20:42
1

GitHub flavored markdown supports Using triple back ticks to fence code blocks, which lets you wrap code blocks more easily than indenting every line.

Standard Markdown converts text with four spaces at the beginning of each line into a code block; GFM also supports fenced blocks. Just wrap your code in ``` (as shown below) and you won't need to indent it by four spaces. Note that although fenced code blocks don't have to be preceded by a blank line—unlike indented code blocks—we recommend placing a blank line before them to make the raw Markdown easier to read.

Here's an example:

```
function test() {
  console.log("notice the blank line before this function?");
}
```

Keep in mind that, within lists, you must indent non-fenced code blocks eight spaces to render them properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.