admin管理员组

文章数量:1122846

When writing Markdown, generally newlines are not a problem:

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.

should be the same as

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.

But apparently not when using lists:

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

is not the same as

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

Having the linebreak results in it being embedded in the list item. I would like to continue using linebreaks for readability in my Markdown source (max line length 120) without impacting its look when rendered (e.g., on GitHub, or rendered to a PDF). Is it possible? If not, is there a better way to have a short title followed by a longer explanation, without an entire heading?

When writing Markdown, generally newlines are not a problem:

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.

should be the same as

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.

But apparently not when using lists:

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

is not the same as

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

Having the linebreak results in it being embedded in the list item. I would like to continue using linebreaks for readability in my Markdown source (max line length 120) without impacting its look when rendered (e.g., on GitHub, or rendered to a PDF). Is it possible? If not, is there a better way to have a short title followed by a longer explanation, without an entire heading?

Share Improve this question edited Nov 22, 2024 at 8:29 Guillius 4614 silver badges11 bronze badges asked Nov 22, 2024 at 8:14 404 Name Not Found404 Name Not Found 3594 silver badges15 bronze badges 2
  • Could you add more information on where this is not rendering as you expect? On GitHub your markdown renders as you expect it to. – Matt Pitkin Commented Nov 22, 2024 at 9:06
  • I was using an online editor (stackedit), it renders the linebreaks there. Indeed on GitHub and VSCode it renders as expected – 404 Name Not Found Commented Nov 22, 2024 at 9:16
Add a comment  | 

1 Answer 1

Reset to default 0

I cannot reproduce the problem you are having as for me:
This

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

And this

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

Is producing the same result of

Here is some text:

  • Short title:
    • This is a very long sentence in a short paragraph, perhaps.

I think you might have some extra spaces at the end of - This is a very long sentence in a short because two spaces at the end of a line is rendered as a line break.

本文标签: line breaksHow do I add linebreaks in Markdown list but not when renderedStack Overflow