Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Line breaks in markdown
Hello  (<-- two spaces)
World

Hello
World


Hello
World

Hello World


Hello<br/>
World

Hello
World


Hello

World

Hello

World

@raytry

This comment has been minimized.

Copy link

@raytry raytry commented Nov 29, 2017

I noticed that the

hello\
world

also causes line break.

@rgolangh

This comment has been minimized.

Copy link

@rgolangh rgolangh commented Feb 13, 2018

@raytry That's even better, cause it is visible. Thank you.

@calebboyd

This comment has been minimized.

Copy link

@calebboyd calebboyd commented Mar 7, 2018

Also:

Hello&nbsp;
World

Hello 
World

@nltesown

This comment has been minimized.

Copy link

@nltesown nltesown commented Mar 26, 2018

Thanks a lot for the backslash tip. The double space never was a very good idea.

@SolidSoils

This comment has been minimized.

Copy link

@SolidSoils SolidSoils commented Apr 13, 2018

@Raytray: While hello\ works with a few Markdown parsers, it is not part of the specification and therefore some parsers ignore it. However, it sure looks elegant and i.m.o. it would be nice if it would be added to the Markdown specification.

For now the only solid solution seems to be the good old <br/> tag, which looks a bit clumsy for such a basic layout feature.

@michael-freidgeim-webjet

This comment has been minimized.

Copy link

@michael-freidgeim-webjet michael-freidgeim-webjet commented Apr 15, 2018

I've noticed that backslash is working as new line only if it is a last character. If it has trailing spaces(e.g. "hello\ "), backslash will be shown literally in the output

@olos00

This comment has been minimized.

Copy link

@olos00 olos00 commented May 1, 2018

Thanks! :)

@GrandAlf

This comment has been minimized.

Copy link

@GrandAlf GrandAlf commented May 7, 2018

interestingly, if we put \ at the end of a line without test on the next line, it shows up in the text
Previous line has an invisible \, this line has it visible\

the last one is visible because an empty line follows it

@darkain

This comment has been minimized.

Copy link

@darkain darkain commented May 10, 2018

Yeah, the double-space thing is a bad idea in general because many text editors automatically trim white-space at the end of each line upon saving. Its best to use a form that'll work for the most amount of people.

@Swoorup

This comment has been minimized.

Copy link

@Swoorup Swoorup commented May 24, 2018

I am appalled how I would have to google for this, lol !!!

@kritoth

This comment has been minimized.

Copy link

@kritoth kritoth commented Jun 19, 2018

for me only Shift + Enter worked. No
and no </kbd>

@matchavez

This comment has been minimized.

Copy link

@matchavez matchavez commented Jul 3, 2018

The backslash is the only way it works within a block quote, as well. shift+enter doesn't.

@Anwar-Faiz

This comment has been minimized.

Copy link

@Anwar-Faiz Anwar-Faiz commented Jul 11, 2018

A good explanation along with a github commit is posted at:

http://www.w3lc.com/2017/05/new-line-in-readme-file-github-fixing.html

I think this will help the readers and people searching answer to fix this issue!

@bell-jamesl

This comment has been minimized.

Copy link

@bell-jamesl bell-jamesl commented Jul 14, 2018

Thanks! :)

@Sungmiii

This comment has been minimized.

Copy link

@Sungmiii Sungmiii commented Jul 24, 2018

Thank you !

@bexoss

This comment has been minimized.

Copy link

@bexoss bexoss commented Oct 14, 2018

Hello world

@MoatazAbdAlmageed

This comment has been minimized.

Copy link

@MoatazAbdAlmageed MoatazAbdAlmageed commented Oct 15, 2018

Testing
npm install #may you need sudo
npm start
navigate to http://localhost:3000\

@peeyush81

This comment has been minimized.

Copy link

@peeyush81 peeyush81 commented Dec 7, 2018

This project is built on symfony 4 and php 7.2.
To get development environment working -
composer install
brew install yarn
yarn install
yarn encore dev
php bin/console server:run
add this to ~/.gitignore_global
https://github.com/symfony/demo/blob/master/.gitignore

@androidfanatic

This comment has been minimized.

Copy link

@androidfanatic androidfanatic commented Dec 13, 2018

This




is just a test.

@liuchong

This comment has been minimized.

Copy link

@liuchong liuchong commented Dec 14, 2018

nice gist!

@isratmir

This comment has been minimized.

Copy link

@isratmir isratmir commented Dec 25, 2018

Thanks man

@BakrFrag

This comment has been minimized.

Copy link

@BakrFrag BakrFrag commented Jan 3, 2019

markdown transferred to html in browser so you can use html tags inside markdown file
so you can use all html tags for newline you can use <br>

