Create two blank lines in markdown

2019-01-30 00:03发布

问题:

I am adding markdown support to my CMS editor.

When writing markdown, how to create two empty lines?

I have been trying, but I always get only one line.

回答1:

Does your markdown compiler support html? You can add <br><br> in the markdown source.



回答2:

I test on a lot of markdowns, the non-breaking space ASCII character &nbsp; (followed by a blank line) would give blank line. Repeat this pair would do the job. So far I haven't failed any.

 

 

 

For example:  

 

 

Hello

 

 

 

 

 

 

world!

 

 



回答3:

In markdowns that support equation output, the following should work on a line by itself, with empty lines before and after (repeat for more lines):

$~$

It is basically an equation containing nothing but a single equation-white-space. The benefit is that in markdowns that include both PDF and HTML output options (including Rmarkdown), it should be understood in the same way for both output types, whereas I'm not sure how PDF output would interpret
or  



回答4:

I know it's very late to answer this question. But in my opinion, none of the answers above provide a neat solution.

Basically, if the library you are using is CommonMark-compliant, you can add multiple hard line breaks (<br />) easily. Here's a quotation from CommonMark's latest specifications (0.28)

A line break (not in a code span or HTML tag) that is preceded by two or more spaces and does not occur at the end of a block is parsed as a hard line break (rendered in HTML as a
tag)

and then...

For a more visible alternative, a backslash before the line ending may be used instead of two spaces

The specification is quite clear. However, the library I have been using MarkDig, doesn't quite work with the two spaces technique (must be a bug) but it works flawlessly with a backlash.

That said, this input...

Line one\
\
\
\
Line two

will produce four hard line breaks after "Line one". You can see it here (using backlash)...

https://babelmark.github.io/?text=Line+one%5C%0A%5C%0A%5C%0A%5C%0ALine+two%0A

Notice how all CommonMark-compliant implementations will get it right



回答5:

I only know these 3 options, would be great to take a list of all of them and comment them differences

// Creates 2 Lines that **can** be selected as text
&nbsp;  
&nbsp;

// Creates 2 Lines that **cannot** be selected as text
&NewLine;
&NewLine;

</br>
</br>


回答6:

You can use the sequence of a no-break space (U+00a0) followed by two spaces (U+0020×2) followed by a newline (U+000a) repeatedly to achieve this. Two or more times is required depending on your use case.

Using (not markdown interpreted here, but) actual white space characters (theoretically copy-and-paste-able):

Preceding
   
   
   
Following.


回答7:

In GitHub Wiki markdown I used hash marks (#) followed by two spaces to make the line break larger. It doesn't actually give you multiple line breaks but it made one large line break and served me well for my needs.

Instead of:

text
(space)(space)
more text

I did:

text
(hash mark)(space)(space)
more text

Hope this helps!



回答8:

Backtick quotes with a space inside and 2 spaces to follow. Repeat as needed for more lines:

text1 text1
`(space)`(space)(space)
`(space)`(space)(space)
text2 text2

Looks decent in markdown source:

text1 text1
` `  
` `  
text2 text2


回答9:

For an empty line in markdown, escape a space (\ ) then add a new line.

Example:

"\

"

Remember: escape a space and escape a new line. That way is markdown compliant, and should compile properly in any compiler. You may have to select the example text to see how it is set up.



回答10:

you can do it perfectly using this :

texttextexttexttext
&nbsp;
&nbsp;
texttexttexttexttext


回答11:

Try adding multiple spaces (two spaces = one <br>):

mycode(space)(space)(space)(space)

Hope that helps you.



标签: markdown