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

Trying to migrate from markdown2, lists without blank lines not working #1442

Closed
nemecek-filip opened this issue Feb 10, 2024 · 3 comments
Closed
Labels
wontfix The issue will not be fixed for the stated reasons.

Comments

@nemecek-filip
Copy link

Hello,

in my Django project I am using the other markdown package - I chose it back in 2021 without much thought. Currently I am working on migration to this one, but I have quite a lot of users' Markdown and these packages behave slightly differently when it comes to lists.

For example this:

Some random text
1.  Item 1
2. Item 2
3. Item 3

or:

Some random text
* Item 1
* Item 2
* Item 3

Does not render as a paragraph followed by list element. I also tried the "sane lists" extension. Unfortunately the markdown2 renders this correctly so I am looking for ways how to fix this in more elegant ways than giving my users opt-in upgrade path with instructions to re-check their rendered content.

Is there perhaps some extension or settings I could use to get the package to parse these lists if they immediately follow paragraph without new line? Or maybe reasonably easy custom extension that I would write would help me?

Thanks, appreciate any input!

@facelessuser
Copy link
Collaborator

Python Markdown normally requires blocks to have new lines before them. While occasionally, some blocks may work without this, it is generally recommended to use them before new blocks so they are not included in the block prior.

@nemecek-filip
Copy link
Author

Do you think I could just add the new line with regex to the Markdown content before turning it into HTML with this package? Wouldn't this perhaps invite more problems?

@waylan
Copy link
Member

waylan commented Feb 13, 2024

Our behavior matches the behavior of the reference implementation. Therefore, it is markdown2 which has the behavior wrong. And for good reason. Consider this paragraph:

A sentence which makes mention of the year
2024. A year which has just gotten underway.

Clearly that should all be a single paragraph. It would be inappropriate to trigger a list just because the line wrapping happens to create what might look like a list item. The point is that Markdown can't tell the difference, so you should be required to insert a blank line if both lines are not part of the same paragraph.

If you want to go through your documents and automate the insertion of blank lines, you can. But how can you be certain you aren't splitting up a paragraph? I suppose because it would have been rendered that way to begin with it would at least be consistent.

In any event, I am closing this as wontfix.

@waylan waylan closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2024
@waylan waylan added the wontfix The issue will not be fixed for the stated reasons. label Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix The issue will not be fixed for the stated reasons.
Projects
None yet
Development

No branches or pull requests

3 participants