Newlines not treated as whitespace in emphasis pattern · Issue #783 · Python-Markdown/markdown (original) (raw)

The following input is correctly not a list as there is no blank line between the first and second lines:

not a list
* list item 1
* list item 2
* list item 3

However, now that we have list-like syntax, the inline patterns make a mess of it and we get this output:

not a list list item 1 list item 2 * list item 3

It seems that * list item 1\n* is incorrectly being identified as em. However, the reference implementation renders that as:

not a list * list item 1 * list item 2 * list item 3

See Babelmark for comparison.

If we remove the newlines:

not a list * list item 1 * list item 2 * list item 3

Then things work as they should (see Babelmark):

not a list * list item 1 * list item 2 * list item 3

Which suggests that the problem is that we are not properly accounting for newlines as being whitespace somewhere in an inline pattern.

Note that Commonmark differs from Markdown here in that it recognizes the list without the blank line. In fact, the Commonmark spec acknowledges that this behavior is different from Markdown. This issue is not about that. See #338 for that discussion. Please keep this discussion on point.

Finally, this issue was first reported on StackOverflow by user Minato.