Add support for anchors on internal links
This commit is contained in:
parent
d6afca69c8
commit
047610f314
@ -87,10 +87,19 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
|||||||
return $element;
|
return $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if there's a hash component in the url, ensure we
|
||||||
|
// don't put that part through the resolver.
|
||||||
|
$urlAndHash = explode("#", $url);
|
||||||
|
$url = $urlAndHash[0];
|
||||||
|
|
||||||
$file = $this->resolveInternalFile($url);
|
$file = $this->resolveInternalFile($url);
|
||||||
|
|
||||||
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
||||||
|
|
||||||
|
if(isset($urlAndHash[1])) {
|
||||||
|
$url .= "#" . $urlAndHash[1];
|
||||||
|
}
|
||||||
|
|
||||||
$element->setAttribute('href', $url);
|
$element->setAttribute('href', $url);
|
||||||
|
|
||||||
return $element;
|
return $element;
|
||||||
|
Loading…
Reference in New Issue
Block a user