PHP code example of ramnzys / commonmark-kroki

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

    

ramnzys / commonmark-kroki example snippets


use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use Ramnzys\CommonmarkKrokiExtension\KrokiExtension;

$environment = Environment::createCommonMarkEnvironment();
$environment->addExtension(new KrokiExtension());

$config = [];

$commonMarkConverter = new CommonMarkConverter($config, $environment);

$markdownContent = <<<EOT

    $config = [
        'kroki' => [
            'server'    => 'https://kroki.io',
            'format'    => 'svg',
            'auto'      => ['plantuml']
        ]
    ];

EOT;

$htmlContent= $commonMarkConverter->convertToHtml($markdownContent);

echo $htmlContent;