League\CommonMark\HtmlRenderer::renderBlock PHP Method

renderBlock() public method

public renderBlock ( AbstractBlock $block, boolean $inTightList = false ) : string
$block League\CommonMark\Block\Element\AbstractBlock
$inTightList boolean
return string
    public function renderBlock(AbstractBlock $block, $inTightList = false)
    {
        $renderer = $this->environment->getBlockRendererForClass(get_class($block));
        if (!$renderer) {
            throw new \RuntimeException('Unable to find corresponding renderer for block type ' . get_class($block));
        }
        return $renderer->render($block, $this, $inTightList);
    }

Usage Example

Example #1
0
 /**
  * Convert body to html
  */
 public function markdown($description)
 {
     $environment = Environment::createCommonMarkEnvironment();
     $parser = new DocParser($environment);
     $htmlRenderer = new HtmlRenderer($environment);
     $markdown = $this->description;
     $documentAST = $parser->parse($markdown);
     return $htmlRenderer->renderBlock($documentAST);
 }
All Usage Examples Of League\CommonMark\HtmlRenderer::renderBlock