2010-09-12 12:20:29 +02:00
|
|
|
Provide markdown conversion to your Symfony2 projects.
|
2010-05-05 18:38:36 +02:00
|
|
|
|
2011-04-07 08:35:00 +02:00
|
|
|
This implementation is based on Michel Fortin work.
|
|
|
|
We added PHP5 sugar, feature selection, and unit tests.
|
|
|
|
|
2010-05-05 18:38:36 +02:00
|
|
|
## INSTALLATION
|
|
|
|
|
2011-07-03 11:28:55 +02:00
|
|
|
Put MarkdownBundle in a `vendor/bundles/Knp/Bundle/MarkdownBundle` dir.
|
2010-05-05 18:38:36 +02:00
|
|
|
|
|
|
|
## USAGE
|
|
|
|
|
2010-05-06 15:20:04 +02:00
|
|
|
// Use the service
|
2011-06-11 06:35:41 +02:00
|
|
|
$html = $this->container->get('markdown.parser')->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 }}
|
|
|
|
|
2011-04-07 08:35:00 +02:00
|
|
|
## Change the parser implementation
|
|
|
|
|
2011-07-03 11:28:55 +02:00
|
|
|
Create a service implementing Knp\Bundle\MarkdownBundle\ParserInterface,
|
2011-04-07 08:35:00 +02:00
|
|
|
then configure the bundle to use it:
|
|
|
|
|
2011-07-03 11:28:55 +02:00
|
|
|
knp_markdown:
|
2011-04-07 08:35:00 +02:00
|
|
|
parser:
|
|
|
|
service: my.markdown.parser
|
|
|
|
|
|
|
|
This bundle comes with 4 parser services, all based on the same algorithm
|
|
|
|
but providing different levels of compliance to the markdown specification:
|
|
|
|
|
|
|
|
- markdown.parser.max // fully compliant = slower (default implementation)
|
|
|
|
- markdown.parser.medium // expensive and uncommon features dropped
|
|
|
|
- markdown.parser.light // expensive features dropped
|
|
|
|
- markdown.parser.min // most features dropped = faster
|
|
|
|
|
|
|
|
For more details, see the implementations in Parser/Preset.
|
|
|
|
|
2010-07-22 12:06:54 +02:00
|
|
|
## TEST
|
|
|
|
|
2011-07-03 11:28:55 +02:00
|
|
|
phpunit -c myapp vendor/bundles/Knp/Bundle/MarkdownBundle
|