Repository: Python-Markdown/markdown (python)

Issue:
image short-reference links not supported
Hi, 

I've encountered an unexpected behavior:

Markdown:
```
[![Build Status]](https://travis-ci.org/commonmark/cmark)


[Build Status]: https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat
```

Produces 
```
<p>
  <a href="https://travis-ci.org/commonmark/cmark">![Build Status]</a>
</p>
```

Expected behavior: (inserted the above markdown snippet as is into this issue)

[![Build Status]](https://travis-ci.org/commonmark/cmark)

[Build Status]: https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat

or in html:
```
<p>
  <a href="https://travis-ci.org/commonmark/cmark"><img src="https://img.shields.io/travis/commonmark/cmark/master.svg?style=flat" alt="Build Status"></a>
</p>
```
In babel:

https://babelmark.github.io/?text=%5B!%5BBuild+Status%5D%5D(https%3A%2F%2Ftravis-ci.org%2Fcommonmark%2Fcmark)%0A%0A%0A%5BBuild+Status%5D%3A+https%3A%2F%2Fimg.shields.io%2Ftravis%2Fcommonmark%2Fcmark%2Fmaster.svg%3Fstyle%3Dflat



Pull request description:
Support short reference image links.
Fixes #894.

@facelessuser this was the first time I've done any work on inline handling code since your inline refactor. This was so easy I thought I must be missing something. Awesome! 🥇 

Patch:
diff --git a/docs/change_log/release-3.3.md b/docs/change_log/release-3.3.md
index 0e0bb89..897308c 100644
--- a/docs/change_log/release-3.3.md
+++ b/docs/change_log/release-3.3.md
@@ -70,6 +70,7 @@ The following new features have been included in the 3.3 release:
 
 The following bug fixes are included in the 3.3 release:
 
+* Support short reference image links (#894).
 * Avoid a `RecursionError` from deeply nested blockquotes (#799).
 * Fix issues with complex emphasis (#979).
 * Fix unescaping of HTML characters `<>` in CodeHilite (#990).
diff --git a/markdown/inlinepatterns.py b/markdown/inlinepatterns.py
index 0655047..1d0a7e1 100644
--- a/markdown/inlinepatterns.py
+++ b/markdown/inlinepatterns.py
@@ -84,6 +84,9 @@ def build_inlinepatterns(md, **kwargs):
     inlinePatterns.register(
         ShortReferenceInlineProcessor(REFERENCE_RE, md), 'short_reference', 130
     )
+    inlinePatterns.register(
+        ShortImageReferenceInlineProcessor(IMAGE_REFERENCE_RE, md), 'short_image_ref', 125
+    )
     inlinePatterns.register(AutolinkInlineProcessor(AUTOLINK_RE, md), 'autolink', 120)
     inlinePatterns.register(AutomailInlineProcessor(AUTOMAIL_RE, md), 'automail', 110)
     inlinePatterns.register(SubstituteTagInlineProcessor(LINE_BREAK_RE, 'br'), 'linebreak', 100)
@@ -844,6 +847,14 @@ class ImageReferenceInlineProcessor(ReferenceInlineProcessor):
         return el
 
 
+class ShortImageReferenceInlineProcessor(ImageReferenceInlineProcessor):
+    """ Short form of inage reference: ![ref]. """
+    def evalId(self, data, index, text):
+        """Evaluate the id from of [ref]  """
+
+        return text.lower(), index, True
+
+
 class AutolinkInlineProcessor(InlineProcessor):
     """ Return a link Element given an autolink (`<http://example/com>`). """
     def handleMatch(self, m, data):


Test patch:
diff --git a/tests/test_syntax/inline/test_images.py b/tests/test_syntax/inline/test_images.py
index 261c24b..c9c7cb8 100644
--- a/tests/test_syntax/inline/test_images.py
+++ b/tests/test_syntax/inline/test_images.py
@@ -158,3 +158,27 @@ class TestAdvancedImages(TestCase):
             """![Image](http://humane man.jpg)""",
             """<p><img alt="Image" src="http://humane man.jpg" /></p>"""
         )
+
+    def test_short_ref(self):
+        self.assertMarkdownRenders(
+            self.dedent(
+                """
+                ![ref]
+
+                [ref]: ./image.jpg
+                """
+            ),
+            '<p><img alt="ref" src="./image.jpg" /></p>'
+        )
+
+    def test_short_ref_in_link(self):
+        self.assertMarkdownRenders(
+            self.dedent(
+                """
+                [![img ref]](http://example.com/)
+
+                [img ref]: ./image.jpg
+                """
+            ),
+            '<p><a href="http://example.com/"><img alt="img ref" src="./image.jpg" /></a></p>'
+        )