public renderBlock ( |
||
$block | ||
$inTightList | boolean | |
리턴 | string |
/** * Convert body to html */ public function markdown($description) { $environment = Environment::createCommonMarkEnvironment(); $parser = new DocParser($environment); $htmlRenderer = new HtmlRenderer($environment); $markdown = $this->description; $documentAST = $parser->parse($markdown); return $htmlRenderer->renderBlock($documentAST); }
public function htmlIntroduction($before = '', $after = '') { $introduction = trim($this->introduction); if (empty($introduction)) { return; } $environment = Environment::createCommonMarkEnvironment(); $parser = new DocParser($environment); $htmlRenderer = new HtmlRenderer($environment); $text = $parser->parse($introduction); return $before . $htmlRenderer->renderBlock($text) . $after; }
/** * @param string $string * @param string $expected * @return void * * @dataProvider dataForIntegrationTest */ public function testStrikethrough($string, $expected) { $environment = Environment::createCommonMarkEnvironment(); $environment->addInlineParser(new StrikethroughParser()); $environment->addInlineRenderer('CommonMarkExt\\Strikethrough\\Strikethrough', new StrikethroughRenderer()); $parser = new DocParser($environment); $renderer = new HtmlRenderer($environment); $document = $parser->parse($string); $html = $renderer->renderBlock($document); // // $converter = new CommonMarkConverter($environment->getConfig()); // $html = $converter->convertToHtml($string); $this->assertSame($expected, $html); }
/** * Returns rendered view * * @return string */ public function render() { if ($this->isMarkdown()) { $environment = Environment::createCommonMarkEnvironment(); $environment->addInlineParser(new TwitterHandleParser()); $parser = new DocParser($environment); $htmlRenderer = new HtmlRenderer($environment); $document = $parser->parse(file_get_contents($this->filename)); return $htmlRenderer->renderBlock($document); } ob_start(); extract($this->vars); require $this->filename; return ob_get_clean(); }
public function transform($markdownText) { $environment = Environment::createCommonMarkEnvironment(); $beforeParseEvent = Croogo::dispatchEvent('Helper.Markdown.beforeMarkdownParse', $this->_View, array('environment' => $environment, 'markdown' => $markdownText)); $markdownText = $beforeParseEvent->data['markdown']; $environment = $beforeParseEvent->data['environment']; $parser = new DocParser($environment); $htmlRenderer = new HtmlRenderer($environment); $documentAST = $parser->parse($markdownText); $beforeRenderEvent = Croogo::dispatchEvent('Helper.Markdown.beforeMarkdownRender', $this->_View, array('ast' => $documentAST)); $documentAST = $beforeRenderEvent->data['ast']; $rendered = $htmlRenderer->renderBlock($documentAST); $afterRenderEvent = Croogo::dispatchEvent('Helper.Markdown.afterMarkdownRender', $this->_View, array('rendered' => $rendered)); return $afterRenderEvent->data['rendered']; }
/** * Converts CommonMark to HTML. * * @param string $commonMark * * @return string * * @api */ public function convertToHtml($commonMark) { $documentAST = $this->docParser->parse($commonMark); return $this->htmlRenderer->renderBlock($documentAST); }
public function renderDocument($ast) { $renderer = new HtmlRenderer($this->getCommonMarkEnvironment()); return $renderer->renderBlock($ast); }
/** * Parse markdown to html * * @param string $markdown * @return string */ public function parse($markdown) { $document = $this->parser->parse($markdown); $html = $this->renderer->renderBlock($document); return $html; }
/** * Render a string of text * * @param string $text * @return string */ public function render($string) { $document = $this->parser->parse($string); return $this->renderer->renderBlock($document); }