1
0
mirror of https://github.com/flextype/flextype.git synced 2025-08-24 21:56:25 +02:00

feat(core): Markdown parsing should be cached in production #287

This commit is contained in:
Awilum
2019-11-11 01:10:18 +03:00
parent fb2e2fac47
commit 23e5d81f35
3 changed files with 37 additions and 12 deletions

View File

@@ -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

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
/**
* @link http://flextype.org
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flextype;
use ParsedownExtra;
class MarkdownParser
{
/**
* Markdown Object
*
* @var object
* @access private
*/
private static $markdown = null;
/**
* parse
*/
public static function parse($input) : string
{
!isset(self::$markdown) and self::$markdown = new ParsedownExtra();
return self::$markdown->text($input);
}
}

View File

@@ -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);
}
}