Go to file
2012-10-04 19:42:02 +03:00
DependencyInjection Fixed phpdoc 2012-05-03 10:49:31 +02:00
Helper Fixed the typehint to use the interface 2012-05-03 10:46:16 +02:00
Parser support Markdown Extra 2012-05-28 04:08:50 +02:00
Resources/config Change Knplabs to Knp. BC break before Symfony2 release. 2011-07-03 11:30:09 +02:00
Tests Fixed tests 2012-02-25 12:10:20 +01:00
Twig/Extension Change Knplabs to Knp. BC break before Symfony2 release. 2011-07-03 11:30:09 +02:00
vendor Fixed tests 2012-02-25 12:10:20 +01:00
.gitignore Added support for Travis 2011-11-19 15:48:33 +01:00
.travis.yml Fixed tests 2012-02-25 12:10:20 +01:00
composer.json Fixed the suggestion key 2012-06-14 15:48:13 +03:00
KnpMarkdownBundle.php Change Knplabs to Knp. BC break before Symfony2 release. 2011-07-03 11:30:09 +02:00
LICENSE Initial commit 2010-05-05 17:11:02 +02:00
MarkdownParserInterface.php Change Knplabs to Knp. BC break before Symfony2 release. 2011-07-03 11:30:09 +02:00
phpunit.xml.dist Added support for Travis 2011-11-19 15:48:33 +01:00
README.markdown fixed typos in README 2012-10-04 19:42:02 +03:00

Provide markdown conversion to your Symfony2 projects.

This implementation is based on Michel Fortin work. We added PHP5 sugar, feature selection, and unit tests.

Build Status

INSTALLATION

Add the following entry to deps the run php bin/vendors install.

[KnpMarkdownBundle]
    git=http://github.com/KnpLabs/KnpMarkdownBundle.git
    target=/bundles/Knp/Bundle/MarkdownBundle

Register the bundle in app/AppKernel.php

$bundles = array(
    // ...
    new Knp\Bundle\MarkdownBundle\KnpMarkdownBundle(),
);

Register namespace in app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'Knp'              => __DIR__.'/../vendor/bundles',
));

USAGE

// Use the service
$html = $this->container->get('markdown.parser')->transform($text);

// Use the helper
echo $view['markdown']->transform($text);

If you have enabled the Twig markdown filter, you can use the following in your Twig templates:

{{ my_data | markdown }}

Change the parser implementation

Create a service implementing Knp\Bundle\MarkdownBundle\MarkdownParserInterface, then configure the bundle to use it:

knp_markdown:
    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.

TEST

phpunit -c myapp vendor/bundles/Knp/Bundle/MarkdownBundle