public function viewPost($postId) { $id = $postId; $posts = $return = array(); $template = ''; //$posts = $this->ksdb->dbselect('posts', array('*')); $query = $this->ksdb->db->prepare("SELECT * FROM posts WHERE id = " . $id); try { $query->execute(); for ($i = 0; $row = $query->fetch(); $i++) { $return[$i] = array(); foreach ($row as $key => $rowitem) { $return[$i][$key] = $rowitem; } } } catch (PDOException $e) { echo $e->getMessage(); } $posts = $return; //$posts = $this->ksdb->dbselect('posts', array('*'),array('id' => $id)); $markdown = new Michelf\Markdown(); $posts[0]['content'] = $markdown->defaultTransform($posts[0]['content']); $postComments = $this->comments->getComments($posts[0]['id']); $template = 'view-post.php'; include_once 'frontend/templates/' . $template; }
public function viewpost($postid) { $id = $postid; $posts = $this->ksdb->dbselect('posts', array('*'), array('id' => $id)); $markdown = new Michelf\Markdown(); $posts[0]['content'] = $markdown->defaultTransform($posts[0]['content']); $postcomments = $this->comments->getcomments($posts[0]['id']); $template = 'view-post.php'; include_once 'frontend/templates/' . $template; }
function getBlock() { // TO DO: this needs to run through eatStaticStorage if (file_exists(DATA_ROOT . '/blocks/' . $this->block_file . '.txt')) { $this->content = $this->read_file(DATA_ROOT . '/blocks/' . $this->block_file . '.txt'); } if (file_exists(DATA_ROOT . '/blocks/' . $this->block_file . '.md')) { $this->raw_content = $this->read_file(DATA_ROOT . '/blocks/' . $this->block_file . '.md'); require_once LIB_ROOT . "/php-markdown/Markdown.inc.php"; $this->content = Michelf\Markdown::defaultTransform($this->raw_content); } return '<span class="block block-' . $this->block_file . '">' . $this->content . '</span>'; }
/** * Parse Markdown and convert to HTML. * Use PHP Markdown & Markdown Extra: http://michelf.ca/projects/php-markdown/ * * @param string $text Text to parse Markdown. * @param string $extra Use MarkdownExtra: http://michelf.ca/projects/php-markdown/extra/ . * * @return string Parsed Text. */ public static function markdown($text, $extra = true, $option = array()) { require_once AKPATH_HTML . "/php-markdown/Markdown.php"; $text = str_replace("\t", ' ', $text); if ($extra) { require_once AKPATH_HTML . "/php-markdown/MarkdownExtra.php"; $result = Michelf\MarkdownExtra::defaultTransform($text); } else { $result = Michelf\Markdown::defaultTransform($text); } if (JArrayHelper::getValue($option, 'highlight_enable', 1)) { self::highlight(JArrayHelper::getValue($option, 'highlight', 'default')); } return $result; }
/** * the page will be a content file in a folder matching the path * or /foo/bar/edd/content.md * or even /foo/bar/edd/content.html * HTML pages with a filename starting with _ are assumed to be partials * if not, full HTML pages * * markdown pages are partials, using a default base template * or a custom base template specified in meta * */ public function getPage($sub_path) { global $page; require_once EATSTATIC_ROOT . "/eatStaticPage.class.php"; $page = new eatStaticPage(); $page_exists = false; if (file_exists($this->root . $sub_path . ".md")) { $raw_content = $this->read_file($this->root . $sub_path . ".md"); $page->content_mode = 'markdown'; $page_exists = true; } if (file_exists($this->root . $sub_path . ".php")) { $ext = "php"; $page->content_mode = 'php'; $page_exists = true; } if (!$page_exists) { return; } switch ($page->content_mode) { case "markdown": // extract meta $split_content = explode('--', $raw_content); if (sizeOf($split_content) > 1) { $raw_meta = $split_content[1]; } $parts = explode("\n", $raw_content); $page->title = str_replace('#', '', $parts[0]); // process remainder and return require_once LIB_ROOT . "/php-markdown/Markdown.inc.php"; $page->content = Michelf\Markdown::defaultTransform($split_content[0]); break; case "php": ob_start(); include $this->root . $sub_path . ".php"; $page->content = ob_get_contents(); ob_end_clean(); break; case "html": // TODO: get first char of filename to see if it is a partial // TODO: return as whole page, or embedded in base template break; } return $page; }
function parse() { return Michelf\Markdown::defaultTransform($this->content); }
/** * Markdown to HTML */ public function markdownToHtml($markdown) { $messageHTML = Michelf\Markdown::defaultTransform($markdown); return $messageHTML; }
<?php echo Michelf\Markdown::defaultTransform($block['text']);
public static function tr($text) { return Michelf\Markdown::defaultTransform($text); }
function ExplainMarkdown($path, $font = null) { $text = file_get_contents($path); return Michelf\Markdown::defaultTransform($text, $font); }
function hydrate() { $this->raw_data = $this->read_file($this->data_file_path); if ($this->raw_data == '') { // no post content found } $ext = $this->getExtension($this->data_file_path); if ($ext == 'md') { $this->source_format = 'markdown'; require_once LIB_ROOT . "/php-markdown/Markdown.inc.php"; } $parts = explode("\n", $this->raw_data); $str = ''; $format_str = ''; // get title from first line $this->title = $parts[0]; $body = true; $meta = false; $raw_body = ''; $raw_meta = ''; // the rest is body for ($i = 1; $i < sizeof($parts); $i++) { $str = $str . $parts[$i]; if ($i > 1) { // the body section can be the rest of the file, // or you can mark the end of the body section with -- // you can then put meta data fields in the file if (eatStatic::stripLineBreaks($parts[$i]) == '--' && $meta == false) { $body = false; $meta = true; } if ($body) { $raw_body = $raw_body . $parts[$i] . "\n"; // formatted body - for text format, line breaks need to be replaced with br, but not between html elements if ($this->source_format == 'text') { if (substr($parts[$i], -1) != '>') { $format_str = $format_str . $parts[$i] . "<br />\n"; } else { $format_str = $format_str . $parts[$i] . "\n"; } } } // get meta info if ($meta && eatStatic::stripLineBreaks($parts[$i]) != '--') { //die('meta:'.$parts[$i]); if ($parts[$i] != '') { $this->handleMeta($parts[$i]); $raw_meta = $raw_meta . $parts[$i] . "\n"; } } } } if ($this->source_format == 'markdown') { // remove hashes from title $this->title = str_replace('#', '', $this->title); // parse the markdown into HTML $this->formatted_body = Michelf\Markdown::defaultTransform($raw_body); } else { $this->formatted_body = $format_str; } $this->raw_body = $raw_body; $this->raw_meta = $raw_meta; $this->body = $str; $this->file_name = basename($this->data_file_path); if ($this->source_format == 'markdown') { $this->slug = str_replace('.md', '', $this->file_name); } else { $this->slug = str_replace('.txt', '', $this->file_name); } $this->date = substr($this->file_name, 0, 10); $this->slug_trimmed = str_replace($this->date . '-', '', $this->slug); $this->nice_date = date(NICE_DATE_FORMAT, strtotime($this->date)); $this->timestamp = strtotime($this->date); // get gallery items if there are any $gallery = new eatStaticGallery($this->slug . '/'); $this->gallery_items = $gallery->gallery_items; // set up the URI if (WP_URLS) { $date_str = date('Y', strtotime($this->date)) . '-' . date('m', strtotime($this->date)) . '-' . date('d', strtotime($this->date)); $this->uri = SITE_ROOT . date('Y', strtotime($this->date)) . '/' . date('m', strtotime($this->date)) . '/' . date('d', strtotime($this->date)) . '/' . str_replace($date_str . '-', '', $this->slug) . '/'; } else { $this->uri = SITE_ROOT . 'posts/' . $this->slug . PAGE_EXT; } // get the next and previous urls $blog = new eatStaticBlog(); $blog->getPostFiles(); foreach ($blog->post_files as $key => $val) { if ($val == $this->data_file_path) { if ($key > 0) { $this->prev_url = $this->uriFromFilename(basename($blog->post_files[$key - 1])); } if ($key < count($blog->post_files) - 1) { $this->next_url = $this->uriFromFilename(basename($blog->post_files[$key + 1])); } } } }
public static function transform($data) { $md = new \Michelf\Markdown(); return $md->defaultTransform($data); }
public function parsing($text) { $parser = new Michelf\Markdown(); $text = $parser->defaultTransform($text); return $text; }