/**
  * @param FencedCode $block
  * @param HtmlRendererInterface $htmlRenderer
  * @param bool $inTightList
  *
  * @return HtmlElement
  */
 public function render(AbstractBlock $block, HtmlRendererInterface $htmlRenderer, $inTightList = false)
 {
     if (!$block instanceof FencedCode) {
         throw new \InvalidArgumentException('Incompatible block type: ' . get_class($block));
     }
     $infoWords = $block->getInfoWords();
     $attr = count($infoWords) === 0 || strlen($infoWords[0]) === 0 ? array() : array('class' => 'language-' . $htmlRenderer->escape($infoWords[0], true));
     return new HtmlElement('pre', array(), new HtmlElement('code', $attr, $htmlRenderer->escape($block->getStringContent())));
 }
Example #2
0
 /**
  * @param Link $inline
  * @param HtmlRendererInterface $htmlRenderer
  *
  * @return HtmlElement
  */
 public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Link) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     $attrs = [];
     $attrs['href'] = $htmlRenderer->escape($inline->getUrl(), true);
     if (isset($inline->data['title'])) {
         $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
     }
     return new HtmlElement('a', $attrs, $htmlRenderer->renderInlines($inline->getChildren()));
 }
 /**
  * @param Image $inline
  * @param HtmlRendererInterface $htmlRenderer
  *
  * @return HtmlElement
  */
 public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Image) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     $attrs = array();
     $attrs['src'] = $htmlRenderer->escape($inline->getUrl(), true);
     $alt = $htmlRenderer->renderInlines($inline->getChildren());
     $alt = preg_replace('/\\<[^>]*alt="([^"]*)"[^>]*\\>/', '$1', $alt);
     $attrs['alt'] = preg_replace('/\\<[^>]*\\>/', '', $alt);
     if (isset($inline->data['title'])) {
         $attrs['title'] = $htmlRenderer->escape($inline->data['title'], true);
     }
     return new HtmlElement('img', $attrs, '', true);
 }
 /**
  * @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('pre', array(), new HtmlElement('code', array(), $htmlRenderer->escape($block->getStringContent())));
 }
Example #5
0
 /**
  * @param Code $inline
  * @param HtmlRendererInterface $htmlRenderer
  *
  * @return HtmlElement
  */
 public function render(AbstractInline $inline, HtmlRendererInterface $htmlRenderer)
 {
     if (!$inline instanceof Code) {
         throw new \InvalidArgumentException('Incompatible inline type: ' . get_class($inline));
     }
     return new HtmlElement('code', array(), $htmlRenderer->escape($inline->getContent()));
 }