protected function parseHrefAttributes(?array $attributes) : ?string
    {
        if (empty($attributes)) {
            return null;
        }

        if (isset($attributes['target']) && $attributes['target'] === '_blank') {
            if (!isset($attributes['rel'])) {
                $attributes['rel'] = 'noreferrer noopener';
            }
        }

        $extra = [];

        foreach ($attributes as $attr => $value) {
            $extra[] = $attr . '="' . $value . '"';
        }

        return ' ' . implode(' ', $extra);
    }