fletcher / MultiMarkdown

Expanded perl version of John Gruber's original Markdown --- No longer under active development since MMD 3
http://fletcherpenney.net/multimarkdown/
1.06k stars 530 forks source link

Footnote references must be treated as paragraphs #11

Closed andrewheiss closed 14 years ago

andrewheiss commented 14 years ago

I'm not sure if this is a feature or a bug…

When using links in reference-style, list mode, each link only needs to be separated by one newline, like so:

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna[^2] aliqua. Ut enim ad minim [veniam][test1], quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla [pariatur][test2]. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

[test1]: www.example1.com
[test2]: www.example2.com

However, when using footnotes, which follow a similar markup pattern, each footnote needs to be separated by a blank line, otherwise all footnotes are grouped together in the same note when converted to HTML. For example, in this paragraph

Lorem ipsum[^1] [dolor][test3] sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna[^2] aliqua. Ut enim ad minim [veniam][test1], quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla [pariatur][test2]. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

This reference list fails and includes both the second footnote and the third link in the text of the first:

[test1]: www.example1.com
[test2]: www.example2.com
[^1]: This is a footnote  
[^2]: This is another footnote
[test3]: www.example3.com

Where as this doesn't fail and works correctly:

[test1]: www.example1.com
[test2]: www.example2.com

[^1]: This is a footnote 

[^2]: This is another footnote

[test3]: www.example3.com

I understand that footnotes are a special case (that don't actually exist in real HTML), and that you can expectedly have multiple paragraphs or other HTML elements in a footnote definition (while you can only have a URL and an optional title in link definitions)

Would it be possible in the footnote parsing functions, though, to remove the need for the newlines, perhaps by checking for a [^x]:, since it shouldn't be possible to include a footnote inside a footnote. It would make the reference-style footnotes act more like the reference-style links and save a lot of unnecessary whitespace.

fletcher commented 14 years ago

Since footnotes can contain multiple lines/paragraphs, they need to be separated by blank lines. This is consistent with the behavior of default Markdown for other "paragraph" type elements (lists, blockquotes, etc).

Without a lot of convincing, I don't expect that this will change.