2015-06-29 16:16:39 +02:00
|
|
|
<?php namespace Todaymade\Daux\Format\Confluence\CommonMark;
|
2015-05-22 14:48:09 +02:00
|
|
|
|
|
|
|
use League\CommonMark\Block\Element\AbstractBlock;
|
|
|
|
use League\CommonMark\Block\Element\IndentedCode;
|
|
|
|
use League\CommonMark\Block\Renderer\BlockRendererInterface;
|
|
|
|
use League\CommonMark\HtmlElement;
|
|
|
|
use League\CommonMark\HtmlRendererInterface;
|
|
|
|
|
|
|
|
class IndentedCodeRenderer implements BlockRendererInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @param AbstractBlock $block
|
|
|
|
* @param HtmlRendererInterface $htmlRenderer
|
|
|
|
* @param bool $inTightList
|
|
|
|
*
|
|
|
|
* @return HtmlElement
|
|
|
|
*/
|
|
|
|
public function render(AbstractBlock $block, HtmlRendererInterface $htmlRenderer, $inTightList = false)
|
|
|
|
{
|
|
|
|
if (!($block instanceof IndentedCode)) {
|
|
|
|
throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
|
|
|
|
}
|
|
|
|
|
|
|
|
return new HtmlElement(
|
|
|
|
'ac:structured-macro',
|
|
|
|
['ac:name' => 'code'],
|
2015-07-17 23:38:06 +02:00
|
|
|
new HtmlElement('ac:plain-text-body', [], '<![CDATA[' . $block->getStringContent() . ']]>')
|
2015-05-22 14:48:09 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|