protected function parseMarkup() { $result = $this->markup; if (strtolower(File::extension($this->fileName)) == 'md') { $result = Markdown::parse($this->markup); } return $result; }
public function formatHtml($input, $preview = false) { $result = Markdown::parse(trim($input)); if ($preview) { $result = str_replace('<pre>', '<pre class="prettyprint">', $result); } $result = TagProcessor::instance()->processTags($result, $preview); return $result; }
protected function createRss() { $fileContents = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" . "<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n" . "\t<channel>\n" . "\t\t<title>" . Settings::get('title') . "</title>\n" . "\t\t<link>" . Settings::get('link') . "</link>\n" . "\t\t<description>" . Settings::get('description') . "</description>\n" . "\t\t<atom:link href=\"" . Settings::get('link') . "/rss.xml\" rel=\"self\" type=\"application/rss+xml\" />\n\n"; foreach ($this->loadPosts() as $post) { $published = DateTime::createFromFormat('Y-m-d H:i:s', $post->published_at); $description = Settings::get('showFullPostContent') ? $post->content : $post->excerpt; $description = Markdown::parse(trim($description)); $fileContents .= "\t\t<item>\n" . "\t\t\t<title>" . $post->title . "</title>\n" . "\t\t\t<link>" . Settings::get('link') . Settings::get('postPage') . "/" . $post->slug . "</link>\n" . "\t\t\t<guid>" . Settings::get('link') . Settings::get('postPage') . "/" . $post->slug . "</guid>\n" . "\t\t\t<pubDate>" . $published->format(DateTime::RFC2822) . "</pubDate>\n" . "\t\t\t<description>" . htmlspecialchars($description, ENT_QUOTES, 'UTF-8') . "</description>\n" . "\t\t</item>\n"; } $fileContents .= "\t</channel>\n"; $fileContents .= "</rss>\n"; $file = File::put('rss.xml', $fileContents); return $file; }
public static function Format($input) { // Replace $$...$$, $...$, \begin{align}...\end{align}, // \begin{equation}..\end{equation} and similar contrcucts // with dummy "html"-tags. Parsedown will not parse // Markdown inside block-level tags. Apparantly non-existing // tags are interpreted as block-level. //$input = self::Replace($input, '@\$\$(.*)\$\$@', '<math-display>$1</math-display>'); //$input = self::Replace($input, '@\$(.*)\$@', '<math-inline>$1</math-inline>'); $result = Markdown::parse(trim($input)); //$result = self::Replace($result, '@<math-inline>(.*)</math-inline>@', '\$$1\$'); //$result = self::Replace($result, '@<math-display>(.*)</math-display>@', '\$\$$1\$\$'); return $result; }
/** * Renders a requested content file. * The framework uses this method internally. */ public function renderContent($name) { /* * Extensibility */ if ($event = $this->fireEvent('page.beforeRenderContent', [$name], true)) { $content = $event; } elseif ($event = Event::fire('cms.page.beforeRenderContent', [$this, $name], true)) { $content = $event; } elseif (($content = Content::loadCached($this->theme, $name)) === null) { throw new CmsException(Lang::get('cms::lang.content.not_found', ['name' => $name])); } $filePath = $content->getFullPath(); $fileContent = File::get($filePath); if (strtolower(File::extension($filePath)) == 'md') { $fileContent = Markdown::parse($fileContent); } /* * Extensibility */ if ($event = $this->fireEvent('page.renderContent', [$name, $fileContent], true)) { return $event; } if ($event = Event::fire('cms.page.renderContent', [$this, $name, $fileContent], true)) { return $event; } return $fileContent; }
/** * Renders a requested content file. * The framework uses this method internally. */ public function renderContent($name) { if (($content = Content::loadCached($this->theme, $name)) === null) { throw new CmsException(Lang::get('cms::lang.content.not_found', ['name' => $name])); } $filePath = $content->getFullPath(); $fileContent = File::get($filePath); if (strtolower(File::extension($filePath)) == 'md') { $fileContent = Markdown::parse($fileContent); } return $fileContent; }
public function beforeSave() { $this->content_html = Str::cleanHtml(Markdown::parse(trim($this->content))); }
public function beforeSave() { $this->name_html = Markdown::parse($this->name); $this->comment_html = Markdown::parse($this->comment); }