demontpx/parsedown-bundle

Parsedown (markdown) bundle for Symfony

Installs: 24 988

Dependents: 0

Suggesters: 0

Security: 0

Stars: 6

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

3.0.2 2021-01-06 15:55 UTC

This package is auto-updated.

Last update: 2024-10-30 01:46:30 UTC


README

Provides the parsedown service and twig filter for Symfony

Installation

Require the bundle using composer:

composer require demontpx/parsedown-bundle ^1.3

Then add it to your bundles section in AppKernel.php:

new Demontpx\ParsedownBundle\DemontpxParsedownBundle()

Usage

Then you can use it in your twig templates:

{{ text|markdown }}
{{ '# This is a header!'|markdown }}

or directly from PHP:

$parsedown = $container->get('demontpx_parsedown.parsedown');
$parsedText = $parsedown->text($text);

You can also use the controller to parse markdown using an REST call. Add this to your routing.yml:

demontpx_parsedown:
    resource: "@DemontpxParsedownBundle/Resources/config/routing.yml"
    prefix:   /parsedown/

After that you'll be able to send a POST request with markdown to http://your-apps-url/parsedown/ and it will return the parsed HTML. You might want to use this to render previews using javascript or something!