PHPackages                             clippings/parsedown-provider - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. clippings/parsedown-provider

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

clippings/parsedown-provider
============================

Pimple service provider for Parsedown.

1.1.0(6y ago)287.8kMITPHPPHP ^7.1CI failing

Since Sep 10Pushed 6y ago24 watchersCompare

[ Source](https://github.com/clippings/parsedown-provider)[ Packagist](https://packagist.org/packages/clippings/parsedown-provider)[ RSS](/packages/clippings-parsedown-provider/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (6)Versions (5)Used By (0)

Parsedown Service Provider
==========================

[](#parsedown-service-provider)

This is a service provider for the [Markdown parser Parsedown](https://github.com/erusev/parsedown). It could be used to easily use and configure Parsedown with [Pimple](http://pimple.sensiolabs.org) or [Silex](http://silex.sensiolabs.org).

[![Build Status](https://camo.githubusercontent.com/1abbd0b9c407c38e0c43136a0dad605d9a374b9c91f31d02eaddaa07e883226b/68747470733a2f2f7472617669732d63692e6f72672f636c697070696e67732f7061727365646f776e2d70726f76696465722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/clippings/parsedown-provider)

Installation
------------

[](#installation)

Install the latest version with Composer:

```
composer require clippings/parsedown-provider

```

Usage
-----

[](#usage)

Register the service provider in the Pimple container and enjoy!

```
$app->register(new Clippings\ParsedownProvider\ParsedownServiceProvider());

$html = $app['parsedown']->text($markdown);
```

It registers one service - `parsedown` which returns the same instance of `Parsedown`.

Configuration
-------------

[](#configuration)

You can configure it like that:

```
$app->register(new Clippings\ParsedownProvider\ParsedownServiceProvider(), [
    'parsedown.markup_escaped' => true,
]);
```

It accepts the following configuration parameters:

- `parsedown.class` - The class to use to instantiate Parsedown. Default: `Parsedown`. You can use that to load an an extension of Parsedown like [`ParsedownExtra`](https://github.com/erusev/parsedown-extra).

    Don't forget to `composer require erusev/parsedown-extra` and then you can do:

    ```
    $app->register(new Clippings\ParsedownProvider\ParsedownServiceProvider(), [
        'parsedown.class' => 'ParsedownExtra',
    ]);
    ```
- `parsedown.breaks_enabled` - Whether to treat line breaks as new lines or not. Default: `true`. This is not the default for Markdown and Parsedown, but it is very common configuration - e.g. GitHub treats line breaks like that.
- `parsedown.markup_escaped` - Whether to escape HTML. Default: `false`.
- `parsedown.urls_linked` - Whether URLs are linked by default. Default: `true`. This is the Parsedown default. URLs would be auto-linked. It is similar to [GFM](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown).

Twig
----

[](#twig)

If you have already registered [Twig](http://twig.sensiolabs.org), probably with the `TwigServiceProvider`, the Parsedown service provider would also register a `parsedown` Twig filter for you to use in your templates.

You can use it like that:

```
{{ foo.markdown|parsedown }}

```

This will convert the Markdown you have directly in your template and output HTML using the same Parsedown instance you have configured.

Silex Application Trait
-----------------------

[](#silex-application-trait)

If you use it with Silex you can add the `ParsedownTrait` in your application:

```
