如何在 Markdown 列表中添加换行符但在渲染时不添加换行符?

问题描述 投票:0回答:1

编写Markdown时,一般换行不是问题:

This is a very long sentence in a short
paragraph, or maybe a paragraph made of
a single very long sentence.

This is an intended separate paragraph.

应该与

相同
This is a very long sentence in a short paragraph, or maybe a paragraph made of a single very long sentence.

This is an intended separate paragraph.

但在使用列表时显然不是:

Here is some text:
- Short title:
    - This is a very long sentence in a short
    paragraph, perhaps.

不一样
Here is some text:
- Short title:
    - This is a very long sentence in a short paragraph, perhaps.

换行符会导致其嵌入到列表项中。 我想继续在 Markdown 源代码中使用换行符以提高可读性(最大行长度 120),而不会影响其渲染时的外观(例如,在 GitHub 上或渲染为 PDF)。是否可以?如果没有,是否有更好的方法,在没有整个标题的情况下先有一个简短的标题,然后是一个较长的解释?

markdown line-breaks
1个回答
0
投票

我无法重现您遇到的问题:
这个

Here is some text:
- Short title:
    - This is a very long sentence in a short
    paragraph, perhaps.

还有这个

Here is some text:
- Short title:
    - This is a very long sentence in a short paragraph, perhaps.

产生与

相同的结果

这是一些文字:

  • 短标题:
    • 这是一个很长的句子 也许是段落。

我认为您可能在

- This is a very long sentence in a short
的末尾有一些额外的空格,因为行尾的两个空格会被渲染为换行符。

© www.soinside.com 2019 - 2024. All rights reserved.