From 0359119a118ba4a85931996a12859a356d9bf998 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Fri, 27 Dec 2024 00:08:39 -0700 Subject: [PATCH] Add Formatter::MarkdownToInlineHtml() HTML without the surrounding `

` tags will be useful to show placeholder notes to admins on the wanted ebooks page. Examples of generating block-level and inline HTML: https://github.com/erusev/parsedown/wiki/Tutorial:-Get-Started --- lib/Formatter.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/Formatter.php b/lib/Formatter.php index 52270e19..93a447aa 100644 --- a/lib/Formatter.php +++ b/lib/Formatter.php @@ -108,6 +108,18 @@ class Formatter{ return Formatter::$_MarkdownParser->text($text); } + /** + * Convert a string of Markdown into inline HTML. + */ + public static function MarkdownToInlineHtml(?string $text): string{ + if(!isset(Formatter::$_MarkdownParser)){ + Formatter::$_MarkdownParser = new Parsedown(); + Formatter::$_MarkdownParser->setSafeMode(true); + } + + return Formatter::$_MarkdownParser->line($text); + } + /** * Given a number of bytes, return a string containing a human-readable filesize. *