public function render(AbstractInline $inline, ElementRendererInterface $htmlRenderer)
{
if (!$inline instanceof Link) {
throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
}
$attrs = [];
foreach ($inline->getData('attributes', []) as $key => $value) {
$attrs[$key] = $htmlRenderer->escape($value, true);
}
$forbidUnsafeLinks = $this->config->getConfig('safe') || !$this->config->getConfig('allow_unsafe_links');
if (!($forbidUnsafeLinks && RegexHelper::isLinkPotentiallyUnsafe($inline->getUrl()))) {
$attrs['href'] = $htmlRenderer->escape($inline->getUrl(), true);
}
if (isset($inline->data['title'])) {
$attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
}
return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->children()));
}