/** * @param BlockQuote $block * @param HtmlRenderer $htmlRenderer * @param bool $inTightList * * @return HtmlElement */ public function render(AbstractBlock $block, HtmlRenderer $htmlRenderer, $inTightList = false) { if (!$block instanceof BlockQuote) { throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block)); } $filling = $htmlRenderer->renderBlocks($block->getChildren()); if ($filling === '') { return new HtmlElement('blockquote', array(), $htmlRenderer->getOption('inner_separator', "\n")); } return new HtmlElement('blockquote', array(), $htmlRenderer->getOption('inner_separator', "\n") . $filling . $htmlRenderer->getOption('inner_separator', "\n")); }
/** * @param ListBlock $block * @param HtmlRenderer $htmlRenderer * @param bool $inTightList * * @return HtmlElement */ public function render(AbstractBlock $block, HtmlRenderer $htmlRenderer, $inTightList = false) { if (!$block instanceof ListBlock) { throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block)); } $listData = $block->getListData(); $start = $listData->start ?: null; $tag = $listData->type == ListBlock::TYPE_UNORDERED ? 'ul' : 'ol'; $attr = !$start || $start == 1 ? array() : array('start' => (string) $start); return new HtmlElement($tag, $attr, $htmlRenderer->getOption('inner_separator', "\n") . $htmlRenderer->renderBlocks($block->getChildren(), $block->isTight()) . $htmlRenderer->getOption('inner_separator', "\n")); }
/** * @param Newline $inline * @param HtmlRenderer $htmlRenderer * * @return HtmlElement|string */ public function render(AbstractInline $inline, HtmlRenderer $htmlRenderer) { if (!$inline instanceof Newline) { throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline)); } if ($inline->getType() === Newline::HARDBREAK) { return new HtmlElement('br', array(), '', true) . "\n"; } else { return $htmlRenderer->getOption('soft_break', "\n"); } }