PHP code example of php-school / cli-md-renderer

1. Go to this page and download the library: Download php-school/cli-md-renderer 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/ */

    

php-school / cli-md-renderer example snippets



League\CommonMark\DocParser;
use League\CommonMark\Environment;
use PhpSchool\CliMdRenderer\CliRendererFactory;

$parser = new DocParser(Environment::createCommonMarkEnvironment());
$cliRenderer = (new CliRendererFactory)->__invoke();
$ast = $parser->parse(file_get_contents('path/to/file.md'));

echo $cliRenderer->renderBlock($ast);



use PhpSchool\CliMdRenderer\Renderer\FencedCodeRenderer;

$codeRenderer = new FencedCodeRenderer;
$codeRenderer->addSyntaxHighlighter('js', new JsSyntaxHighlighter);

 
olors\Color;
use League\CommonMark\Environment;

$environment = new Environment();
$environment->addExtension(new CliExtension());

$colors = new Color();
$colors->setForceStyle(true);

return new CliRenderer($environment, $colors);