From 93544d1f296def4b2af3d92af63d617fb9323c85 Mon Sep 17 00:00:00 2001 From: trendschau Date: Fri, 7 Jun 2024 06:45:32 +0200 Subject: [PATCH] V.2.6.0 Improve markdown extension to process shortcodes inside theme markdown input --- .../Extensions/TwigMarkdownExtension.php | 19 +++++++++++++++++-- system/typemill/system.php | 5 ++--- themes/cyanine/layout.twig | 4 ++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/system/typemill/Extensions/TwigMarkdownExtension.php b/system/typemill/Extensions/TwigMarkdownExtension.php index f025b66..0685974 100644 --- a/system/typemill/Extensions/TwigMarkdownExtension.php +++ b/system/typemill/Extensions/TwigMarkdownExtension.php @@ -8,6 +8,21 @@ use Typemill\Extensions\ParsedownExtension; class TwigMarkdownExtension extends AbstractExtension { + protected $dispatcher; + + protected $settings; + + protected $baseurl; + + public function __construct($baseurl, $settings, $dispatcher) + { + $this->dispatcher = $dispatcher; + + $this->settings = $settings; + + $this->baseurl = $baseurl; + } + public function getFunctions() { return [ @@ -17,8 +32,8 @@ class TwigMarkdownExtension extends AbstractExtension public function renderMarkdown($markdown) { - $parsedown = new ParsedownExtension(); - + $parsedown = new ParsedownExtension($this->baseurl, $this->settings, $this->dispatcher); + $markdownArray = $parsedown->text($markdown); return $parsedown->markup($markdownArray); diff --git a/system/typemill/system.php b/system/typemill/system.php index ea1d793..14aa1ea 100644 --- a/system/typemill/system.php +++ b/system/typemill/system.php @@ -73,7 +73,6 @@ if(isset($settings['displayErrorDetails']) && $settings['displayErrorDetails']) ini_set('display_errors', $display_errors); } - /**************************** * CREATE CONTAINER + APP * ****************************/ @@ -299,7 +298,7 @@ $container->set('assets', function() use ($assets){ return $assets; }); * TWIG TO CONTAINER * ****************************/ -$container->set('view', function() use ($settings, $urlinfo, $translations) { +$container->set('view', function() use ($settings, $urlinfo, $translations, $dispatcher) { $twig = Twig::create( [ @@ -325,7 +324,7 @@ $container->set('view', function() use ($settings, $urlinfo, $translations) { $twig->addExtension(new TwigUserExtension()); $twig->addExtension(new TwigUrlExtension($urlinfo)); $twig->addExtension(new TwigLanguageExtension( $translations )); - $twig->addExtension(new TwigMarkdownExtension()); + $twig->addExtension(new TwigMarkdownExtension($urlinfo['baseurl'], $settings, $dispatcher)); $twig->addExtension(new TwigMetaExtension()); $twig->addExtension(new TwigPagelistExtension()); $twig->addExtension(new TwigCaptchaExtension()); diff --git a/themes/cyanine/layout.twig b/themes/cyanine/layout.twig index 9b2e85d..62b8469 100644 --- a/themes/cyanine/layout.twig +++ b/themes/cyanine/layout.twig @@ -177,8 +177,6 @@ {% endif %} - - {{ assets.renderCSS() }} {% endblock %} @@ -246,6 +244,8 @@ {% endif %} + {{ assets.renderCSS() }} + {{ assets.renderJS() }} {% endblock %}