getUrl(); // empty urls and anchors should // not go through the url resolver if (!$this->isValidUrl($url)) { return $element; } // Absolute urls, shouldn't either if ($this->isExternalUrl($url)) { $element->setAttribute('class', 'Link--external'); return $element; } // if there's a hash component in the url, we can directly use it as all pages are in the same file $urlAndHash = explode('#', $url); if (isset($urlAndHash[1])) { $element->setAttribute('href', '#' . $urlAndHash[1]); return $element; } try { $file = $this->resolveInternalFile($url); $url = $file->getUrl(); } catch (LinkNotFoundException $e) { if ($this->daux->isStatic()) { throw $e; } $element->setAttribute('class', 'Link--broken'); } $url = str_replace('/', '_', $url); $element->setAttribute('href', "#file_$url"); return $element; } }