Esempio n. 1
0
 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;
 }
Esempio n. 2
0
 public function __construct($markdown, $flags = 0)
 {
     parent::__construct();
     $inputMask = MarkdownDocument::NOHEADER | MarkdownDocument::TABSTOP;
     $this->initFromString((string) $markdown, $flags & $inputMask);
     $this->compile((int) $flags & ~$inputMask);
 }
Esempio n. 3
0
 public function formatFile($file)
 {
     $fd = fopen($file, "r");
     $md = \MarkdownDocument::createFromStream($fd);
     $md->compile(\MarkdownDocument::AUTOLINK | \MarkdownDocument::TOC);
     $html = $md->getHtml();
     fclose($fd);
     return $html;
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
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>
Esempio n. 6
0
<?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;
Esempio n. 7
0
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&rsquo;s back.</p>
Esempio n. 8
0
<?php

$f = dirname(__FILE__) . "/syntax_start.txt";
$md = MarkdownDocument::createFromStream($f);
$md->compile();
var_dump($md->dumpTree($file = fopen('php://temp', 'r+'), "syntax_st"));
echo stream_get_contents($file, -1, 0);
/* if your platform provides the fopencookie native function, you can skip
 * stream_get_contents and the temporary file and do:
 * $md->dumpTree('php://output', "syntax_st");
 */
/* Example of output:

bool(true)
syntax_st--+--[source]-----[header, <P>, 1 line]
           |--[html, 7 lines]
           `--[source]--+--[ul, <P>]--+--[item]--+--[markup, 1 line]
                        |             |          `--[ul, <P>]--+--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]
                        |             |                        `--[item]-----[markup, 1 line]
                        |             |--[item]--+--[markup, 1 line]
                        |             |          `--[ul, <P>]--+--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]
                        |             |                        `--[item]-----[markup, 1 line]
                        |             |--[item]--+--[markup, 1 line]
                        |             |          `--[ul, <P>]--+--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]
                        |             |                        |--[item]-----[markup, 1 line]