Go to file
Ryan Weaver 4e890d540a Adding symfony/dependency-injection specifically to avoid 2.2 bug with framework
Before framework-bundle 2.3.24, framework-bundle allowed for the 2.2 of the dependency-injection
component. However, 2.3 of DI added synchronized services, which framework-bundle uses. So,
framework-bundle 2.3 *really* needs di 2.2. This caused our integration tests to fail, because
the "lowest" deps included 2.3.0 of both components (which are not compatible).
2015-12-15 16:53:49 -05:00
DependencyInjection Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
Helper Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
Parser Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
Resources/config Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
Tests Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
Twig/Extension Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
.gitignore Removing MarkdownTwigExtension dependency to MarkdownHelper 2015-12-15 16:08:41 -05:00
.travis.yml Improve the Travis setup 2015-09-29 16:52:27 +02:00
composer.json Adding symfony/dependency-injection specifically to avoid 2.2 bug with framework 2015-12-15 16:53:49 -05:00
KnpMarkdownBundle.php Removed hard dependency on MarkdownParser code, now uses dflydev/markdown library 2012-10-15 17:28:35 +02:00
LICENSE Initial commit 2010-05-05 17:11:02 +02:00
MarkdownParserInterface.php Reverted the interface renaming done in #50 2014-02-20 11:34:05 +01:00
phpunit.xml.dist Exclude vendors from the code coverage 2015-09-29 16:47:42 +02:00
README.markdown Add link to php-markdown lib. 2015-05-05 11:36:51 +02:00

Provide markdown conversion (based on Michel Fortin work) to your Symfony2 projects.

Build Status

INSTALLATION

Add KnpMarkdownBundle to your composer.json

{
    "require": {
        "knplabs/knp-markdown-bundle": "~1.3"
    }
}

or simply run composer require knplabs/knp-markdown-bundle:~1.3

Register the bundle in app/AppKernel.php

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

USAGE

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

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

// Use the helper and a select specific parser
echo $view['markdown']->transform($text, $parserName);

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

{# Use default parser #}
{{ my_data|markdown }}

{# Or select specific parser #}
{{ my_data|markdown('parserName') }}

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

Alternatively if you are using the markdown.parser.sundown there are options for enabling sundown extensions and render flags, see the default Configuration with:

php app/console config:dump-reference knp_markdown

This bundle comes with 5 parser services, 4 based on the same algorithm but providing different levels of compliance to the markdown specification, and one which is uses the php sundown extension:

- 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
- markdown.parser.sundown   // faster and fully compliant (recommended)

markdown.parser.sundown requires the php sundown extension.

For more details, see the implementations in Parser/Preset.

TEST

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