/** * @param ContainerInterface $c * @return CliRenderer */ public function __invoke(ContainerInterface $c) { $terminal = $c->get(TerminalInterface::class); $highlighterFactory = new PSXFactory(); $codeRender = new FencedCodeRenderer(); $codeRender->addSyntaxHighlighter('php', new PhpHighlighter($highlighterFactory->__invoke())); $blockRenderers = [Document::class => new DocumentRenderer(), Header::class => new HeaderRenderer(), HorizontalRule::class => new HorizontalRuleRenderer($terminal->getWidth()), Paragraph::class => new ParagraphRenderer(), FencedCode::class => $codeRender]; $inlineBlockRenderers = [Text::class => new TextRenderer(), Code::class => new CodeRenderer(), Emphasis::class => new EmphasisRenderer(), Strong::class => new StrongRenderer(), Newline::class => new NewlineRenderer(), Link::class => new LinkRenderer()]; return new CliRenderer($blockRenderers, $inlineBlockRenderers, $c->get(Color::class)); }
/** * @return CliRenderer */ public function __invoke() { $highlighterFactory = new Factory(); $codeRender = new FencedCodeRenderer(); $codeRender->addSyntaxHighlighter('php', new PhpHighlighter($highlighterFactory->__invoke())); $blockRenderers = [Document::class => new DocumentRenderer(), Header::class => new HeaderRenderer(), HorizontalRule::class => new HorizontalRuleRenderer(), Paragraph::class => new ParagraphRenderer(), FencedCode::class => $codeRender]; $inlineBlockRenderers = [Text::class => new TextRenderer(), Code::class => new CodeRenderer(), Emphasis::class => new EmphasisRenderer(), Strong::class => new StrongRenderer(), Newline::class => new NewlineRenderer(), Link::class => new LinkRenderer()]; $colors = new Color(); $colors->setForceStyle(true); return new CliRenderer($blockRenderers, $inlineBlockRenderers, $colors); }
/** * @return FencedCodeRenderer */ private function getRenderer() { $highlighterFactory = new Factory(); $class = $this->getRendererClass(); $renderer = new $class(); $renderer->addSyntaxHighlighter('php', new PhpHighlighter($highlighterFactory->__invoke())); return $renderer; }