Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CommonMark - Overriding default renderers
use League\CommonMark\Block\Element\AbstractBlock;
use League\CommonMark\ElementRendererInterface;
class CustomParagraphRenderer implements BlockRendererInterface
public function render(AbstractBlock $block, ElementRendererInterface $htmlRenderer, $inTightList = false)
return $htmlRenderer->renderInlines($block->children());
$environment = Environment::createCommonMarkEnvironment();
$environment->addBlockRenderer('League\CommonMark\Block\Element\Paragraph', new CustomParagraphRenderer());
$converter = new CommonMarkConverter([], $environment);
echo $converter->convertToHtml('**Hello World!**');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.