New lines inside paragraph in README.md

365,469

Solution 1

Interpreting newlines as <br /> used to be a feature of Github-flavored markdown, but the most recent help document no longer lists this feature.

Fortunately, you can do it manually. The easiest way is to ensure that each line ends with two spaces. So, change

a
b
c

into

a__
b__
c

(where _ is a blank space).

Or, you can add explicit <br /> tags.

a <br />
b <br />
c

Solution 2

You can use a backslash at the end of a line.
So this:

a\
b\
c

will then look like:

a
b
c

Notice that there is no backslash at the end of the last line (after the 'c' character).

Solution 3

If you want to be a little bit fancier you can also create it as an html list to create something like bullets or numbers using ul or ol.

<ul>
<li>Line 1</li>
<li>Line 2</li>
</ul>
Share:
365,469
zoran119
Author by

zoran119

Updated on August 18, 2021

Comments

  • zoran119
    zoran119 almost 3 years

    When editing an issue and clicking Preview the following markdown source:

    a
    b
    c
    

    shows every letter on a new line.

    However, it seems to me that pushing similar markdown source structure in README.md joins all the letters on one line.

    I'd like the new lines preserved in the README.md in this project: https://github.com/zoran119/simple-read-only-test

    Any idea how?

  • Guilherme Ferreira
    Guilherme Ferreira over 7 years
    Thank you so much. My documents will be much better now!
  • Ben Creasy
    Ben Creasy about 7 years
    according to stackoverflow.com/questions/18019957/… Github-favored markdown is not used everywhere on Github. Might be outdated though.
  • Ev.
    Ev. over 6 years
    Gracias mi amigo!
  • Christian Seiler
    Christian Seiler about 6 years
    The question is about new line within a paragraph
  • Pierre
    Pierre over 5 years
    According to the link you give, it's now possible to create line breaks "by leaving a blank line between lines of text." There is still a problem: with this method, you create a new paragraph, not just a line break.
  • Dato
    Dato over 5 years
    As @BenCreasy said, Github-flavored markdown is not used in README.md files. Or, to be fair, not the full set of features is used: syntax highlighting and auto-linking URLs are available; hard line breaks, formatted task lists and references to issues—aren’t.
  • user3015682
    user3015682 over 4 years
    Forward slash doesn't seem to be necessary, worked fine with just <br>
  • Thiago Valentim
    Thiago Valentim over 4 years
    The forward slash sounds like a workaround but works well instead the html tag already is a formal way to do the task. Thanks so much @tbekolay! your answer helps me a lot.
  • Manuel
    Manuel over 3 years
    I tried it for Bitbucket and the only format that worked were the 2 blank spaces. Anything else (<br>, <br />, Backslash) didn't work.
  • Celdor
    Celdor over 3 years
    Thanks. This works for me outside GitHub where the other solutions did not.
  • Admin
    Admin over 2 years
    <br> works well for me, but 2 spaces are not working for me (GitHub README.md file).