PHP code example of wnx / commonmark-markdown-renderer
1. Go to this page and download the library: Download wnx/commonmark-markdown-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/ */
wnx / commonmark-markdown-renderer example snippets
use League\CommonMark\Environment\Environment;
use League\CommonMark\Parser\MarkdownParser;
use Wnx\CommonmarkMarkdownRenderer\MarkdownRendererExtension;
use Wnx\CommonmarkMarkdownRenderer\Renderer\MarkdownRenderer;
$environment = new Environment($config);
$environment->addExtension(new MarkdownRendererExtension());
$markdownParser = new MarkdownParser($environment);
$markdownRenderer = new MarkdownRenderer($environment);
$markdown = "**Hello World!**";
$documentAST = $markdownParser->parse($markdown);
// Manipulate AST in your script (append, prepend or replace nodes)
$markdown = $markdownRenderer->renderDocument($documentAST);