What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

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

">

  • Second

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

share|improve this question

3 Answers 3

up vote 5 down vote accepted

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)"
 >
share|improve this answer
    
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 Sep 20 '11 at 13:46
    
The preview is obviously generated in realtime; the displayed post is only re-rendered when submitting an edit. –  balpha Sep 20 '11 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 Sep 20 '11 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 Aug 2 '12 at 9:11

It works, if you use the following Markdown:

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


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

 

screenshot

share|improve this answer
    
Isn't it still a bug though? –  genesis Sep 20 '11 at 12:13

there is another way you can do,

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

[1]: http://stackoverflow.com
[2]: http://phpcode.eu/images/1316518785.php
share|improve this answer

You must log in to answer this question.

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