public function shortCode($text)
    {
        /* Needs PHP 7
        $patternsAndCallbacks = [
            "/\[(FIGURE)[\s+](.+)\]/" => function ($match) {
                return self::ShortCodeFigure($matches[2]);
            },
            "/(```([\w]*))\n([^`]*)```[\n]{1}/s" => function ($match) {
                return $this->syntaxHighlightGeSHi($matches[3], $matches[2]);
            },
        ];

        return preg_replace_callback_array($patternsAndCallbacks, $text);
        */

        $patterns = [
            "/\[(FIGURE)[\s+](.+)\]/",
            //'/\[(YOUTUBE) src=(.+) width=(.+) caption=(.+)\]/',
            "/\[(YOUTUBE)[\s+](.+)\]/",
            "/\[(CODEPEN)[\s+](.+)\]/",
            "/\[(ASCIINEMA)[\s+](.+)\]/",
            "/\[(BOOK)[\s+](.+)\]/",
            //"/(```)([\w]*)\n([.]*)```[\n]{1}/s",
            "/(```)([\w]*)\n(.*?)```\n/s",
            '/\[(INFO)\]/',
            '/\[(\/INFO)\]/',
            '/\[(WARNING)\]/',
            '/\[(\/WARNING)\]/',
        ];

        return preg_replace_callback(
            $patterns,
            function ($matches) {
                switch ($matches[1]) {
                    case "FIGURE":
                        return self::shortCodeFigure($matches[2]);
                    break;

                    case "YOUTUBE":
                        return self::shortCodeYoutube($matches[2]);
                    break;

                    case "CODEPEN":
                        return self::shortCodeCodepen($matches[2]);
                    break;

                    case "ASCIINEMA":
                        return self::shortCodeAsciinema($matches[2]);
                    break;

                    case "BOOK":
                        return self::shortCodeBook($matches[2]);
                    break;

                    case "```":
                        //return $this->syntaxHighlightGeSHi($matches[3], $matches[2]);
                        return $this->syntaxHighlightJs($matches[3], $matches[2]);
                    break;

                    case 'INFO':
                        return <<<EOD
<div class="info">
    <span class="icon fa-stack fa-lg">
        <i class="fa fa-circle fa-stack-2x"></i>
        <i class="fa fa-info fa-stack-1x fa-inverse" aria-hidden="true"></i>
    </span>
    <div markdown=1>
EOD;
                        break;

                    case 'WARNING':
                        return <<<EOD
<div class="warning">
    <span class="icon fa-stack fa-lg">
        <i class="fa fa-circle fa-stack-2x"></i>
        <i class="fa fa-exclamation-triangle fa-stack-1x fa-inverse" aria-hidden="true"></i>
    </span>
    <div markdown=1>
EOD;
                        break;

                    case '/INFO':
                    case '/WARNING':
                        return "</div></div>";
                        break;

                    default:
                        return "{$matches[1]} is unknown shortcode.";
                }
            },
            $text
        );
    }
public function shortCode($text)
    {
        /* Needs PHP 7
        $patternsAndCallbacks = [
            "/\[(FIGURE)[\s+](.+)\]/" => function ($match) {
                return self::ShortCodeFigure($matches[2]);
            },
            "/(```([\w]*))\n([^`]*)```[\n]{1}/s" => function ($match) {
                return $this->syntaxHighlightGeSHi($matches[3], $matches[2]);
            },
        ];

        return preg_replace_callback_array($patternsAndCallbacks, $text);
        */

        $patterns = [
            "/\[(FIGURE)[\s+](.+)\]/",
            //'/\[(YOUTUBE) src=(.+) width=(.+) caption=(.+)\]/',
            "/\[(YOUTUBE)[\s+](.+)\]/",
            "/\[(CODEPEN)[\s+](.+)\]/",
            "/\[(ASCIINEMA)[\s+](.+)\]/",
            "/\[(BOOK)[\s+](.+)\]/",
            //"/(```)([\w]*)\n([.]*)```[\n]{1}/s",
            "/(```)([\w]*)\n(.*?)```\n/s",
            '/\[(INFO)\]/',
            '/\[(\/INFO)\]/',
            '/\[(WARNING)\]/',
            '/\[(\/WARNING)\]/',
        ];

        return preg_replace_callback(
            $patterns,
            function ($matches) {
                switch ($matches[1]) {
                    case "FIGURE":
                        return self::shortCodeFigure($matches[2]);
                    break;

                    case "YOUTUBE":
                        return self::shortCodeYoutube($matches[2]);
                    break;

                    case "CODEPEN":
                        return self::shortCodeCodepen($matches[2]);
                    break;

                    case "ASCIINEMA":
                        return self::shortCodeAsciinema($matches[2]);
                    break;

                    case "BOOK":
                        return self::shortCodeBook($matches[2]);
                    break;

                    case "```":
                        //return $this->syntaxHighlightGeSHi($matches[3], $matches[2]);
                        return $this->syntaxHighlightJs($matches[3], $matches[2]);
                    break;

                    case 'INFO':
                        return <<<EOD
<div class="info">
    <span class="icon fa-stack fa-lg">
        <i class="fa fa-circle fa-stack-2x"></i>
        <i class="fa fa-info fa-stack-1x fa-inverse" aria-hidden="true"></i>
    </span>
    <div markdown=1>
EOD;
                        break;

                    case 'WARNING':
                        return <<<EOD
<div class="warning">
    <span class="icon fa-stack fa-lg">
        <i class="fa fa-circle fa-stack-2x"></i>
        <i class="fa fa-exclamation-triangle fa-stack-1x fa-inverse" aria-hidden="true"></i>
    </span>
    <div markdown=1>
EOD;
                        break;

                    case '/INFO':
                    case '/WARNING':
                        return "</div></div>";
                        break;

                    default:
                        return "{$matches[1]} is unknown shortcode.";
                }
            },
            $text
        );
    }
public function shortCode ( $ text ) { /* Needs PHP 7
        $patternsAndCallbacks = [
            "/\[(FIGURE)[\s+](.+)\]/" => function ($match) {
                return self::ShortCodeFigure($matches[2]);
            },
            "/(```([\w]*))\n([^`]*)```[\n]{1}/s" => function ($match) {
                return $this->syntaxHighlightGeSHi($matches[3], $matches[2]);
            },
        ];

        return preg_replace_callback_array($patternsAndCallbacks, $text);
        */ $ patterns = [ "/\[(FIGURE)[\s+](.+)\]/" , //'/\[(YOUTUBE) src=(.+) width=(.+) caption=(.+)\]/', "/\[(YOUTUBE)[\s+](.+)\]/" , "/\[(CODEPEN)[\s+](.+)\]/" , "/\[(ASCIINEMA)[\s+](.+)\]/" , "/\[(BOOK)[\s+](.+)\]/" , //"/(```)([\w]*)\n([.]*)```[\n]{1}/s", "/(```)([\w]*)\n(.*?)```\n/s" , '/\[(INFO)\]/' , '/\[(\/INFO)\]/' , '/\[(WARNING)\]/' , '/\[(\/WARNING)\]/' , ] ; return preg_replace_callback ( $ patterns , function ( $ matches ) { switch ( $ matches [ 1 ] ) { case "FIGURE" : return self :: shortCodeFigure ( $ matches [ 2 ] ) ; break ; case "YOUTUBE" : return self :: shortCodeYoutube ( $ matches [ 2 ] ) ; break ; case "CODEPEN" : return self :: shortCodeCodepen ( $ matches [ 2 ] ) ; break ; case "ASCIINEMA" : return self :: shortCodeAsciinema ( $ matches [ 2 ] ) ; break ; case "BOOK" : return self :: shortCodeBook ( $ matches [ 2 ] ) ; break ; case "```" : //return $this->syntaxHighlightGeSHi($matches[3], $matches[2]); return $ this -> syntaxHighlightJs ( $ matches [ 3 ] , $ matches [ 2 ] ) ; break ; case 'INFO' : return  <<<EOD
<div class="info">
    <span class="icon fa-stack fa-lg">
        <i class="fa fa-circle fa-stack-2x"></i>
        <i class="fa fa-info fa-stack-1x fa-inverse" aria-hidden="true"></i>
    </span>
    <div markdown=1>
EOD ; break ; case 'WARNING' : return  <<<EOD
<div class="warning">
    <span class="icon fa-stack fa-lg">
        <i class="fa fa-circle fa-stack-2x"></i>
        <i class="fa fa-exclamation-triangle fa-stack-1x fa-inverse" aria-hidden="true"></i>
    </span>
    <div markdown=1>
EOD ; break ; case '/INFO' : case '/WARNING' : return "</div></div>" ; break ; default : return "{$matches[1]} is unknown shortcode." ; } } , $ text ) ; }
Shortcode to quicker format text as HTML.

@param string $text text to be converted.

@return string the formatted text.
Shortcode to quicker format text as HTML .