convert markdowned text to html for Twig.
markdown converter is php-markdown-extra.
Install via PEAR installer locally:
$ pear install -f package.xml
Install via PEAR installer from Corneltek PEAR channel:
$ pear install -a corneltek/Twig_Extensions_Markdown
Install composer in your project:
curl -s http://getcomposer.org/installer | php
Create a composer.json file in your project root:
{
"repositories": [
{
"type": "package",
"package": {
"name": "michelf/php-markdown",
"version": "1.0",
"dist": {
"url": "https://github.com/michelf/php-markdown/zipball/extra",
"type": "zip"
},
"autoload": {
"files": [
"markdown.php"
]
}
}
},
{
"type": "vcs",
"url": "http://github.com/geta6/Twig-Markdown"
}
],
"require": {
"michelf/php-markdown": "1.*",
"geta6/twig-markdown": "@dev"
}
}
Run install command:
php composer.phar install
{% markdown %}markdownedtext{% endmarkdown %}
or
{{ markdowned|markdown|raw }}
# use built-in twig autoloader
require_once 'Twig/Autoloader.php';
Twig_Autoloader::register();
$debug = new \Twig_Extensions_Extension_Debug;
$twig->addExtension( $debug );
$markdown = new \Twig_Extension_Markdown;
$twig->addExtension( $markdown );
To update the package.xml
file, you need to install onion
:
むりやりincludeしてるのでもっとスマートな方法おしえてください