How to insert a line break
in markdown

前端 未结 3 1985
故里飘歌
故里飘歌 2021-01-31 12:57

I\'m trying to create a markdown file with some paragraphs containing both a link and a line of text on the next line. The problem I\'ve encountered is that when I make a new li

相关标签:
3条回答
  • 2021-01-31 13:41

    Try adding 2 spaces (or a backslash \) after the first line:

    [Name of link](url)
    My line of text\
    

    Visually:

    [Name of link](url)<space><space>
    My line of text\
    

    Output:

    <p><a href="url">Name of link</a><br>
    My line of text<br></p>
    
    0 讨论(0)
  • 2021-01-31 13:44

    I know this post is about adding a single line break but I thought I would mention that you can create multiple line breaks with the backslash (\) character:

    Hello
    \
    \
    \
    World!
    

    This would result in 3 new lines after "Hello". To clarify, that would mean 2 empty lines between "Hello" and "World!". It would display like this:


    Hello



    World!



    Personally I find this cleaner for a large number of line breaks compared to using <br>.

    Note that backslashes are not recommended for compatibility reasons. So this may not be supported by your Markdown parser but it's handy when it is.

    0 讨论(0)
  • 2021-01-31 13:52

    Just adding a new line worked for me if you're to store the markdown in a JavaScript variable. like so

    let markdown = `
        1. Apple
        2. Mango
         this is juicy
        3. Orange
    `
    
    0 讨论(0)
提交回复
热议问题