@BakrFrag

This comment has been minimized.

Copy link

@BakrFrag BakrFrag commented Jan 3, 2019

this examples of using both html and markdown to get same results
bold from markdown



also bold from html

itaclic from markdown

also italic from html

so if you want to make newline in markdown you can use <br>

@mahiki

This comment has been minimized.

Copy link

@mahiki mahiki commented Jan 10, 2019

Why does markdown do this? If I want two lines to run consecutively I won’t introduce a newline.

Every editor can wrap text, I’m truly at a loss. Now we have to have <br> everywhere, or double spaced lines, or that silly two-spaces thing.

@sosospicy

This comment has been minimized.

Copy link

@sosospicy sosospicy commented Jan 30, 2019

hello
world

"```" works.

@Chenghan-Sun

This comment has been minimized.

Copy link

@Chenghan-Sun Chenghan-Sun commented Feb 7, 2019

hello
world

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Mar 4, 2019

hello\ world

@YingtongDou

This comment has been minimized.

Copy link

@YingtongDou YingtongDou commented Mar 4, 2019

this  
a test

@RobertShaw1

This comment has been minimized.

Copy link

@RobertShaw1 RobertShaw1 commented Mar 16, 2019

@Raytray: While hello\ works with a few Markdown parsers, it is not part of the specification and therefore some parsers ignore it. However, it sure looks elegant and i.m.o. it would be nice if it would be added to the Markdown specification.

For now the only solid solution seems to be the good old
tag, which looks a bit clumsy for such a basic layout feature.

@SolidSoils: https://spec.commonmark.org/0.28/#hard-line-breaks

@eyecatchup

This comment has been minimized.

Copy link

@eyecatchup eyecatchup commented Mar 17, 2019

@RobertShaw1 CommonMark is not Markdown. ;)

@ponya

This comment has been minimized.

Copy link

@ponya ponya commented Mar 20, 2019

hello/ world

@ho0kim

This comment has been minimized.

Copy link

@ho0kim ho0kim commented Apr 14, 2019

hello

world

@resarahman

This comment has been minimized.

Copy link

@resarahman resarahman commented Apr 24, 2019

Hello  Word

@cnukaus

This comment has been minimized.

Copy link

@cnukaus cnukaus commented May 18, 2019

two spaces doesn't work for my GIthub MD? will use
back slash

@Risyandi

This comment has been minimized.

Copy link

@Risyandi Risyandi commented Jun 2, 2019

Thank you.

@kartikynwa

This comment has been minimized.

Copy link

@kartikynwa kartikynwa commented Jun 13, 2019

Thanks
a
lot.

@NabiKAZ

This comment has been minimized.

Copy link

@NabiKAZ NabiKAZ commented Jun 24, 2019

for me only Shift + Enter worked. No
and no

You are right for issue comments, but don't work for README.md in the github, and needed <br>.

@V0idk

This comment has been minimized.

Copy link

@V0idk V0idk commented Jul 25, 2019

thank
you

@dwy6626

This comment has been minimized.

Copy link

@dwy6626 dwy6626 commented Jul 31, 2019

This awesome note got more stars than its word counts
lol

@XiaojiaoChen

This comment has been minimized.

Copy link

@XiaojiaoChen XiaojiaoChen commented Aug 11, 2019

hello\ world

@XiaojiaoChen

This comment has been minimized.

Copy link

@XiaojiaoChen XiaojiaoChen commented Aug 11, 2019

hello
world

@superarts

This comment has been minimized.

Copy link

@superarts superarts commented Aug 19, 2019

How to break a long line without space? Something like:

但是可以运行慢得要死的Java虚拟机的现代手机等硬件来说(Java爱好者肯定能拿出一百个例子来说明Java并不慢,我一直不明白,byte code和垃圾回收这种机制不可能在所有场合下都能取得比机器代码加引用计数同样的效率这点,怎么会有人不明白,而且下文会说,并不是机器效率越高,一个语言就越成功),值类型在大多数应用场景不再是一个问题。对大型工程来说,人们更看重的是架构层面的问题。把同一段内存,也就是一个object,用不同的reference来表达,这种方式本质上是会造成架构问题的。要求一个程序员在修改一个内存变量的时候,心中时刻记得所有指向同一内存地址的变量,需要时刻记得相关的所有变量,这样的要求会引发更多犯错误的可能。Swift之所以把可变性作为一个重点问题来抓,原因就是在现实中,可变性引发的bug实在太多太多了。因此Swift会强制你在传递或者复制一个对象的时候,除非特别制定,否则默认会真的复制一段内存内容出来,这样可以保证不变的对象是真的不变。

