Sorry for bumping this old thread, but I wanted to mention that it seems to me like requiring a space before list items that interrupt a paragraph doesn’t really solve anything. The issue is not that some authors prefer to start list items immediately after paragraphs, but rather that that is (perhaps by accident) a common occurrence in Markdown usage. People start list items immediately following a paragraph, and expect for it to just work.
I wonder if it would make sense to extend the current rule to allow a list to interrupt a paragraph only if it both start at “1” and has multiple list items. In the infrequent situations where authors actually want to have a list with a single item, they would still have the option to put an empty line before it.
Regarding the O(n²) issue, I think it’s interesting to note that parsing Markdown already requires arbitrary lookahead, so it seems to me like this doesn’t introduce any potential for exploit that isn’t already there. Cf. https://github.com/micromark/micromark/issues/8
Examples:
The following would not be a list, because it would have a single item:
We are talking about the number
1. It is a natural number.
The following would be a list, because it has multiple items:
We are talking about the number two.
1. It is a natural number.
2. It is a prime number.
The following would be a list, because it is not interrupting a paragraph anyway:
We are talking about some number.
1. It is a natural number.
The following would not be a list, because it doesn’t start at “1”.
My favorite number is the number
2. I heard it was created around
1982. I’m not sure that’s right.
If the “favorite number” in the example above were actually “1”, then it would unfortunately become a list. Perhaps it’d make sense to require lists interrupting paragraphs to actually be sequential, but I feel like that kind of situation is rare enough to not actually warrant worry.