PHP code example of zhenhaihou / commonmark-highlighter
1. Go to this page and download the library: Download zhenhaihou/commonmark-highlighter 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/ */
zhenhaihou / commonmark-highlighter example snippets
use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\Block\Element\IndentedCode;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer;
use Spatie\CommonMarkHighlighter\IndentedCodeRenderer;
$environment = Environment::createCommonMarkEnvironment();
$environment->addBlockRenderer(FencedCode::class, new FencedCodeRenderer());
$environment->addBlockRenderer(IndentedCode::class, new IndentedCodeRenderer());
$commonMarkConverter = new CommonMarkConverter([], $environment);
echo $commonMarkConverter->convertToHtml($markdown);
new FencedCodeRenderer(['html', 'php', 'js']);
new IndentedCodeCodeRenderer(['html', 'php', 'js']);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.