Upgrade to 3.7.1
This commit is contained in:
@@ -20,62 +20,62 @@ use ParsedownExtra;
|
||||
*/
|
||||
class Markdown
|
||||
{
|
||||
/**
|
||||
* Array with all configured options
|
||||
* for the parser
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
/**
|
||||
* Array with all configured options
|
||||
* for the parser
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $options = [];
|
||||
|
||||
/**
|
||||
* Returns default values for all
|
||||
* available parser options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function defaults(): array
|
||||
{
|
||||
return [
|
||||
'breaks' => true,
|
||||
'extra' => false,
|
||||
'safe' => false
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Returns default values for all
|
||||
* available parser options
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function defaults(): array
|
||||
{
|
||||
return [
|
||||
'breaks' => true,
|
||||
'extra' => false,
|
||||
'safe' => false
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Markdown parser
|
||||
* with the given options
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = array_merge($this->defaults(), $options);
|
||||
}
|
||||
/**
|
||||
* Creates a new Markdown parser
|
||||
* with the given options
|
||||
*
|
||||
* @param array $options
|
||||
*/
|
||||
public function __construct(array $options = [])
|
||||
{
|
||||
$this->options = array_merge($this->defaults(), $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given text and returns the HTML
|
||||
*
|
||||
* @param string|null $text
|
||||
* @param bool $inline
|
||||
* @return string
|
||||
*/
|
||||
public function parse(string $text = null, bool $inline = false): string
|
||||
{
|
||||
if ($this->options['extra'] === true) {
|
||||
$parser = new ParsedownExtra();
|
||||
} else {
|
||||
$parser = new Parsedown();
|
||||
}
|
||||
/**
|
||||
* Parses the given text and returns the HTML
|
||||
*
|
||||
* @param string|null $text
|
||||
* @param bool $inline
|
||||
* @return string
|
||||
*/
|
||||
public function parse(string $text = null, bool $inline = false): string
|
||||
{
|
||||
if ($this->options['extra'] === true) {
|
||||
$parser = new ParsedownExtra();
|
||||
} else {
|
||||
$parser = new Parsedown();
|
||||
}
|
||||
|
||||
$parser->setBreaksEnabled($this->options['breaks']);
|
||||
$parser->setSafeMode($this->options['safe']);
|
||||
$parser->setBreaksEnabled($this->options['breaks']);
|
||||
$parser->setSafeMode($this->options['safe']);
|
||||
|
||||
if ($inline === true) {
|
||||
return @$parser->line($text);
|
||||
} else {
|
||||
return @$parser->text($text);
|
||||
}
|
||||
}
|
||||
if ($inline === true) {
|
||||
return @$parser->line($text);
|
||||
} else {
|
||||
return @$parser->text($text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user