* @license https://files.froxlor.org/misc/COPYING.txt GPLv2 */ namespace Froxlor\System; use League\CommonMark\Exception\CommonMarkException; use League\CommonMark\GithubFlavoredMarkdownConverter; class Markdown { private static $converter = null; public static function converter(): ?GithubFlavoredMarkdownConverter { if (is_null(self::$converter)) { self::$converter = new GithubFlavoredMarkdownConverter([ 'html_input' => 'strip', 'allow_unsafe_links' => false, ]); } return self::$converter; } public static function cleanCustomNotes(string $note = ""): string { if (!empty($note)) { try { $note = self::converter()->convert($note)->getContent(); } catch (CommonMarkException $e) { $note = ""; } } return $note; } }