/** * Convert line breaks * * @param Text $text */ public function initialize(Text $text) { $text->replaceString("\r\n", "\n"); $text->replaceString("\r", "\n"); $text->append("\n\n"); $this->markdown->emit('detab', array($text)); $text->replace('/^[ \\t]+$/m', ''); }
public function testAppendPrependWrap() { $text = new Text('content'); $expected = '<p>content</p>'; $p = $text->append('</p>')->prepend('<p>'); $this->assertEquals($expected, (string) $p); $text = new Text('content'); $this->assertEquals($expected, (string) $text->wrap('<p>', '</p>')); }
/** * {@inheritdoc} */ public function renderCodeBlock($content, array $options = array()) { if (!$content instanceof Text) { $content = new Text($content); } $options = $this->createResolver()->resolve($options); $tag = Tag::create('pre')->setAttributes($options['attr'])->setText(Tag::create('code')->setText($content->append("\n"))->render()); $this->getEmitter()->emit('tag', [$tag]); return $tag->render(); }
/** * {@inheritdoc} */ public function renderCodeBlock($content, array $options = array()) { if (!$content instanceof Text) { $content = new Text($content); } $options = $this->createResolver()->resolve($options); $pre = new Tag('pre'); $pre->setAttributes($options['attr']); $code = new Tag('code'); $code->setText($content->append("\n")); $pre->setText($code->render()); return $pre->render(); }