getUrl(); // empty urls and anchors should // not go through the url resolver if (!DauxHelper::isValidUrl($url)) { return $element; } // Absolute urls, shouldn't either if (DauxHelper::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 = DauxHelper::resolveInternalFile($this->daux, $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; } }