Markdown footnotes attached to list items render incorrectly

Summary

Markdown is rendered incorrectly if the last item in a numbered or bullet list has a footnote. A heading following the footnote's content is not detected as such. See the example below:

Steps to reproduce

* List item with a footnote [^1]
[^1]: Footnote 1

### Heading

Should render 'Heading' as a heading. Instead, this happens:

  • List item with a footnote 1

Heading

  1. Footnote 1