mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Add parameter to MarkdownToHtml for inline HTML
This commit is contained in:
parent
7bd08087dc
commit
e25993b208
3 changed files with 8 additions and 16 deletions
|
@ -99,25 +99,17 @@ class Formatter{
|
|||
/**
|
||||
* Convert a string of Markdown into an HTML fragment.
|
||||
*/
|
||||
public static function MarkdownToHtml(?string $text): string{
|
||||
public static function MarkdownToHtml(?string $text, bool $inline = false): string{
|
||||
if(!isset(Formatter::$_MarkdownParser)){
|
||||
Formatter::$_MarkdownParser = new Parsedown();
|
||||
Formatter::$_MarkdownParser->setSafeMode(true);
|
||||
}
|
||||
|
||||
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);
|
||||
if($inline){
|
||||
return Formatter::$_MarkdownParser->line($text);
|
||||
}else{
|
||||
return Formatter::$_MarkdownParser->text($text);
|
||||
}
|
||||
|
||||
return Formatter::$_MarkdownParser->line($text);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue