5

Markdown is probably broken. When I try to submit question/answer with

[![](http://phpcode.eu/images/1316518785.php)][1]

[1]: http://stackoverflow.com

it doesn't work, but when I write it with the classic parentheses, it works perfectly:

[![](http://phpcode.eu/images/1316518785.php)](http://stackoverflow.com)

Proof:

  • First

[](http://phpcode.eu/images/1316518785.php) http://stackoverflow.com

  • Second

http://phpcode.eu/images/1316518785.php

The first one is shown wrongly, after submission and while previewing.

3 Answers 3

6

This is getting into an area where Markdown's ambiguities and lenience aren't fixable, because by removing one edge case, you're creating two others. Since this isn't a particularly exciting issue, I'll leave it be; there are enough ways to accomplish what you're trying (related: What's the recommended syntax for an image with a link?), and the new problems that would be introduced by a fix are probably worse than what you have now.

One thing I'm changing though (next build), is the particular way in which this breaks, so it stops creating broken HTML (which then gets eaten by the sanitizer).

After this change, the created HTML still isn't what you expect, but it's a) valid, and b) it makes clear what happens here:

[![](http://phpcode.eu/images/1316518785.php)][1]

is understood like this:

[              just an open bracket; regular text
![             start of an image
    ...        the image alt text
]              the end of the alt text
[1]            the reference to the image link

so what you're getting in the generated HTML is this (line breaks inserted for clarification):

[<img
      src="http://stackoverflow.com"
      alt="](http://phpcode.eu/images/1316518785.php)"
 >
4
  • Will be my question corrected in next build or should be there dummy edit? (is preview converted from markdown in realtime or is it static?)
    – genesis
    Commented Sep 20, 2011 at 13:46
  • The preview is obviously generated in realtime; the displayed post is only re-rendered when submitting an edit.
    – balpha StaffMod
    Commented Sep 20, 2011 at 13:57
  • I have meant, if post, as I can see now, will be automatical fixed, corrected or should I edit it? From your comment, I assume I should edit that
    – genesis
    Commented Sep 20, 2011 at 13:58
  • This was basically what we were talking about in chat the other day. While I certainly trust you more than myself, I don't immediately see what new edge cases would be created by applying the nested brackets pattern that the anchor regexes already use. The way things are now, even the ![alt](img) some text [link][ref] case breaks.
    – Tim Stone
    Commented Aug 2, 2012 at 9:11
3

It works, if you use the following Markdown:

[![screenshot][2]][1]


 [1]: http://stackoverflow.com
 [2]: http://phpcode.eu/images/1316518785.php

 

screenshot http://phpcode.eu/images/1316518785.php

1
  • Isn't it still a bug though?
    – genesis
    Commented Sep 20, 2011 at 12:13
0

there is another way you can do,

[ ![1][2]][2]

[1]: http://stackoverflow.com
[2]: http://phpcode.eu/images/1316518785.php

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .