shore(composer): update parsedown and update namespace

BREAKING_CHANGE : Pico::parseFileContent parameter $singleLineis not needed

BREAKING_CHANGE : $config['content_config']['escape'] and
$config['content_config']['auto_urls'] are not used
This commit is contained in:
Jérémy Dufraisse 2023-12-25 13:57:47 +01:00
parent 869ab1f2e0
commit e8795f158e
2 changed files with 16 additions and 12 deletions

View File

@ -35,8 +35,8 @@
"ext-mbstring": "*", "ext-mbstring": "*",
"twig/twig": "^3.3.8", "twig/twig": "^3.3.8",
"symfony/yaml" : "^5.4.3", "symfony/yaml" : "^5.4.3",
"erusev/parsedown": "1.7.4", "erusev/parsedown": "^2.0.0-beta-1",
"erusev/parsedown-extra": "0.8.1" "erusev/parsedown-extra": "^2.0.0-beta-1"
}, },
"suggest": { "suggest": {
"picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme.", "picocms/pico-theme": "Pico requires a theme to actually display the contents of your website. This is Pico's official default theme.",

View File

@ -61,6 +61,12 @@ use Twig\TwigFilter;
* @license https://opensource.org/licenses/MIT The MIT License * @license https://opensource.org/licenses/MIT The MIT License
* @version 3.0 * @version 3.0
*/ */
use Erusev\Parsedown\Configurables\Breaks;
use Erusev\Parsedown\Parsedown;
use Erusev\Parsedown\State;
use Erusev\ParsedownExtra\ParsedownExtra;
class Pico class Pico
{ {
/** /**
@ -1587,15 +1593,13 @@ class Pico
public function getParsedown(): Parsedown public function getParsedown(): Parsedown
{ {
if ($this->parsedown === null) { if ($this->parsedown === null) {
$state = new State([
new Breaks((bool) $this->config['content_config']['breaks'])
]);
if ($this->config['content_config']['extra']){ if ($this->config['content_config']['extra']){
$this->parsedown = new ParsedownExtra(); $state = new ParsedownExtra($state);
} else {
$this->parsedown = new Parsedown();
} }
$this->parsedown = new Parsedown($state);
$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']);
$this->triggerEvent('onParsedownRegistered', [ &$this->parsedown ]); $this->triggerEvent('onParsedownRegistered', [ &$this->parsedown ]);
} }
@ -1711,14 +1715,14 @@ class Pico
* @see Pico::getFileContent() * @see Pico::getFileContent()
* *
* @param string $markdown Markdown contents of a page * @param string $markdown Markdown contents of a page
* @param bool $singleLine whether to parse just a single line of markup * @param bool $singleLine whether to parse just a single line of markup (deprecated because not needed and not used)
* *
* @return string parsed contents (HTML) * @return string parsed contents (HTML)
*/ */
public function parseFileContent(string $markdown, bool $singleLine = false): string public function parseFileContent(string $markdown, bool $singleLine = false): string
{ {
$markdownParser = $this->getParsedown(); $markdownParser = $this->getParsedown();
return !$singleLine ? @$markdownParser->text($markdown) : @$markdownParser->line($markdown); return @$markdownParser->toHtml($markdown);
} }
/** /**