public function create_object($data) { try { $mc = new \Core\Backend\MemcachedContainer(); $m = $mc->get_backend(); $m_enable = True; } catch (\Core\Backend\MemcachedNotLoadedError $e) { } $data = \Core\Dict::create($data); if (strlen($data->custom_url) > 0) { $data->seo_title = $data->custom_url; } else { $data->seo_title = strtolower(str_replace(' ', '-', $data->title)); } if (extension_loaded('discount')) { $md = \MarkdownDocument::createFromString($data['body']); $md->compile(); $data['body_html'] = $md->getHtml(); } else { import('3rdparty.markdown'); $data['body_html'] = Markdown($data['body']); } $data->preview = substr(strip_tags($data['body_html']), 0, 440); $a = Article::create($data)->form_values(); return $a; }
private function _get_page($filename) { $filename = SITE_PATH . '/pages/' . $filename . '.md'; if (is_file($filename)) { ob_start(); include $filename; $contents = ob_get_contents(); ob_end_clean(); if(extension_loaded('discount')) { $md = \MarkdownDocument::createFromString($contents); $md->compile(); return $md->getHtml(); } else { import('3rdparty.markdown'); import('3rdparty.smartypants'); return \Smartypants(\Markdown($contents)); } } throw new \Core\FileNotFoundError($filename); }
Markdown extra style definition list \t Apple : Pomaceous fruit of plants of the genus Malus in the family Rosaceae. Orange : The fruit of an evergreen tree of the genus Citrus. EOD; $md = MarkdownDocument::createFromString($t); $md->compile(MarkdownDocument::DLEXTRA); echo $md->getHtml(), "\n\n"; /* deactivated: */ echo "Now with NODLIST:\n"; $md = MarkdownDocument::createFromString($t); $md->compile(MarkdownDocument::NODLIST); echo $md->getHtml(); /* Expected output: <p>Discount style definition list:</p> <dl> <dt>term one</dt> <dd>definition 1</dd> <dt>term two</dt> <dd>definition 2</dd> </dl> <p>Markdown extra style definition list</p>
<?php /** * Preview script for MarkItUp markdown * * You may not change or alter any portion of this comment or credits * of supporting developers from this source code or any supporting source code * which is considered copyrighted (c) material of the original comment or credit authors. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @copyright Copyright (c) Pi Engine http://www.xoopsengine.org * @license http://www.xoopsengine.org/license New BSD License * @author Taiwen Jiang <*****@*****.**> * @package Editor\Markitup * @since 3.0 * @version $Id$ */ $content = $_POST['preview']; if (class_exists('MarkdownDocument')) { $markdown = MarkdownDocument::createFromString($content); $markdown->compile(); $content = $markdown->getHtml(); } else { echo '<h2>MarkdownDocument is not available</h2><hr />'; $content = '<pre>' . $content . '</pre>'; } echo $content;
Now is the time for all good men to come to the aid of their country. This is just a regular paragraph. The quick brown fox jumped over the lazy dog's back. ### Header 3 > This is a blockquote. > > This is the second paragraph in the blockquote. > > ## This is an H2 in a blockquote EOD; $md = MarkdownDocument::createFromString($markdown_str); $md->compile(); echo $md->getHtml(); /* Expected output: <h1>A First Level Header</h1> <h2>A Second Level Header</h2> <p>Now is the time for all good men to come to the aid of their country. This is just a regular paragraph.</p> <p>The quick brown fox jumped over the lazy dog’s back.</p>
public function formatString($string) { $md = \MarkdownDocument::createFromString($string); $md->compile(\MarkdownDocument::AUTOLINK); return $md->getHtml(); }