2017 © Pedro Peláez
 

library laravel-markdown-it

A thing for using PHP version markdown-it in Laravel 5.x.

image

kaoken/laravel-markdown-it

A thing for using PHP version markdown-it in Laravel 5.x.

  • Wednesday, September 13, 2017
  • by kaoken
  • Repository
  • 1 Watchers
  • 0 Stars
  • 25 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

laravel-markdown-it

Build Status composer version licence PHP version Laravel version, (*1)

This target Laravel 6.0 and higher, making PHP version markdown-it easy to use with Laravel., (*2)

Table of content, (*3)

Install

composer:, (*4)

Add to composer.json as follows, (*5)

```composer.json "require": { ... "kaoken/laravel-markdown-it":"^2.0" }, (*6)

Then update!
```bash
composer update

Setting

Add to config\app.php as follows:

``` config\app.php 'providers' => [ ... Kaoken\LaravelMarkdownIt\MarkdownItServiceProvider::class, ],, (*7)

'aliases' => [
    ...
    'MarkdownIt' => Kaoken\LaravelMarkdownIt\Facade\MarkdownIt::class,
],
### artisan command

```bash
php artisan vendor:publish

By executing the above command, markdownit.php is created in theconfig directory., (*8)

Options and rules configuration file

All options and rules are enabled by default. This is equivalent to hoge ['options_rules_group'] ['default'] in config \ markdownit.php below.
For a description of the options ("options ") and rules ("enable ", "disable "), see the comments for each parameter of hoge ['options_rules_group'] ['default'] .
If you want to add new options and rules, rewrite the contents of 'example'by removing the comments belowAdd options and rules in the comments below., (*9)

<?php


return [
    'set_options_rules' => 'default',

    'options_rules_group' =>[
        'default' => [
            'options'=> [
                'html'=>         true,        // Enable HTML tags in source
                'xhtmlOut'=>     true,        // Use '/' to close single tags (<br />)
                'breaks'=>       true,        // Convert '\n' in paragraphs into <br>
                'langPrefix'=>   'language-',  // CSS language prefix for fenced blocks
                'linkify'=>      true,        // autoconvert URL-like texts to links

                // Enable some language-neutral replacements + quotes beautification
                'typographer'=>  false,

                // Double + single quotes replacement pairs, when typographer enabled,
                // and smartquotes on. Could be either a String or an Array.
                //
                // For example, you can use '«»„“' for Russian, '„“‚‘' for German,
                // and ['«\xA0', '\xA0»', '‹\xA0', '\xA0›'] for French (including nbsp).
                'quotes'=> '“”‘’', /* “”‘’ */

                // Highlighter function. Should return escaped HTML,
                // or '' if the source string is not changed and should be escaped externaly.
                // If result starts with <pre... internal wrapper is skipped.
                //
                // function (/*str, lang*/) { return ''; }
                //
                'highlight'=> null,

                'maxNesting'=>   100            // Internal protection, recursion limit
            ],
            /**
             * Manage rules!
             * `'enable'` adds the rule you want to enable.
             * `'disable'` adds the rule you want to disable.
             * default all rules are enabled.
             * @see https://github.com/markdown-it/markdown-it/tree/master/benchmark/samples
             */
            'enable' => [
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-autolink.md
                 */
                'autolink',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-backticks.md
                 */
                'backticks',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-bq-flat.md
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-bq-nested.md
                 */
                'blockquote',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-code.md
                 */
                'code',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-em-flat.md
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-em-nested.md
                 */
                'emphasis',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-entity.md
                 */
                'entity',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-escape.md
                 */
                'escape',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-fences.md
                 */
                'fence',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-heading.md
                 */
                'heading',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-hr.md
                 */
                'hr',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-html.md
                 */
                'html_block',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-html.md
                 */
                'html_inline',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-links-flat.md
                 */
                'image',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-lheading.md
                 */
                'lheading',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-links-flat.md
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-links-nested.md
                 */
                'link',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-list-flat.md
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-list-nested.md
                 */
                'list',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/inline-newlines.md
                 */
                'newline',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-ref-flat.md
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-ref-list.md
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-ref-nested.md
                 */
                'reference',
                /**
                 * @see https://github.com/markdown-it/markdown-it/blob/master/benchmark/samples/block-tables.md
                 */
                'table'
            ],
            'disable' => [

            ]
        ],
        /**
         * Add options and rules.
         */
        /*
        'example' => [
            'options'=> [
                'html'=>         false,
                'xhtmlOut'=>     false,
                'breaks'=>       false,
                'langPrefix'=>   'language-',
                'linkify'=>      false,
                'typographer'=>  false
            ],
            'enable' => [
                'backticks',
                'blockquote',
                'emphasis',
                'heading',
                'list',
                'newline',
            ],
            'disable' => [
                'autolink',
                'code',
                'entity',
                'escape',
                'fence',
                'hr',
                'html_block',
                'html_inline',
                'image',
                'lheading',
                'link',
                'reference',
                'table'
            ]
        ]
        */
    ]
];

Simpl

use MarkdownIt;

class hoge{
    public function test(){
        // Already a group of `default` options and rules have been set.
        $result1 = MarkdownIt::render('# markdown-it rulezz!');
        // `example`options and groups of rules are set.
        $result2 = MarkdownIt::setOptionsRules("example")
                             ->render('# markdown-it rulezz!');
    }
}

Single line rendering, without paragraph wrap:, (*10)

use MarkdownIt;

class hoge{
    public function test(){
        // Already a group of `default` options and rules have been set.
        $result1 = MarkdownIt::renderInline('__markdown-it__ rulezz!');
        // `example`options and groups of rules are set.
        $result2 = MarkdownIt::setOptionsRules("example")
                             ->renderInline('__markdown-it__ rulezz!');
    }
}

Linkify

linkify: true Set linkify-it to access the linkify instance., (*11)

use MarkdownIt;

class hoge{
    public function test(){
        // disables .py as top level domain
        MarkdownIt::linkify()->tlds('.py', false);
    }
}

References / Thanks

Thanks to the authors of the original implementation in Javascript, markdown-it:, (*12)

and to John MacFarlane for his work on the CommonMark spec and reference implementations., (*13)

Related Links:, (*14)

  • https://github.com/jgm/CommonMark - reference CommonMark implementations in C & JS, also contains latest spec & online demo.
  • http://talk.commonmark.org - CommonMark forum, good place to collaborate developers' efforts.

License

MIT, (*15)

The Versions

13/09 2017

dev-master

9999999-dev

A thing for using PHP version markdown-it in Laravel 5.x.

  Sources   Download

MIT

The Requires

 

laravel markdown markdown-it

13/09 2017

1.5.2

1.5.2.0

A thing for using PHP version markdown-it in Laravel 5.x.

  Sources   Download

MIT

The Requires

 

laravel markdown markdown-it

30/08 2017

1.5.0

1.5.0.0

A thing for using PHP version markdown-it in Laravel 5.x.

  Sources   Download

MIT

The Requires

 

laravel markdown markdown-it

06/08 2017

1.0.3

1.0.3.0

A thing for using PHP version markdown-it in Laravel 5.x.

  Sources   Download

MIT

The Requires

 

laravel markdown markdown-it

15/07 2017

1.0.0

1.0.0.0

A thing for using PHP version markdown-it in Laravel 5.x.

  Sources   Download

MIT

The Requires

 

laravel markdown markdown-it