+++ /dev/null
-<?php
-
-namespace Cubist\Backpack\Markdown\InternalLink;
-
-
-use League\CommonMark\Block\Element\Heading;
-use League\CommonMark\ConfigurableEnvironmentInterface;
-use League\CommonMark\Extension\ExtensionInterface;
-use League\CommonMark\Inline\Element\Link;
-
-class Extension implements ExtensionInterface
-{
- public function register(ConfigurableEnvironmentInterface $environment)
- {
- $environment->addInlineRenderer(Link::class, new Renderer(), 10);
- }
-}
+++ /dev/null
-<?php
-
-
-namespace Cubist\Backpack\Markdown\InternalLink;
-
-
-use Cubist\Backpack\Magic\Menu\Menu;
-use League\CommonMark\ElementRendererInterface;
-use League\CommonMark\HtmlElement;
-use League\CommonMark\Inline\Element\AbstractInline;
-use League\CommonMark\Inline\Element\Link;
-use League\CommonMark\Inline\Renderer\InlineRendererInterface;
-
-class Renderer implements InlineRendererInterface
-{
-
- /**
- * @param Link $inline
- * @param ElementRendererInterface $htmlRenderer
- *
- * @return HtmlElement
- */
- public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
- {
- if (!($inline instanceof Link)) {
- throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
- }
-
- $attrs = $inline->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()));
- }
-
-}
--- /dev/null
+<?php
+
+namespace Cubist\Backpack\Markdown\InternalLink;
+
+
+use League\CommonMark\Block\Element\Heading;
+use League\CommonMark\ConfigurableEnvironmentInterface;
+use League\CommonMark\Extension\ExtensionInterface;
+use League\CommonMark\Inline\Element\Link;
+
+class Extension implements ExtensionInterface
+{
+ public function register(ConfigurableEnvironmentInterface $environment)
+ {
+ $environment->addInlineRenderer(Link::class, new Renderer(), 10);
+ }
+}
--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\Markdown\InternalLink;
+
+
+use Cubist\Backpack\Magic\Menu\Menu;
+use League\CommonMark\ElementRendererInterface;
+use League\CommonMark\HtmlElement;
+use League\CommonMark\Inline\Element\AbstractInline;
+use League\CommonMark\Inline\Element\Link;
+use League\CommonMark\Inline\Renderer\InlineRendererInterface;
+
+class Renderer implements InlineRendererInterface
+{
+
+ /**
+ * @param Link $inline
+ * @param ElementRendererInterface $htmlRenderer
+ *
+ * @return HtmlElement
+ */
+ public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
+ {
+ if (!($inline instanceof Link)) {
+ throw new \InvalidArgumentException('Incompatible inline type: ' . \get_class($inline));
+ }
+
+ $attrs = $inline->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()));
+ }
+
+}