1<?php 2 3/* 4 * This file is part of the clockoon/dokuwiki-commonmark-plugin package. 5 * 6 * (c) Sungbin Jeon <clockoon@gmail.com> 7 * 8 * Original code based on the followings: 9 * - CommonMark JS reference parser (https://bitly.com/commonmark-js) (c) John MacFarlane 10 * - league/commonmark (https://github.com/thephpleague/commonmark) (c) Colin O'Dell <colinodell@gmail.com> 11 * 12 * For the full copyright and license information, please view the LICENSE 13 * file that was distributed with this source code. 14 */ 15 16namespace DokuWiki\Plugin\Commonmark\Extension\Renderer\Block; 17 18use League\CommonMark\Extension\CommonMark\Node\Block\BlockQuote; 19use League\CommonMark\Node\Node; 20use League\CommonMark\Renderer\ChildNodeRendererInterface; 21use League\CommonMark\Renderer\NodeRendererInterface; 22use League\CommonMark\Util\HtmlElement; 23use League\CommonMark\Xml\XmlNodeRendererInterface; 24 25final class BlockQuoteRenderer implements NodeRendererInterface 26{ 27 /** 28 * @param BlockQuote $block 29 * @param ChildNodeRendererInterface $DWRenderer 30 * @param bool $inTightList 31 * 32 * @return string 33 */ 34 public function render(Node $node, ChildNodeRendererInterface $DWRenderer): string 35 { 36 BlockQuote::assertInstanceOf($node); 37 38 $attrs = $node->data->get('attributes'); 39 40 $filling = $DWRenderer->renderNodes($node->children()); 41 $filling = preg_replace('/\n/', "\n>", $filling); 42 43 if ($filling === '') { 44 return '>' . $DWRenderer->getOption('inner_separator', "\n"); 45 } 46 47 return '>' . $filling . $DWRenderer->getOption('inner_separator', "\n"); 48 } 49} 50