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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redcarpet incorrectly parses nested lists #790

Open
kristoph opened this issue Jul 5, 2024 · 4 comments
Open

Redcarpet incorrectly parses nested lists #790

kristoph opened this issue Jul 5, 2024 · 4 comments

Comments

@kristoph
Copy link

kristoph commented Jul 5, 2024

  1. Lists: You can create a bulleted list by prefacing each line with a dash or an asterisk. For example:

    • Item 1
    • Item 2
    • Item 3

( or equivalent string 5. Lists: You can create a bulleted list by prefacing each line with a dash or an asterisk. For example:\n\n * Item 1\n * Item 2\n * Item 3 )

Generates ...

"<ol>\n<li>Lists: You can create a bulleted list by prefacing each line with a dash or an asterisk. For example:</li>\n</ol>\n\n<ul>\n<li>Item 1</li>\n<li>Item 2</li>\n<li>Item 3</li>\n</ul>\n"
@jlpereira
Copy link

Any news on this? We are also having this problem with nested lists

@dhMuse
Copy link

dhMuse commented Aug 27, 2024

The problem seems to be that the <li> tags that should wrap the nested <ul> or <ol> element are missing. Moreover, this problem affects HTML passed in, too, not just markdown. Rendering passed-in HTML gives a hint as to the nature of the problem, since it appears that tags wrapping the nested list are actually stripped. For example, if you pass in something like

<ul>
  <li>Item 1</li>
  <li>
    <ol>
      <li>Subitem 1</li>
      <li>Subitem 2</li>
      <li>Subitem 3</li>
    </ol>
  </li>
</ul>

the rendered HTML will be look more like

<ul>
  <li>Item 1</li>
  <ol>
    <li>Subitem 1</li>
    <li>Subitem 2</li>
    <li>Subitem 3</li>
  </ol>
</ul>

which is invalid HTML.

@dhMuse
Copy link

dhMuse commented Aug 27, 2024

Nope, sorry, the point in my last post about the surrounding <li> tags being stripped was mistaken! Passing in correctly nested <ul><li><ol></ol></li></ul> will retain the <li> tags.

@mjy
Copy link

mjy commented Sep 11, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants