PHP code example of samwilson / commonmark-shortcodes

1. Go to this page and download the library: Download samwilson/commonmark-shortcodes 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/ */

    

samwilson / commonmark-shortcodes example snippets


$environment = new Environment([
    'shortcodes' => [
        'shortcodes' => [
            'myshortcode' => /* callback one */
            'myshortcode2' => /* callback two */
        ],
    ],
]);
$environment->addExtension(new CommonMarkCoreExtension());

$environment->addExtension(new ShortcodeExtension());
$converter = new MarkdownConverter($environment);
echo $converter->convert('Markdown *goes here*.')->getContent();

[
    'smallcaps' => function (Shortcode $shortcode) {
        return '<span style="font-variant:small-caps">'
            . $shortcode->getAttr(1)
            . '</span>';
    },
]