New lines inside paragraph in README.md
Asked Answered
T

6

449

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?

Trimurti answered 4/7, 2014 at 13:40 Comment(2)
Does this answer your question? How to insert a line break <br> in markdownVickyvico
I cannot understand why people don't want to be allowed to break lines of code without breaking lines visually. It is just like being against html consuming extra space or treating newlines as spaces. Specially if you are talking about github. GitHub uses diff... it is horrible to have a very long line!!! So... I am forced to write a whole paragraph in one line... :-(Capparidaceous
W
873

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
Whitaker answered 4/7, 2014 at 14:5 Comment(9)
Thank you so much. My documents will be much better now!Formwork
according to #18020457 Github-favored markdown is not used everywhere on Github. Might be outdated though.Vaginitis
Gracias mi amigo!Rosanarosane
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.Verbid
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.Therewithal
Forward slash doesn't seem to be necessary, worked fine with just <br>Rotator
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.Humdrum
I tried it for Bitbucket and the only format that worked were the 2 blank spaces. Anything else (<br>, <br />, Backslash) didn't work.Ambrosane
<br> works well for me, but 2 spaces are not working for me (GitHub README.md file).Prestissimo
J
95

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).

Jonajonah answered 17/12, 2019 at 12:13 Comment(2)
Thanks. This works for me outside GitHub where the other solutions did not.Secundines
Works in GitLab READMEEvonneevonymus
E
9

You should use html break <br/> tag

a <br/>
b <br/>
c

Endothelium answered 4/3, 2022 at 2:55 Comment(0)
P
5

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>
Provencal answered 16/7, 2018 at 21:6 Comment(0)
E
3

Using the mentioned methods above didn't work for me in all cases.

I ended up adding "##" to add a new line!

a
##
b
##
c
Enlil answered 2/1, 2023 at 18:4 Comment(1)
Thank you. this was the only option that worked for me.Hyrup
P
-1

According to Github API two empty lines are a new paragraph (same as here in stackoverflow)

You can test it with http://prose.io

Phenetidine answered 13/9, 2017 at 11:5 Comment(1)
The question is about new line within a paragraphBeestings

© 2022 - 2025 — McMap. All rights reserved.