Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -12,9 +12,10 @@ namespace App\Utils;
|
||||
/**
|
||||
* This Class extends the default Parsedown Class for custom methods.
|
||||
*/
|
||||
class ParsedownExtension extends \Parsedown
|
||||
final class ParsedownExtension extends \Parsedown
|
||||
{
|
||||
private $ids = [];
|
||||
/** @var array<string> */
|
||||
private array $ids = [];
|
||||
|
||||
/**
|
||||
* Overwritten to prevent # to show up as headings for two reasons:
|
||||
@@ -71,16 +72,16 @@ class ParsedownExtension extends \Parsedown
|
||||
* - added support for file:///
|
||||
* - open links in new windows
|
||||
*/
|
||||
protected function inlineUrl($Excerpt)
|
||||
protected function inlineUrl($Excerpt): ?array
|
||||
{
|
||||
if ($this->urlsLinked !== true or !isset($Excerpt['text'][2]) or $Excerpt['text'][2] !== '/') {
|
||||
return;
|
||||
return null;
|
||||
}
|
||||
|
||||
if (preg_match('/\b(https?:[\/]{2}|file:[\/]{3})[^\s<]+\b\/*/ui', $Excerpt['context'], $matches, PREG_OFFSET_CAPTURE)) {
|
||||
$url = $matches[0][0];
|
||||
|
||||
$Inline = [
|
||||
return [
|
||||
'extent' => \strlen($matches[0][0]),
|
||||
'position' => $matches[0][1],
|
||||
'element' => [
|
||||
@@ -92,14 +93,14 @@ class ParsedownExtension extends \Parsedown
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $Inline;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function blockHeader($line)
|
||||
protected function blockHeader($Line)
|
||||
{
|
||||
$block = parent::blockHeader($line);
|
||||
$block = parent::blockHeader($Line);
|
||||
|
||||
$text = $block['element']['text'];
|
||||
$id = $this->getIDfromText($text);
|
||||
@@ -151,8 +152,8 @@ class ParsedownExtension extends \Parsedown
|
||||
{
|
||||
$Block = parent::blockTable($Line, $Block);
|
||||
|
||||
if (\is_null($Block)) {
|
||||
return;
|
||||
if ($Block === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$Block['element']['attributes']['class'] = 'table';
|
||||
|
||||
Reference in New Issue
Block a user