@AweiLoveAndroid

This comment has been minimized.

Copy link

@AweiLoveAndroid AweiLoveAndroid commented Oct 12, 2019

Title1 Title12
Inreoduces.:
xxxxxxxxxxxxxxxxxxxxxxxx
Inreoduces:
xxxxxxxxxxxxxxxxxxxxxxxx
Inreoduces:
xxxxxxxxxxxxxxxxxxxxxxxx
@mirhmousavi

This comment has been minimized.

Copy link

@mirhmousavi mirhmousavi commented Nov 12, 2019

Thanks

@luengark

This comment has been minimized.

Copy link

@luengark luengark commented Dec 6, 2019

This
is
a
test\

@metablaster

This comment has been minimized.

Copy link

@metablaster metablaster commented Dec 20, 2019

groundbreaking!

@joshuasing

This comment has been minimized.

Copy link

@joshuasing joshuasing commented Jan 14, 2020

Thank
You!
This
Helped
A
Lot!

*Joshua was here*

@UInt2048

This comment has been minimized.

Copy link

@UInt2048 UInt2048 commented Jan 23, 2020

@chuongmep

This comment has been minimized.

Copy link

@chuongmep chuongmep commented Feb 14, 2020

thanks
you

@Faisal-Zulfiqar510

This comment has been minimized.

Copy link

@Faisal-Zulfiqar510 Faisal-Zulfiqar510 commented Mar 3, 2020

I noticed that the

hello\
world

also causes line break.

Thanks buddy

@cweijan

This comment has been minimized.

Copy link

@cweijan cweijan commented Mar 20, 2020

hello\world
hello\ world
hello/ world

@UInt2048

This comment has been minimized.

Copy link

@UInt2048 UInt2048 commented Mar 21, 2020

@cweijan Well, it certainly won't do anything in preformatted (code) text.

@lazerg

This comment has been minimized.

Copy link

@lazerg lazerg commented Mar 28, 2020

Cool thanks, exactly what i was looking for

@saminwankwo

This comment has been minimized.

Copy link

@saminwankwo saminwankwo commented Apr 7, 2020

Thanks this helped

@wachin

This comment has been minimized.

Copy link

@wachin wachin commented Apr 16, 2020

Working

@opxop

This comment has been minimized.

Copy link

@opxop opxop commented Apr 24, 2020

nice gist, this helped!

@sylven

This comment has been minimized.

Copy link

@sylven sylven commented Apr 30, 2020

Double space seems like a better solution to keep the source code more readable, but having so many plugins and IDE remove trailing spaces, I'll go with backslash 🙄

@nanmcpe

This comment has been minimized.

Copy link

@nanmcpe nanmcpe commented May 4, 2020

Thank you

@BunnyBomb

This comment has been minimized.

Copy link

@BunnyBomb BunnyBomb commented May 6, 2020

How do I add a line space between a bullet of text and a line break?

Currently if I use this:

- The property is down a shared driveway and a 20 min drive from the city

****

It comes out like this:
image

I have tried using these already and they don't work:

<br />
2 spaces at the end
/
/s
@2gbeh

This comment has been minimized.

Copy link

@2gbeh 2gbeh commented May 8, 2020


is the most consistent on github.md

@mousetrapbot01

This comment has been minimized.

Copy link

@mousetrapbot01 mousetrapbot01 commented May 29, 2020

Thank you so much.

@dougglenn

This comment has been minimized.

Copy link

@dougglenn dougglenn commented May 29, 2020

@sylven

Double space seems like a better solution to keep the source code more readable, but having so many plugins and IDE remove trailing spaces, I'll go with backslash.

Every editor or IDE I've had to use that strips whitespace when saving the file, there has always been a check box in settings or preferences to disable it which allows for the spaces to remain when saved. As another option, you can choose to use a text editor that doesn't and just use it for that purpose. Or you can create another editor profile you can launch to do the same. That is what I do with Kate, select to open another profile in another window.

Personally I'll stick to the HTML break. I written so much HTML it's automatic reflex.

@michelmany

This comment has been minimized.

Copy link

@michelmany michelmany commented Jun 7, 2020

This a

test

@manisha201301

This comment has been minimized.

Copy link

@manisha201301 manisha201301 commented Jul 9, 2020

Hello. World

@akhilalekha

This comment has been minimized.

Copy link

@akhilalekha akhilalekha commented Aug 1, 2020

Hi what if it's inside multiline code block? How to wrap lines in multi line code block?

@coarsehorse

This comment has been minimized.

Copy link

@coarsehorse coarsehorse commented Aug 6, 2020

Nice, thank you all

@ZJT26142

This comment has been minimized.

Copy link

@ZJT26142 ZJT26142 commented Aug 11, 2020

Thanks!

@behnazj

This comment has been minimized.

Copy link

@behnazj behnazj commented Sep 1, 2020

<br> worked fine for me (macbook). Thx!

@itsHel

This comment has been minimized.

@cuongnh1998

This comment has been minimized.

Copy link

@cuongnh1998 cuongnh1998 commented Nov 24, 2020

Thanks

@Galaxy-Coding

This comment has been minimized.

Copy link

@Galaxy-Coding Galaxy-Coding commented Dec 15, 2020

test
he

@refcell

This comment has been minimized.

Copy link

@refcell refcell commented Dec 23, 2020

We need a line-continuation, like \<cr> in C programming language. Sadly, this symbol represents line breaks in markdown. Without this feature, compact text like Chinese can only be written one line at a time, otherwise, inappropriate Spaces will appear. I want to be able to use /<cr> or \\<cr> as a continuation, expected results the following:

markdown:

a/
b

or

a\\
b

expected:

ab
@vsvad

This comment has been minimized.

Copy link

@vsvad vsvad commented Dec 29, 2020

In <pre><code> works <br>

@meliodev

This comment has been minimized.

Copy link

@meliodev meliodev commented Jan 13, 2021

import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; import { gestureHandlerRootHOC } from 'react-native-gesture-handler' import notifee, { EventType, AndroidImportance } from '@notifee/react-native' import messaging from '@react-native-firebase/messaging' //background & quit state: messages listener async function onBackgroundMessageReceived(message) { const channelId = await notifee.createChannel({ id: 'projects', name: 'projects', lights: false, vibration: true, importance: AndroidImportance.DEFAULT, }) await notifee.displayNotification(JSON.parse(message.data.notifee)) } messaging().setBackgroundMessageHandler(onBackgroundMessageReceived) notifee.onBackgroundEvent(async ({ type, detail }) => { const { notification } = detail //const { pressAction } = notification.android switch (type) { case EventType.PRESS: console.log('NOTIFICATION PRESSED !') // I want to navigate to a sepcified screen await notifee.cancelNotification(notification.id) break } }) AppRegistry.registerComponent(appName, () => gestureHandlerRootHOC(App));

@AysegulSezen

This comment has been minimized.

Copy link

@AysegulSezen AysegulSezen commented Jan 21, 2021

Thanks!

@funder7

This comment has been minimized.

Copy link

@funder7 funder7 commented Feb 16, 2021

I noticed that the

hello\
world

also causes line break.

Nice, but it doesn't work for me (tested in brackets app - macos)

@pepoluan

This comment has been minimized.

Copy link

@pepoluan pepoluan commented Feb 17, 2021

We need a line-continuation, like \<cr> in C programming language. Sadly, this symbol represents line breaks in markdown. Without this feature, compact text like Chinese can only be written one line at a time, otherwise, inappropriate Spaces will appear. I want to be able to use /<cr> or \\<cr> as a continuation, expected results the following:

markdown:

a/
b

or

a\\
b

expected:

ab

Strange... I swear that it used to be, if you write two lines next to each other like this:

This is first line.
This is second line.

They used to render like this:

This is first line. This is second line.

Since when GitHub introduced this misguided change??

@OV-ETN

This comment has been minimized.

Copy link

@OV-ETN OV-ETN commented Mar 4, 2021

/very/
/cool!/

@prakass1

This comment has been minimized.

Copy link

@prakass1 prakass1 commented Mar 18, 2021

hello
world

@prakass1

This comment has been minimized.

Copy link

@prakass1 prakass1 commented Mar 18, 2021

hello/ world

@albertogaldames

This comment has been minimized.

Copy link

@albertogaldames albertogaldames commented Mar 19, 2021




Test


Hello

@marceloalvescl

This comment has been minimized.

Copy link

@marceloalvescl marceloalvescl commented Apr 3, 2021

hello

world /
this
is just/
a test

@marceloalvescl

This comment has been minimized.

Copy link

@marceloalvescl marceloalvescl commented Apr 3, 2021

isso aqui
é só um teste aleatório
@emperor-orbitz

This comment has been minimized.

Copy link

@emperor-orbitz emperor-orbitz commented Apr 3, 2021

I think Github allows html markups for Commit Messages

@KpuCko

This comment has been minimized.

Copy link

@KpuCko KpuCko commented Apr 7, 2021

Many thanks!
You saved my day.

@DannyLizzie

This comment has been minimized.

Copy link

@DannyLizzie DannyLizzie commented Apr 30, 2021

There is a slight spacing difference if you use backslash. The vertical spacing is bigger than if you just use an empty line.

linebreak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment