From fca0c92b606ed2351445cb045688214da04abb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Dufraisse?= Date: Mon, 27 Feb 2023 09:06:39 +0100 Subject: [PATCH] fix(Pico): call to new parsedown --- lib/Pico.php | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/Pico.php b/lib/Pico.php index 37057aa..0bab820 100644 --- a/lib/Pico.php +++ b/lib/Pico.php @@ -43,7 +43,9 @@ * @version 3.0 */ +use Erusev\Parsedown\Configurables\Breaks; use Erusev\Parsedown\Parsedown; +use Erusev\Parsedown\State; use Erusev\ParsedownExtra\ParsedownExtra; class Pico @@ -1565,12 +1567,13 @@ class Pico public function getParsedown() { if ($this->parsedown === null) { - $className = $this->config['content_config']['extra'] ? ParsedownExtra::class : Parsedown::class; - $this->parsedown = new $className(); - - $this->parsedown->setBreaksEnabled((bool) $this->config['content_config']['breaks']); - $this->parsedown->setMarkupEscaped((bool) $this->config['content_config']['escape']); - $this->parsedown->setUrlsLinked((bool) $this->config['content_config']['auto_urls']); + $state = new State([ + new Breaks((bool) $this->config['content_config']['breaks']) + ]); + if ($this->config['content_config']['extra']){ + $state = new ParsedownExtra($state); + } + $this->parsedown = new Parsedown($state); $this->triggerEvent('onParsedownRegistered', array(&$this->parsedown)); } @@ -1670,14 +1673,13 @@ class Pico * @see Pico::getFileContent() * * @param string $markdown Markdown contents of a page - * @param bool $singleLine whether to parse just a single line of markup * * @return string parsed contents (HTML) */ - public function parseFileContent($markdown, $singleLine = false) + public function parseFileContent($markdown) { $markdownParser = $this->getParsedown(); - return !$singleLine ? @$markdownParser->text($markdown) : @$markdownParser->line($markdown); + return @$markdownParser->toHtml($markdown); } /**