2017 © Pedro Peláez
 

library parsedown-provider

Pimple service provider for Parsedown.

image

clippings/parsedown-provider

Pimple service provider for Parsedown.

  • Saturday, September 10, 2016
  • by hkdobrev
  • Repository
  • 10 Watchers
  • 2 Stars
  • 27,085 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 20 % Grown

The README.md

Parsedown Service Provider

This is a service provider for the Markdown parser Parsedown. It could be used to easily use and configure Parsedown with Pimple or Silex., (*1)

Build Status, (*2)

Installation

Install the latest version with Composer:, (*3)

composer require clippings/parsedown-provider

Usage

Register the service provider in the Pimple container and enjoy!, (*4)

``` php $app->register(new Clippings\ParsedownProvider\ParsedownServiceProvider());, (*5)

$html = $app['parsedown']->text($markdown);, (*6)


It registers one service - `parsedown` which returns the same instance of `Parsedown`. Configuration ------------- You can configure it like that: ``` php $app->register(new Clippings\ParsedownProvider\ParsedownServiceProvider(), [ 'parsedown.markup_escaped' => true, ]);

It accepts the following configuration parameters:, (*7)

  • parsedown.class - The class to use to instantiate Parsedown. Default: Parsedown. You can use that to load an an extension of Parsedown like ParsedownExtra., (*8)

    Don't forget to composer require erusev/parsedown-extra and then you can do:, (*9)

    php $app->register(new Clippings\ParsedownProvider\ParsedownServiceProvider(), [ 'parsedown.class' => 'ParsedownExtra', ]);, (*10)

  • 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., (*11)

  • parsedown.markup_escaped - Whether to escape HTML. Default: false., (*12)

  • 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., (*13)

Twig

If you have already registered Twig, probably with the TwigServiceProvider, the Parsedown service provider would also register a parsedown Twig filter for you to use in your templates., (*14)

You can use it like that:, (*15)

{{ 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., (*16)

Silex Application Trait

If you use it with Silex you can add the ParsedownTrait in your application:, (*17)

``` php <?php, (*18)

class Application extends Silex\Application { use Clippings\ParsedownProvider\ParsedownTrait; }, (*19)


Then you could use it like that: ``` php $html = $app->parsedown($markdown);

Authors and License

The Parsedown provider was developed by the Clippings.com team and is distributed under the MIT license., (*20)

Read more about our projects at the Clippings Geeks blog., (*21)

The Versions

10/09 2016
10/09 2016