['href'], 'article' => [], 'audio' => ['src', 'controls', 'preload'], 'b' => [], 'blockquote' => [], 'br' => [], 'caption' => [], 'code' => [], 'dd' => [], 'details' => [], 'div' => ['role', 'aria-label', 'tabindex'], 'dl' => [], 'dt' => [], 'em' => [], 'h1' => [], 'h2' => [], 'h3' => [], 'h4' => [], 'h5' => [], 'h6' => [], 'hr' => [], 'i' => [], 'img' => ['src', 'alt', 'loading', 'width', 'height'], 'label' => ['for'], 'li' => [], 'ol' => [], 'p' => [], 'pre' => [], 'progress' => ['max', 'value'], 's' => [], 'small' => [], 'source' => ['src', 'type'], 'span' => [], 'strong' => [], 'summary' => [], 'table' => [], 'tbody' => [], 'td' => ['colspan', 'rowspan'], 'tfoot' => [], 'th' => ['scope', 'colspan', 'rowspan'], 'thead' => [], 'tr' => [], 'ul' => [], 'video' => ['src', 'controls', 'muted', 'playsinline', 'poster', 'preload'], ]; public static function url(string $value, bool $media = false): bool { if ($value === '' || preg_match('/[\x00-\x20\x7f\\\\]/', $value)) { return false; } if (str_starts_with($value, '/')) { return !str_starts_with($value, '//'); } if (str_starts_with($value, '#')) { return !$media && strlen($value) > 1; } $scheme = strtolower((string) parse_url($value, PHP_URL_SCHEME)); return in_array($scheme, $media ? ['https'] : ['https', 'http', 'mailto', 'tel'], true); } public static function markdown(string $text): string { static $converter; $converter ??= new CommonMarkConverter(['html_input' => 'strip', 'allow_unsafe_links' => false, 'max_nesting_level' => 30]); $html = $converter->convert($text)->getContent(); return str_replace(['