mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 03:16:36 -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);
|
||||
}
|
||||
|
||||
if($inline){
|
||||
return Formatter::$_MarkdownParser->line($text);
|
||||
}else{
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -161,12 +161,12 @@ catch(Exceptions\InvalidPermissionsException){
|
|||
|
||||
<? if($artwork->Exception !== null){ ?>
|
||||
<h3>Public domain status exception reason</h3>
|
||||
<?= Formatter::MarkdownToHtml($artwork->Exception) ?>
|
||||
<?= Formatter::MarkdownToHtml($artwork->Exception, false) ?>
|
||||
<? } ?>
|
||||
|
||||
<? if($artwork->Notes !== null){ ?>
|
||||
<h2>Special notes</h2>
|
||||
<?= Formatter::MarkdownToHtml($artwork->Notes) ?>
|
||||
<?= Formatter::MarkdownToHtml($artwork->Notes, false) ?>
|
||||
<? } ?>
|
||||
|
||||
<? if($artwork->CanBeEditedBy(Session::$User)){ ?>
|
||||
|
|
|
@ -18,7 +18,7 @@ function WantedEbooks(Enums\EbookPlaceholderDifficulty $difficulty, ?bool $showP
|
|||
<? } ?>
|
||||
by <?= Formatter::EscapeHtml($ebook->AuthorsString) ?><? if($ebook->ContributorsHtml != ''){ ?>. <? } ?>
|
||||
<?= $ebook->ContributorsHtml ?>
|
||||
<? if(isset($ebook->EbookPlaceholder->Notes)){ ?>(<?= Formatter::MarkdownToInlineHtml($ebook->EbookPlaceholder->Notes) ?>)<? } ?>
|
||||
<? if(isset($ebook->EbookPlaceholder->Notes)){ ?>(<?= Formatter::MarkdownToHtml($ebook->EbookPlaceholder->Notes, true) ?>)<? } ?>
|
||||
<? if($showPlaceholderMetadata){ ?>
|
||||
<p>Ebook ID: <?= $ebook->EbookId ?>, <a href="<?= $ebook->Url ?>">View placeholder</a></p>
|
||||
<? } ?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue