You are here

protected function Markdown::_doAnchors_reference_callback in Express 8

* Callback method to parse referenced anchors *

Parameters

string $matches: * @return string

1 method overrides Markdown::_doAnchors_reference_callback()
MarkdownExtra::_doAnchors_reference_callback in vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
* Callback for reference anchors *

File

vendor/michelf/php-markdown/Michelf/Markdown.php, line 723

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function _doAnchors_reference_callback($matches) {
  $whole_match = $matches[1];
  $link_text = $matches[2];
  $link_id =& $matches[3];
  if ($link_id == "") {

    // for shortcut links like [this][] or [this].
    $link_id = $link_text;
  }

  // lower-case and turn embedded newlines into spaces
  $link_id = strtolower($link_id);
  $link_id = preg_replace('{[ ]?\\n}', ' ', $link_id);
  if (isset($this->urls[$link_id])) {
    $url = $this->urls[$link_id];
    $url = $this
      ->encodeURLAttribute($url);
    $result = "<a href=\"{$url}\"";
    if (isset($this->titles[$link_id])) {
      $title = $this->titles[$link_id];
      $title = $this
        ->encodeAttribute($title);
      $result .= " title=\"{$title}\"";
    }
    $link_text = $this
      ->runSpanGamut($link_text);
    $result .= ">{$link_text}</a>";
    $result = $this
      ->hashPart($result);
  }
  else {
    $result = $whole_match;
  }
  return $result;
}