A Bundle that integrates the Sundown parser

Installs: 3 322

Dependents: 2

Suggesters: 0

Security: 0

Stars: 5

Watchers: 2

Forks: 4


dev-master 2014-08-06 10:37 UTC

This package is not auto-updated.

Last update: 2024-07-06 10:46:26 UTC



This bundle lets you easily make use of the markdown parser inside your Symfony applications.

See it in action: Status

This bundle is in development phase. Do not hesitate to contribute.

Build Status


  • Merge the parameters with the DI config
  • Add all possible extensions to DI config
  • Add flags feature
  • Convert config files to .xml
  • Make the Twig extension use of Markdown class
  • Add some tests
  • Structured docs
  • Request feedbacks

Open Source Community

This bundle wraps the work of amazing developers:

Sundown is based on the original Upskirt parser by Natacha Porté, with many additions by Vicent Marti (@tanoku) and contributions from the following authors:

Ben Noordhuis, Bruno Michel, Joseph Koshy, Krzysztof Kowalczyk, Samuel Bronson,
Shuhei Tanuma

php-sundown is a php wrapper of the Sundown project made by [chobie] (


Install sundown and php-sundown on your server

git clone php-sundown -b development
cd php-sundown
# this command will fetch submodule and copy neccesary files to src dir and compile it.
rake submodule compile
sudo rake install

# enable the sundown extension by adding the following line to your php.ini

Download the KwattroMarkdownBundle

Add the following to your deps file:


And run the following command:

php bin/vendors install

Register the bundle

Add the Kwattro namespace to the autoloader:

# /app/autoload.php
'Kwattro' => __DIR__.'/../vendor/bundles',

And finally, register the bundle in your AppKernel

# /app/AppKernel.php
public function registerBundles()
    $bundles = array(
    new Kwattro\MarkdownBundle\KwattroMarkdownBundle(),

How to use it

In your twig templates

You can easily use the markdown parser in your Twig templates:

{{ body | markdown }}

In your controllers by using the kwattro_markdown service name:

$markdown = $this->container->get('kwattro_markdown');
$string = $body; //Some string to transform
$output = $markdown->render($string);

You can custom the extensions and the render to use on the fly. The second array parameter is for the flags.

In your controllers :
$md = $this->container->get('kwattro_markdown');
$string = $body; // some string to transform
$output = $md->render($string, array('autolink' => false), array(), 'xhtml')
In your templates
{{ body | markdown( {'autolink': false}, {}, 'html') }}


For more information about the Markdown syntax, visit the markdown author [website] (

Configuration Reference

You can configure the bundle simply in the config.yml file:

    twig_extension: ~ // default is the twig extension provided by the bundle
    renderer : ~ // default `html` You can choose between html | xhtml | base | custom
    render_class: ~ based off the renderer chosen, you have to specify one if "custom" is chosen
        no_intra_emphasis: false
        tables: true
        fenced_code_blocks: true
        autolink: true
        strikethrough: true
        lax_html_blocks: false
        space_after_headers: true
        superscript: false
        filter_html: false
        no_images: false
        no_links: false
        no_styles: false
        safe_links_only: false
        with_toc_data: false
        hard_wrap: true
        xhtml: true