From: Vincent Vanwaelscappel Date: Thu, 3 Dec 2020 13:14:43 +0000 (+0100) Subject: wip #3753 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=dad8db62e00e6c44c344c2b7443272a13cd574c4;p=cubist_cms-back.git wip #3753 --- diff --git a/src/app/Markdown/InternaLink/Extension.php b/src/app/Markdown/InternaLink/Extension.php deleted file mode 100644 index 0e826be..0000000 --- a/src/app/Markdown/InternaLink/Extension.php +++ /dev/null @@ -1,17 +0,0 @@ -addInlineRenderer(Link::class, new Renderer(), 10); - } -} diff --git a/src/app/Markdown/InternaLink/Renderer.php b/src/app/Markdown/InternaLink/Renderer.php deleted file mode 100644 index ce724da..0000000 --- a/src/app/Markdown/InternaLink/Renderer.php +++ /dev/null @@ -1,49 +0,0 @@ -getData('attributes', []); - - - $href = $inline->getUrl(); - if (stristr($href, 'internal:')) { - $href = Menu::internalToHref($href); - } - $attrs['href'] = $href; - - if (isset($inline->data['title'])) { - $attrs['title'] = $inline->data['title']; - } - - if (isset($attrs['target']) && $attrs['target'] === '_blank' && !isset($attrs['rel'])) { - $attrs['rel'] = 'noopener noreferrer'; - } - - return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children())); - } - -} diff --git a/src/app/Markdown/InternalLink/Extension.php b/src/app/Markdown/InternalLink/Extension.php new file mode 100644 index 0000000..0e826be --- /dev/null +++ b/src/app/Markdown/InternalLink/Extension.php @@ -0,0 +1,17 @@ +addInlineRenderer(Link::class, new Renderer(), 10); + } +} diff --git a/src/app/Markdown/InternalLink/Renderer.php b/src/app/Markdown/InternalLink/Renderer.php new file mode 100644 index 0000000..ce724da --- /dev/null +++ b/src/app/Markdown/InternalLink/Renderer.php @@ -0,0 +1,49 @@ +getData('attributes', []); + + + $href = $inline->getUrl(); + if (stristr($href, 'internal:')) { + $href = Menu::internalToHref($href); + } + $attrs['href'] = $href; + + if (isset($inline->data['title'])) { + $attrs['title'] = $inline->data['title']; + } + + if (isset($attrs['target']) && $attrs['target'] === '_blank' && !isset($attrs['rel'])) { + $attrs['rel'] = 'noopener noreferrer'; + } + + return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children())); + } + +}