/** * Generate a preview * * @param array $input * @param $user * @return \Illuminate\View\View */ public function generatePost($input, $user) { // Generate preview post $post = $this->postRepo->getEmptyPost(); $post->author = $user; $post->markdown = $input['content']; $post->html = \Purifier::clean(\Markdown::text($input['content'])); return $post; }
/** * Create post * * @param array $input * @param $topic * @param $user * @param bool $add * @return \Illuminate\Http\RedirectResponse|object */ public function create($input, $topic, $user, $add = true) { // Create post $data = ['markdown' => $input['content'], 'html' => \Purifier::clean(\Markdown::text($input['content'])), 'topic_id' => $topic->id, 'user_id' => $user->id]; if (\Bouncer::hasPermission('devresponse') and \Input::get('devresponse') == 1) { $data['developer_response'] = true; } $post = $this->postRepo->create($data); return $post; }
public function testTablesHaveTableClass() { $parser = new Markdown(); $content = <<<'MARKDOWN' |Tables|Is| |------|--| |OK |? | MARKDOWN; $result = $parser->text($content); $this->assertEquals("<table class=\"table\">\n<thead>\n<tr>\n<th>Tables</th>\n<th>Is</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>OK</td>\n<td>?</td>\n</tr>\n</tbody>\n</table>", $result); }
protected function readDoc($fileName) { // Key for cache $cacheKey = md5('docs.' . $fileName); // use cache if exist if ($this->cache->has($cacheKey)) { return $this->cache->get($cacheKey); } $getContent = $this->file->get(base_path('docs/' . $fileName)); $doc = \Markdown::text($getContent); // Put it in cache $this->cache->put($cacheKey, $doc, 10080); return $doc; }
public function getBodyHtmlAttribute($field) { return \Markdown::text($this->body); }
/** * @param string $input * @return string HTML */ public static function render($input) { $md = new Markdown(); return preg_replace('/^<p>|<\\/p>$/', '', $md->text($input)); }
function markdown_settings($filename) { return Markdown::text(settings($filename)); }
<?php preg_match('/^\\s*(#{1,})(.*)/m', $text, $title); ?> <title><?php echo $title[2]; ?> </title> </head> <body> <?php if (!preg_match('/index.md$/', $file)) { ?> <div class="toc"> <?php echo $instance->text(toc_file($file, FALSE)); ?> </div> <?php } ?> <?php echo $instance->text($text); ?> <script src="<?php echo $url; ?> prism.js"></script> </body> </html>
/** * @param $postId * @param $input */ public function edit($postId, $input) { // Edit post $this->postRepo->edit($postId, ['markdown' => $input['content'], 'html' => \Purifier::clean(\Markdown::text($input['content']))]); }