Ejemplo n.º 1
0
 /**
  * @param AbstractBlock $block
  * @param CliRenderer   $renderer
  *
  * @return string
  */
 public function render(AbstractBlock $block, CliRenderer $renderer)
 {
     if (!$block instanceof Heading) {
         throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
     }
     $level = $block->getLevel();
     $text = $renderer->renderInlines($block->children());
     return sprintf("\n%s %s\n", $renderer->style(str_repeat('#', $level), 'dark_gray'), $renderer->style($text, ['bold', 'cyan']));
 }
Ejemplo n.º 2
0
 /**
  * @param AbstractInline $inline
  * @param CliRenderer    $renderer
  *
  * @return string
  */
 public function render(AbstractInline $inline, CliRenderer $renderer)
 {
     if (!$inline instanceof Code) {
         throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
     }
     return $renderer->style($inline->getContent(), 'yellow');
 }
Ejemplo n.º 3
0
 /**
  * @param AbstractInline $inline
  * @param CliRenderer    $renderer
  *
  * @return string
  */
 public function render(AbstractInline $inline, CliRenderer $renderer)
 {
     if (!$inline instanceof Link) {
         throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
     }
     return $renderer->style($renderer->renderInlines($inline->children()), ['underline', 'bold', 'light_blue']);
 }
 /**
  * @param AbstractInline $inline
  * @param CliRenderer    $renderer
  *
  * @return string
  */
 public function render(AbstractInline $inline, CliRenderer $renderer)
 {
     if (!$inline instanceof Emphasis) {
         throw new \InvalidArgumentException(sprintf('Incompatible inline type: "%s"', get_class($inline)));
     }
     return $renderer->style($renderer->renderInlines($inline->children()), 'italic');
 }
 /**
  * @param AbstractBlock $block
  * @param CliRenderer   $renderer
  *
  * @return string
  */
 public function render(AbstractBlock $block, CliRenderer $renderer)
 {
     if (!$block instanceof ThematicBreak) {
         throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
     }
     return $renderer->style(str_repeat('-', $this->width), 'dark_gray');
 }
 /**
  * @param AbstractBlock $block
  * @param CliRenderer   $renderer
  *
  * @return string
  */
 public function render(AbstractBlock $block, CliRenderer $renderer)
 {
     if (!$block instanceof FencedCode) {
         throw new \InvalidArgumentException(sprintf('Incompatible block type: "%s"', get_class($block)));
     }
     $infoWords = $block->getInfoWords();
     $codeType = null;
     if (count($infoWords) !== 0 && strlen($infoWords[0]) !== 0) {
         $codeType = $infoWords[0];
     }
     if (null === $codeType || !isset($this->highlighters[$codeType])) {
         return $this->indent($renderer->style($block->getStringContent(), 'yellow'));
     }
     return $this->indent(sprintf("%s\n", $this->highlighters[$codeType]->highlight($block->getStringContent())));
 }