code: public function processReferencedImage(Text $text, array $options = array())
      {
          if (!$text->contains('![')) {
              return;
          }
  
          /** @noinspection PhpUnusedParameterInspection */
          $text->replace(
              '{
                  #(               # wrap whole match in $1
                    !\[
                      (.*?)       # alt text = $2
                    \]
  
                    [ ]?          # one optional space
                    (?:\n[ ]*)?   # one optional newline followed by spaces
  
                    \[
                      (.*?)       # id = $3
                    \]
                  #)
              }xs',
              function (Text $whole, Text $alt, Text $id = null) use ($options) {
                  $result = null;
  
                  if ($id->lower() == '') {
                      $id->setString($alt);
                  }
  
                  $this->markdown->emit('escape.special_chars', [$alt->replace('/(?<!\\\\)_/', '\\\\_')]);
  
                  $attr = array(
                      'alt' => $alt->replace('/"/', '&quot;')
                  );
  
                  if ($this->markdown->getUrlRegistry()->exists($id)) {
                      $url = new Text($this->markdown->getUrlRegistry()->get($id));
                      $url->escapeHtml();
  
                      if ($this->markdown->getTitleRegistry()->exists($id)) {
                          $title = new Text($this->markdown->getTitleRegistry()->get($id));
                          $attr['title'] = $title->escapeHtml();
                      }
  
                      return $this->getRenderer()->renderImage($url, array('attr' => $attr));
                  } else {
                      if ($options['strict']) {
                          throw new SyntaxError(
                              sprintf('Unable to find id "%s" in Reference-style image', $id),
                              $this, $whole, $this->markdown
                          );
                      }
  
                      return $whole;
                  }
              }
          );
      }
docs: Handle reference-style labeled images: ![alt text][id]
  
  @param Text  $text
  @param array $options