Add Formatter::MarkdownToInlineHtml()

HTML without the surrounding `<p>` 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
This commit is contained in:
Mike Colagrosso 2024-12-27 00:08:39 -07:00 committed by Alex Cabal
parent 9652d63b12
commit 0359119a11

View file

@ -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.
*