如何在 Markdown 演示文稿中添加新行?

How to add new line in Markdown presentation?

如何在 Markdown 演示文稿中添加新行?

我的意思是,在 TeX 中类似于 \newline

参见the original markdown specification(粗体):

The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <br /> tag.

When you do want to insert a <br /> break tag using Markdown, you end a line with two or more spaces, then type return.

How to add new line in Markdown presentation?

检查以下资源Line Return

To force a line return, place two empty spaces at the end of a line.

你可以在 R markdown 中使用 &nbsp; 来创建一个新的空行。

例如,在您的 .Rmd 文件中:

I want 3 new lines: 

&nbsp;
&nbsp;
&nbsp;

End of file. 

换行符 (\n) 可用于以编程方式将换行符添加到 markdown 文件中。例如,可以在 python:

中这样做
with open("file_name.md", "w") as file:
   file.write("Some text")
   file.write("\n")
   file.write("Some other text")

只需在行尾添加 \。例如

one\
two

会变成

one
two

它也比两个空格好,因为它是可见的。

编辑:
它在某些降价应用程序中不起作用,因此可能会导致不兼容。 https://www.markdownguide.org/basic-syntax/#line-break-best-practices

这取决于您使用的是哪种降价解析器。例如在 showdownjs 中有一个选项 {simpleLineBreaks: true} 为以下 md 输入提供相应的 html:

a line
wrapped in two
<p>a line<br>
wrapped in two</p>

我在 Android 中使用 Markwon 进行降价解析。以下效果很好:

"My first line  \nMy second line  \nMy third line  \nMy last line"

...每行末尾有两个空格后跟 \n

MarkDown 文件的三种断行方式

<br /> Tag Using

paragraph First Line <br /> Second Line

\ Using

First Line sentence \
Second Line sentence 

space keypress two times Using

First Line sentence␠␠
Second Line sentence

段落正在使用 <br /> 标签。

多句使用\或两次按space key然后Enter和写一个新句子。

如果这里提到的 none 解决方案对你有用,这就是我遇到的情况,那么你可以执行以下操作: 添加一个空 header(破坏语义的 hack)

text
####
text

只需确保在添加 header 时,它在降价 css 中的底部没有边框,这样您就可以尝试 header 的不同变体。

我想在 react 中创建一个 MarkdownPreviewer 作为 freecodecamp 项目的一部分。所以我拼命寻找降价换行符。在尝试了很多建议之后。 我终于使用了 \n 并且成功了。

什么对我有用

\
&nbsp;
\
&nbsp;

您也可以将它包装在一个围栏代码块中。这种方法的优点是您无需为每一行都添加额外的内容。 但是,内容应显示为带有背景的突出显示块,因此它可能不适用于所有用例。

Lorem inmissa qui propinquas doleas
Accipe fuerat accipiam

换行加一个\就可以了

\