2017 © Pedro Pelรกez
 

library bono-markdown

Markdown Support for Bono Based Project

image

krisanalfa/bono-markdown

Markdown Support for Bono Based Project

  • Tuesday, August 12, 2014
  • by krisanalfa
  • Repository
  • 1 Watchers
  • 0 Stars
  • 13 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Markdown Support for Bono Based Project

This package will make you able to use markdown as Norm schema or input type markdown in your Bono Based Project., (*1)

Note: This package required PHP >5.4, (*2)

Installation

Add this package to your composer.json file, (*3)

"require": {
    "krisanalfa/bono-markdown": "~0.0.1",
}

Register Bono Markdown provider to your Bono provider configuration:, (*4)

'bono.providers' => [
    'Bono\\Markdown\\Provider\\MarkdownProvider' => [
        'gfm' => true, // activate Github Flavored Markdown
    ],
],

Note: For another config options, see the Config section below., (*5)

Example Usage

$app = App::getInstance();
$markdown = '**Markdown is awesome**';

// render markdown syntax
echo $app->container['markdown']->render($markdown);

// render markdown form input
echo $app->container['markdown.form']->renderInput($markdown);

Input form use Bootstrap 3 as it's theme, if you want to override this one, you should use custom view, and render your own partial template there., (*6)

Options

Below is complete example of available option for your Markdown configuration:, (*7)

use App\MyCustomViewEngine;

'bono.providers' => [
    'Bono\\Markdown\\Provider\\MarkdownProvider' => [
        'gfm' => true, // default false
        'service' => true, // default false
        'endpoint' => '/md-parser', // default '/md'
        'requestKeyName' => 'entry', // default 'markdown',
        'view' => function () { // default is not set, fallback to Slim\View
            return new MyCustomViewEngine;
        },
        'partialTemplatePath' => 'templates/partials', // default is not set, using our own partials
    ],
],

Options โ€“โ€“ gfm

Enable Github Flavored Markdown, default is false, (*8)

Options โ€“โ€“ service

If you want to enable web service that able to parse markdown set this to true, default is false, (*9)

Options โ€“โ€“ endpoint

The endpoint URL of your web service, require service to true, default is md, (*10)

Options โ€“โ€“ requestKeyName

The request key name for your web service, default is markdown, (*11)

Options โ€“โ€“ view

Your custom view engine, default is Slim\View, (*12)

Options โ€“โ€“ partialTemplatePath

Your custom partial template, default is not set (using our own partials), (*13)

Norm Schema

You can also use this package as Norm schema. Be caution, when you call formatInput() method, the method calls $app->container['markdown.form']->renderInput($markdown) method; the default partial still use _markdown/form and Slim\View view engine. So, if you want to override this behavior, you must set your own view in config file:, (*14)

'bono.providers' => [
    'Bono\\Markdown\\Provider\\MarkdownProvider' => [
        'view' => function() {
            return new MyCustomViewEngine();
        }
    ],
],

Note: Make sure your custom view is an extends from Slim\View, (*15)

Web Service

To enable this feature, you have to change your config, and set service to true. Access them via POST request. This is a simple javascript example to access your webservice:, (*16)

$.ajax({
    url: 'http://yourdomain.com/md',
    data: {
        'markdown': '**Markdown is awesome**'
    },
    type: 'POST'
}).done(function(html) {
    $('div').html(html);
});

Note: As you see, the given URL, /md is based on your endpoint configuration., (*17)

Another Hack

Form input use Slim\View to fetch and load the view. If you want to change this default, you can use $app->container['markdown.form']->setView($view)., (*18)

$view = new MyCustomViewEngine();

$app->container['markdown.form']->setView($view); // after this, form should use your custom view engine

One more. The default partials to render is _markdown/form, if you want to render another partials, just pass a second argument in Form::renderInput() method. Example:, (*19)

$app->container['markdown.form']->renderInput($markdown, '_partials/markdown');

For more information, see Bono\Markdown\Helper\Form.php file., (*20)

Note: Your custom view should an extends from Slim\View, (*21)

The Versions

12/08 2014

dev-master

9999999-dev

Markdown Support for Bono Based Project

  Sources   Download

MIT

The Requires

 

12/08 2014

0.0.2

0.0.2.0

Markdown Support for Bono Based Project

  Sources   Download

MIT

The Requires