stephenharris/WP-MarkDown

Images as links do not work

stephenharris opened this issue · 2 comments

As posted here http://wordpress.org/support/topic/close-but-not-polished?replies=3#post-4032749

[![Adobe Bucks][2]][1]

[1]: http://google.com/
[2]: http://google.com/logo.png

Causes the MarkDown to be corrupted and the following error:

Notice: Undefined index: linkID in /var/www/git/WP-MarkDown/markdownify/markdownify.php on line 412

The post previews fine so the problem lies in the HTML -> MarkDown converter.

Turns out MarkDownify messes up the stack - it assumes the last thing (link) pushed to the stack is the url of the link when parsing. So if you add additional tags to the stack (in this instance an image), it thinks this what the link should point to.

The stack contains other details - attributes, reference ID (1 and 2 in the above) - and this mix up causes the above error.

This fixed it for me. Thanks!