PHP code example of jsw / commonmark-figure-extension

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

    

jsw / commonmark-figure-extension example snippets


$environment = new Environment();
$environment->addExtension(new CommonMarkCoreExtension());
            ->addExtension(new FigureExtension());

$converter = new MarkdownConverter($environment);

$markdown =<<<EOL
^^^
![example-image](https://example.com/image.jpg)
^^^ This is caption for image
EOL;

// <figure><p><img src="https://example.com/image.jpg" alt="example-image" /></p>
// <figcaption>This is caption for image</figcaption></figure>
echo $converter->convert($markdown);