2010-09-12 12:20:29 +02:00
|
|
|
Provide markdown conversion to your Symfony2 projects.
|
2010-05-05 18:38:36 +02:00
|
|
|
|
|
|
|
## INSTALLATION
|
|
|
|
|
2010-09-12 12:20:29 +02:00
|
|
|
Put MarkdownBundle in your `src/Bundle` dir.
|
2010-05-05 18:38:36 +02:00
|
|
|
|
2010-09-12 12:20:29 +02:00
|
|
|
Then enable it in your `config.yml`:
|
2011-02-25 15:51:43 +01:00
|
|
|
knplabs_markdown:
|
|
|
|
parser: ~ # Enable the parser service
|
|
|
|
helper: ~ # Enable the helper in the templates
|
2010-05-05 18:38:36 +02:00
|
|
|
|
2010-09-19 21:05:36 +02:00
|
|
|
Optionnally enable the twig markdown filter :
|
|
|
|
|
2011-02-25 15:51:43 +01:00
|
|
|
twig: ~ # Enable Twig
|
|
|
|
knplabs_markdown:
|
|
|
|
twig: ~ # Enable the markdown filter
|
2010-09-19 21:05:36 +02:00
|
|
|
|
2010-11-07 14:56:49 +01:00
|
|
|
You can also define your own Parser class :
|
|
|
|
|
2011-02-25 15:51:43 +01:00
|
|
|
knplabs_markdown:
|
|
|
|
parser:
|
2010-11-07 14:56:49 +01:00
|
|
|
class: Bundle\HelloBundle\MarkdownParser
|
|
|
|
|
2010-05-05 18:38:36 +02:00
|
|
|
## USAGE
|
|
|
|
|
2010-05-06 15:20:04 +02:00
|
|
|
// Use the service
|
2010-09-12 12:20:29 +02:00
|
|
|
$html = $this->container['markdownParser']->transform($text);
|
2010-05-06 15:20:04 +02:00
|
|
|
|
|
|
|
// Use the helper
|
2010-09-12 13:25:50 +02:00
|
|
|
echo $view['markdown']->transform($text);
|
2010-07-22 12:06:54 +02:00
|
|
|
|
2010-09-19 21:05:36 +02:00
|
|
|
If you have enabled the twig markdown filter, you can use the following in your twig templates:
|
|
|
|
|
|
|
|
{{ my_data | markdown }}
|
|
|
|
|
2010-07-22 12:06:54 +02:00
|
|
|
## TEST
|
|
|
|
|
|
|
|
phpunit -c myapp src/Bundle/MarkdownBundle
|