misd / twig-markdowner
This package is abandoned and no longer maintained.
No replacement package was suggested.
Twig extension to turn Markdown formatted text into HTML
v1.0.2
2012-10-09 09:30 UTC
Requires
- dflydev/markdown: 1.*
- twig/twig: 1.*
This package is not auto-updated.
Last update: 2020-04-05 18:57:00 UTC
README
Converts text with Markdown syntax into HTML in Twig templates.
Authors
- Stuart Chapman stuart.chapman@admin.cam.ac.uk
Installation
-
Add TwigMarkdowner to your dependencies
// composer.json { // ... "require": { // ... "misd/twig-markdowner": "1.0.*" } }
-
Use Composer to download and install TwigMarkdowner
$ php composer.phar update misd/twig-markdowner
-
Instantiate a
MarkdownParser
and add the extension to the Twig environment$parser = new \dflydev\markdown\MarkdownParser(); /** @var $twig Twig_Environment */ $twig->addExtension(new Misd\TwigMarkdowner\Twig\Extension\MarkdownerExtension($parser));
Usage
In a Twig template:
{{ "My *Markdown* text"|markdown }}
or
{{ object.property|markdown }}
Please note
This filter does not prevent the injection of arbitrary HTML and JavaScript; the output should be filtered (using HTMLPurifier, or equivalent) before being output in a template.