trentm / python-markdown2

markdown2: A fast and complete implementation of Markdown in Python
Other
2.66k stars 433 forks source link

Maintain order of appearance in footnotes #536

Closed Crozzers closed 11 months ago

Crozzers commented 12 months ago

This PR closes #533 by making sure footnotes maintain their order of appearance in the final HTML.

Previously, the order of the final footnotes list was based on the insertion order of footnote_ids. This array was populated as the parser processed the text and encountered footnotes. The problem is that markdown isn't processed entirely in order, leading to a disorganised footnotes list being generated.

This PR changes this by instead using the insertion order of footnotes, which is populated at the beginning of the conversion process by _strip_footnote_definitions.

The result is that the generated list of footnotes will appear in the same order as the footnote definitions.

nicholasserra commented 11 months ago

Nice, thank you!