You are here

protected function Markdown::_doAnchors_inline_callback in Markdown 7

* Callback method to parse inline anchors *

Parameters

string $matches: * @return string

1 method overrides Markdown::_doAnchors_inline_callback()
MarkdownExtra::_doAnchors_inline_callback in includes/MarkdownExtra.php
* Callback for inline anchors *

File

includes/Markdown.php, line 762

Class

Markdown
Markdown Parser Class

Namespace

Michelf

Code

protected function _doAnchors_inline_callback($matches) {
  $whole_match = $matches[1];
  $link_text = $this
    ->runSpanGamut($matches[2]);
  $url = $matches[3] == '' ? $matches[4] : $matches[3];
  $title =& $matches[7];

  // If the URL was of the form <s p a c e s> it got caught by the HTML
  // tag parser and hashed. Need to reverse the process before using
  // the URL.
  $unhashed = $this
    ->unhash($url);
  if ($unhashed != $url) {
    $url = preg_replace('/^<(.*)>$/', '\\1', $unhashed);
  }
  $url = $this
    ->encodeURLAttribute($url);
  $result = "<a href=\"{$url}\"";
  if (isset($title)) {
    $title = $this
      ->encodeAttribute($title);
    $result .= " title=\"{$title}\"";
  }
  $link_text = $this
    ->runSpanGamut($link_text);
  $result .= ">{$link_text}</a>";
  return $this
    ->hashPart($result);
}