<?php

namespace Knp\Bundle\MarkdownBundle\Twig\Extension;

use Knp\Bundle\MarkdownBundle\Parser\ParserManager;

class MarkdownTwigExtension extends \Twig_Extension
{
    private $parserManager;

    public function __construct(ParserManager $parserManager)
    {
        $this->parserManager = $parserManager;
    }

    public function getFilters()
    {
        return array(
            new \Twig_SimpleFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
        );
    }

    public function markdown($text, $parser = null)
    {
        return $this->parserManager->transform($text, $parser);
    }

    public function getName()
    {
        return 'markdown';
    }
}

<?php

namespace Knp\Bundle\MarkdownBundle\Twig\Extension;

use Knp\Bundle\MarkdownBundle\Parser\ParserManager;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;

class MarkdownTwigExtension extends AbstractExtension
{
    private $parserManager;

    public function __construct(ParserManager $parserManager)
    {
        $this->parserManager = $parserManager;
    }

    public function getFilters()
    {
        return array(
            new TwigFilter('markdown', array($this, 'markdown'), array('is_safe' => array('html'))),
        );
    }

    public function markdown($text, $parser = null)
    {
        return $this->parserManager->transform($text, $parser);
    }

    public function getName()
    {
        return 'markdown';
    }
}

Update Twig filters and extension
Update Twig filters and extension

Hello,

I just updated this file to be compatible with Symfony 5.
The twig filters and extensions were deprecated.

Cheers 😉