Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lists with line breaks are not parsed correctly #2779

Open
d0819 opened this issue Apr 11, 2023 · 1 comment
Open

Lists with line breaks are not parsed correctly #2779

d0819 opened this issue Apr 11, 2023 · 1 comment
Labels
category: lists L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue

Comments

@d0819
Copy link

d0819 commented Apr 11, 2023

Marked version:
4.3.0
4.2.3

Describe the bug

馃憢Hello. I am using marked and it is a great library, thank you for creating it.

According to this discussion, V4.2.3 is supposed to be 100% compliant with the "Lists" and "List items" of the CommonMark standard. However, it seems to have some issues with parsing lists that contain line breaks, such as the following:

1.
Monday
2.
Tuesday
3.
Wednesday

To Reproduce
Steps to reproduce the behavior:

Expected behavior

I believe that parsing it in the following way, like in CommonMark, is correct:

<ol>
<li></li>
</ol>
<p>Monday
2.
Tuesday
3.
Wednesday</p>

Explanation
According to CommonMark 5.2 List items:

  1. A list may start or end with an empty list item. So 1. is a list item with empty content.
  2. In this case, the width W of the list marker (1.) is 2, so in order for Monday to become the content of 1., it needs to have 3 (= W + 1) or more spaces of indentation. In the given example, since there are 0 spaces, Monday should become regular text (<p>).

Example1:

1.
Monday

Expected result:

<ol>
<li></li>
</ol>
<p>Monday</p>

Example2:

1.
   Monday

Expected result:

<ol>
<li>Monday</li>
</ol>
@UziTech
Copy link
Member

UziTech commented Apr 11, 2023

It looks like the expected result for Example2 is what happens in marked.

I would say that Example1 is not well formatted markdown and should be considered in the category of garbage in/garbage out.

The are quite a few places in the common mark spec where it describes how common mark works not necessarily how it should work.

@UziTech UziTech closed this as completed Apr 11, 2023
@UziTech UziTech reopened this Apr 11, 2023
@UziTech UziTech added L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue category: lists labels Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: lists L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue
Projects
None yet
Development

No branches or pull requests

2 participants