seth-brown / formd

A Markdown formatting tool
MIT License
147 stars 19 forks source link

formd flipping mangles MultiMarkdown footnotes #4

Closed kopischke closed 12 years ago

kopischke commented 12 years ago

Using formd to flip link style on a document containing MultiMarkdown footnotes will mangle the footnotes. Specifically, while the inline footnote numbering is retained (in most cases – consecutive footnote numbers retain only the first), the body of the fist footnote will be concatenated to the text if there are several footnotes, while the following get deleted (as does a lone footnote body).

As reproducing this will be easier than trying to describe it, I have prepared two test documents, formd inline link test document and formd reference link test document – I suggest downloading those and trying out what happens on flipping to get a clearer grip on the issue.

seth-brown commented 12 years ago

Thanks for the detailed description and sample MMD documents. I've update formd to, I think, correct the bug you're describing. Both inline and reference documents seem to be the same? Let me know if there are still problems after the patch. Thanks!

kopischke commented 12 years ago

Whoa, that was fast. I just tested the newly committed changes, and it’s almost there: footnotes are preserved (yay!), but the paragraph break before the first footnote is AWOL after flipping (which effectively kills it as a footnote, as footnotes need to be separate paragraphs). PS: The only difference between the two documents is the link in the body text (inline / reference) – the link in the footnote is inlined in both. Not a big difference, I’ll admit, but I thought that sufficient as a baseline test case :).

seth-brown commented 12 years ago

Ok, thanks for the update. Curiously, I do not see this error. I'm in the middle of moving across the country, so I'll try and look into this over the next few days. Sorry for the troubles.

kopischke commented 12 years ago

I think I found the cause: the multiline URL line break removing code in _link is stripping the line breaks (commenting it out and yielding linkmakes the error go away), because the links RE will match a string from a final footnote number to the beginning of the first footnote, thus erroneously identifying it as a multiline link. I’ve submitted a pull request correcting the RE which seems to solve this in my testing.

derdennis commented 11 years ago

I want to thank both of you for the work you put in to make formd compatible with MultiMarkdown footnotes.

I still have trouble. All my footnotes disappear, when I use formd to convert my text.

Allow me to show an example:

This is before formd -r is run (Usually in vim, but I have the exact same problem when using formd on the commandline...):

Hello, this is a link to [Google](http://google.com).

This is some text with a footnote[^fn1].

Some other text with another footnote[^fn2].

And here is a link to [formd](https://github.com/drbunsen/formd).

[^fn1]: Such a nice footnote

[^fn2]: I love me some footnotes

And this is it after the run:

Hello, this is a link to [Google][1].

This is some text with a footnote[^fn1].

Some other text with another footnote[^fn2].

And here is a link to [formd][2].

[1]: http://google.com
[2]: https://github.com/drbunsen/formd

Links converted as requested, inline footnote markers still present, footnote content at the end of the file missing.

So, do you have any idea, what could be causing this trouble? I tried omitting the fn and just use numbers but it didn't help...

Is this reproducable with your setup? Could you have a look at this? Please let me know if you need additional information.

Thank you again for your great work and your time.

seth-brown commented 11 years ago

My fault. I shuffled a few things around and clobbered the previous code that handled MMD footnotes. Footnotes should now be handled correctly. Please let me know if you have further trouble.

derdennis commented 11 years ago

Works beautiful!

Never mind the clobbering. Happens to me all the time. Now that it's fixed, I'm a very happy camper.

Thank you again.