PHP code example of mpratt / luthor

1. Go to this page and download the library: Download mpratt/luthor library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mpratt / luthor example snippets


     $embera = new \Luthor\Luthor();

    $loader->registerNamespace('Luthor', 'path/to/Luthor');

    $lex = new \Luthor\Luthor();
    echo $lex->parse('**I dont like Superman**');
    // <p><strong>I dont like Superman</strong></p>


    class MyExtension extends \Luthor\Parser\Extensions\Adapters\InlineAdapter
    {
        protected $regex = '~\^([^ ]+)~A';
        public function parse()
        {
            return '<strong>' . $this->matches['1'] . '</strong>';
        }
    }

    $lex = new \Luthor\Luthor();
    $lex->addExtension(new MyExtension());
    echo $lex->parse('I love ^Luthor !');
    // <p>I love <strong>Luthor</strong>!</p>

    $lex = new \Luthor\Luthor();
    $lex->addFilter(function ($text){
        return str_replace('Hello', 'World', $text);
    });

    echo $lex->parse('Hello World!');
    // <p>World World!</p>