From 23e5d81f35eb55babe124259048b567d64d7730f Mon Sep 17 00:00:00 2001 From: Awilum Date: Mon, 11 Nov 2019 01:10:18 +0300 Subject: [PATCH] feat(core): Markdown parsing should be cached in production #287 --- flextype/dependencies.php | 7 ----- flextype/parsers/MarkdownParser.php | 36 +++++++++++++++++++++++++ flextype/twig/MarkdownTwigExtension.php | 6 +---- 3 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 flextype/parsers/MarkdownParser.php diff --git a/flextype/dependencies.php b/flextype/dependencies.php index a617ce36..64a40e55 100644 --- a/flextype/dependencies.php +++ b/flextype/dependencies.php @@ -34,7 +34,6 @@ use League\Glide\Responses\SlimResponseFactory; use League\Glide\ServerFactory; use Monolog\Handler\StreamHandler; use Monolog\Logger; -use ParsedownExtra as Markdown; use Slim\Csrf\Guard; use Slim\Flash\Messages; use Slim\Http\Environment; @@ -202,12 +201,6 @@ $flextype['shortcodes'] = static function ($container) { return new ShortcodeFacade(); }; -/** - * Add Markdown service to Flextype container - */ -$flextype['markdown'] = static function ($container) { - return new Markdown(); -}; /** * Add entries service to Flextype container diff --git a/flextype/parsers/MarkdownParser.php b/flextype/parsers/MarkdownParser.php new file mode 100644 index 00000000..d9f7d186 --- /dev/null +++ b/flextype/parsers/MarkdownParser.php @@ -0,0 +1,36 @@ +text($input); + } +} diff --git a/flextype/twig/MarkdownTwigExtension.php b/flextype/twig/MarkdownTwigExtension.php index 1958576c..786c6ea7 100644 --- a/flextype/twig/MarkdownTwigExtension.php +++ b/flextype/twig/MarkdownTwigExtension.php @@ -44,10 +44,6 @@ class MarkdownTwigExtension extends Twig_Extension */ public function markdown($value) : string { - if ($value !== null) { - return $this->flextype->markdown->text($value); - } - - return ''; + return MarkdownParser::parse($value); } }