コード例 #1
2
 public function readme()
 {
     $result = $this->_shell->getBlob($this, $this->_currentBranch, 'README.md');
     $parsedown = new \Parsedown();
     $result = $parsedown->text($result);
     return str_replace('<pre>', '<pre class="prettyprint linenums">', $result);
 }
コード例 #2
0
ファイル: Consumable.php プロジェクト: lutherpros/snipe-it
 public function getEula()
 {
     $Parsedown = new Parsedown();
     if ($this->category->eula_text) {
         return $Parsedown->text(e($this->category->eula_text));
     } elseif (Setting::getSettings()->default_eula_text && $this->category->use_default_eula == '1') {
         return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
     } else {
         return null;
     }
 }
コード例 #3
0
/**
 * UCFBands Rehearsal - Get Schedule
 *
 * @author Jordan Pakrosnis
 */
function ucfbands_rehearsal_schedule($schedule_items)
{
    // Include Parsedown
    require_once CHILD_DIR . '/inc/parsedown/Parsedown.php';
    $Parsedown = new Parsedown();
    // Schedule Output String
    $schedule = '';
    // Schedule Wrapper
    $schedule .= '<div class="event-schedule"><h5>Schedule</h5>';
    // Start UL
    $schedule .= '<ul>';
    //-- SCHEDULE ITEM LOOP --//
    foreach ($schedule_items as $schedule_item) {
        // Get Item Meta
        $time = esc_attr($schedule_item['time']);
        $thing = esc_attr($schedule_item['thing']);
        $sub_items = $schedule_item['sub_item'];
        // Make "AM" and "PM" lowercase
        $time = explode(" ", $time);
        $time[1] = strtolower($time[1]);
        // Start List Item
        $schedule .= '<li>';
        // Parse thing into Markdown HTML
        $thing = $Parsedown->text($thing);
        // Time & Thing
        $schedule .= '<span>' . $time[0] . ' ' . $time[1] . '</span>' . $thing;
        // Check for sub-items
        if ($sub_items != '') {
            // Nested UL
            $schedule .= '<ul>';
            foreach ($sub_items as $sub_item) {
                // Parse item into Markdown HTML
                $sub_item = $Parsedown->text($sub_item);
                // Output Sub item
                $schedule .= '<li>' . $sub_item . '</li>';
            }
            // foreach sub-item
            $schedule .= '</ul>';
        }
        // if sub-items
        $schedule .= '</li>';
    }
    // foreach Item Loop
    $schedule .= '</ul>';
    //     Close Schedule Wrapper
    $schedule .= '</div>';
    // Return Schedule String
    return $schedule;
}
コード例 #4
0
 /**
  *
  * @param $text
  * @param null $cacheKey
  * @param int $life cache life time
  * @return mixed|string
  */
 public function render($text, $cacheKey = null, $life = 360)
 {
     //
     if (!$life || is_null($cacheKey)) {
         $text = $this->convertToRef($text);
         return $this->parser->text($text);
     }
     if (\Cache::has($cacheKey)) {
         return \Cache::get($cacheKey);
     }
     $text = $this->convertToRef($text);
     $result = $this->parser->text($text);
     \Cache::put($cacheKey, $result, $life);
     return $result;
 }
コード例 #5
0
ファイル: Helper.php プロジェクト: stijni/snipe-it
 public static function parseEscapedMarkedown($str)
 {
     $Parsedown = new \Parsedown();
     if ($str) {
         return $Parsedown->text(e($str));
     }
 }
コード例 #6
0
ファイル: CommentController.php プロジェクト: sh1nu11bi/CloMa
 public function postComment($id)
 {
     $input = Input::all();
     Log::info($input);
     $validator = Comment::validate($input);
     if ($validator->fails()) {
         FlashHelper::message("Null title", FlashHelper::DANGER);
         return;
     }
     $post = Post::findOrFail($id);
     if (!$post->can_comment || !PrivacyHelper::checkPermission(Auth::user(), $post)) {
         throw new Exception("Don't have permision");
     }
     $comment = new Comment();
     $Parsedown = new Parsedown();
     $comment->post_id = $id;
     $comment->parrent_id = $input['parrent_id'];
     $comment->markdown = $input['markdown'];
     Log::info($comment);
     $comment->HTML = $Parsedown->text($comment->markdown);
     $comment->save();
     $comment->comments = array();
     $data['html'] = View::make('posts._comment')->with('data', $comment)->with('level', count($comment->parents()))->with('can_comment', true)->render();
     $data['status'] = true;
     $data['parent_id'] = $comment->parrent_id;
     return Response::json($data);
 }
コード例 #7
0
ファイル: Draft.php プロジェクト: HyuchiaDiego/Draft
function build($directory)
{
    $menu = "";
    $pages = "";
    foreach (glob("{$directory}/*", GLOB_MARK) as $f) {
        $find = array(".html", ".md", ".php", " ");
        $replace = array("", "", "", "-");
        $spaces = array("_", "-");
        $nice_name = str_replace($find, $replace, basename($f));
        $cap_name = ucwords(strtolower(str_replace($spaces, " ", $nice_name)));
        if (substr($f, -1) === '/') {
            $content = build($f);
            $pages .= $content[1];
            $menu .= "<li>\n\t\t\t\t\t<span data-menu='submenu'><i class='fa fa-plus-circle'></i> <span>{$cap_name}</span></span>\n\t\t\t\t\t<ul>";
            $menu .= $content[0];
            $menu .= "</ul></li>";
        } else {
            if ($cap_name != "Main") {
                $pages .= "<section class='doc' data-doc='{$nice_name}'>";
                $menu .= "<li data-show='{$nice_name}'> {$cap_name}</li>";
                if (end(explode('.', basename($f))) == "md") {
                    $Parsedown = new Parsedown();
                    $pages .= $Parsedown->text(file_get_contents($f));
                } else {
                    $pages .= file_get_contents($f);
                }
                $pages .= "</section>";
            }
        }
    }
    return [$menu, $pages];
}
コード例 #8
0
ファイル: TceMain.php プロジェクト: MaxServ/t3ext-parsedown
 /**
  * Convert markdown to html on saving
  *
  * @param array $incommingFieldArray (reference) The field array of a
  *     record
  * @param string $table The table currently processing data for
  * @param string $id The record uid currently processing data for,
  *     [integer] or [string] (like 'NEW...')
  * @param \TYPO3\CMS\Core\DataHandling\DataHandler $parentObject
  *
  * @return void
  */
 public function processDatamap_preProcessFieldArray(&$incomingFieldArray, $table, $id, $parentObject)
 {
     if ($incomingFieldArray['CType'] == 'parsedown_markdown') {
         $parseDown = new \Parsedown();
         $incomingFieldArray['bodytext'] = $parseDown->text((string) $incomingFieldArray['tx_parsedown_content']);
     }
 }
コード例 #9
0
ファイル: BuildDocs.php プロジェクト: dev-lucid/lucid
 public function run()
 {
     include getcwd() . '/vendor/autoload.php';
     $navStructure = (include getcwd() . '/docs/navigation.php');
     echo "Loading markdown...\n";
     $markdown = $this->findMarkdown($navStructure);
     echo "Converting markdown to html...\n";
     $Parsedown = new \Parsedown();
     $html = $Parsedown->text($markdown);
     $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     #$pdf->SetAuthor('Nicola Asuni');
     $pdf->SetTitle('My Documentation');
     #$pdf->SetSubject('TCPDF Tutorial');
     #$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $pdf->setPrintHeader(false);
     $pdf->setPrintFooter(false);
     $pdf->SetFont('helvetica', '', 20);
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->AddPage();
     $pdf->writeHTML($html, true, 0, true, 0);
     $pdf->lastPage();
     echo "Writing PDF...\n";
     $pdf->Output($this->config['output'], 'F');
     echo "Complete.\n";
 }
コード例 #10
0
 public function handle()
 {
     $this->page = Page::find_by_title($this->request->page);
     # Action tree
     if ($this->request->action_is('save')) {
         # TODO: validate request before saving
         if (strlen($this->request->post('wmd-input')) > self::MAX_BODY_LENGTH) {
             $this->t->flash('Page content is too long. Please shorten.', 'warning');
             $this->t->data('page-body', $this->request->post('wmd-input'));
         } else {
             $this->page->set('body', $this->request->post('wmd-input'));
             $this->page->save();
             NeechyResponse::redirect($this->page->url());
         }
     } elseif ($this->request->action_is('preview')) {
         $markdown = new Parsedown();
         $preview_html = $markdown->text($this->request->post('wmd-input'));
         $this->t->data('preview', $preview_html);
         $this->t->data('page-body', $this->request->post('wmd-input'));
     } elseif ($this->request->action_is('edit')) {
         $this->t->data('page-body', $this->request->post('wmd-input'));
     } else {
         $this->t->data('page-body', $this->page->field('body'));
     }
     # Partial variables
     $last_edited = sprintf('Last edited by %s on %s', $this->page->editor_link(), $this->page->field('created_at'));
     $page_title = NeechyTemplater::titleize_camel_case($this->page->get_title());
     # Render partial
     $this->t->data('action', $this->request->action);
     $this->t->data('page-title', $page_title);
     $this->t->data('last-edited', $last_edited);
     $content = $this->render_view('editor');
     # Return response
     return $this->respond($content);
 }
コード例 #11
0
ファイル: Parser.php プロジェクト: stof/Gitiki
 public function page(Page $page)
 {
     $this->tocBuilder = new TocBuilder();
     $page->setContent(parent::text($page->getContent()));
     $page->setToc($this->tocBuilder->getToc());
     $this->tocBuilder = null;
 }
コード例 #12
0
ファイル: MergeTrait.php プロジェクト: comdeng/firegit
 function merge_action($mergeId)
 {
     $this->setBranch();
     $api = new \firegit\app\mod\git\Merge();
     $merge = $api->getMerge($mergeId);
     if (!$merge) {
         throw new \Exception('firegit.u_notfound');
     }
     $orig = $merge['orig_branch'];
     $dest = $merge['dest_branch'];
     setcookie('branch', $orig, time() + 3600 * 24, '/');
     //blame使用cookie
     $commits = $this->repo->listCommits($orig, $dest);
     $branches = $this->repo->listBranches();
     $umod = new \firegit\app\mod\user\User();
     $tusers = $umod->getUsers();
     // 评论
     $modComment = new \firegit\app\mod\util\Comment();
     $comments = $modComment->getComments(1, $mergeId, $this->_sz);
     require_once VENDOR_ROOT . '/parsedown/Parsedown.php';
     $parsedown = new \Parsedown();
     foreach ($comments['list'] as $key => $value) {
         $comments['list'][$key]['content'] = $parsedown->text($value['content']);
     }
     $this->set(array('pageTitle' => '合并请求:' . $merge['title'], 'merge' => $merge, 'commits' => $this->packCommits($commits), 'navType' => 'merge', 'branches' => $branches, 'orig' => $orig, 'dest' => $dest, 'tusers' => $tusers, 'notShowNav' => true, 'comments' => $comments['list'], 'curUser' => $this->getData('user')))->setView('git/merge.phtml');
 }
コード例 #13
0
ファイル: Model.php プロジェクト: blechdom/inventory
 public function getNote()
 {
     $Parsedown = new Parsedown();
     if ($this->note) {
         return $Parsedown->text(e($this->note));
     }
 }
コード例 #14
0
ファイル: myFunc.php プロジェクト: sky-L/LBlog-Slim
/**
 * 获取全部文章资源
 * @param  integer $page
 * @param  integer $perpage
 * @return
 */
function get_posts($page = 1, $perpage = 0)
{
    if ($perpage == 0) {
        $perpage = 5;
    }
    $posts = get_post_names();
    // 当前页面posts
    $posts = array_slice($posts, ($page - 1) * $perpage, $perpage);
    $tmp = [];
    $Parsedown = new Parsedown();
    foreach ($posts as $v) {
        $post = new stdClass();
        $arr = explode('_', $v);
        // 从文件名获取时间戳
        $post->date = strtotime(str_replace('posts/', '', $arr[0]));
        // 获取url
        $post->url = './' . date('Y/m', $post->date) . '/' . str_replace('.md', '', $arr[1]);
        // 得到post内容
        $content = $Parsedown->text(file_get_contents($v));
        $arr = explode('</h1>', $content);
        $post->title = str_replace('<h1>', '', $arr[0]);
        $post->body = $arr[1];
        $tmp[] = $post;
    }
    return $tmp;
}
コード例 #15
0
ファイル: Template.php プロジェクト: samwilson/swidau
 public function render($echo = false)
 {
     // Load template directories.
     $loader = new \Twig_Loader_Filesystem();
     $loader->addPath('templates');
     // Set up Twig.
     $twig = new \Twig_Environment($loader, array('debug' => true, 'strct_variables' => true));
     $twig->addExtension(new \Twig_Extension_Debug());
     // Mardown support.
     $twig->addFilter(new \Twig_SimpleFilter('markdown', function ($text) {
         $parsedown = new \Parsedown();
         return $parsedown->text($text);
     }));
     // DB queries.
     $twig->addFunction(new \Twig_SimpleFunction('db_queries', function () {
         return Db::getQueries();
     }));
     // Render.
     $string = $twig->render($this->template, $this->data);
     if ($echo) {
         echo $string;
     } else {
         return $string;
     }
 }
コード例 #16
0
 protected function invokeHandler()
 {
     $content = $this->file->getContent();
     $parsedown = new Parsedown();
     $this->smarty->assign('content', $parsedown->text($content));
     $this->smarty->display('handler/markdown.tpl');
 }
コード例 #17
0
 function it_can_parse_html_from_file(\Parsedown $parser, Filesystem $filesystem)
 {
     $this->setPath('path/to/file.md');
     $filesystem->get('path/to/file.md')->shouldBeCalled()->willReturn('Some Markdown');
     $parser->text('Some Markdown')->shouldBeCalled()->willReturn('Parsed Markdown');
     $this->getHtml()->shouldBe('Parsed Markdown');
 }
コード例 #18
0
ファイル: CommonMarkTest.php プロジェクト: sh1nu11bi/CloMa
 /**
  * @dataProvider data
  * @param $section
  * @param $markdown
  * @param $expectedHtml
  */
 function test_($section, $markdown, $expectedHtml)
 {
     $parsedown = new Parsedown();
     $actualHtml = $parsedown->text($markdown);
     $actualHtml = $this->normalizeMarkup($actualHtml);
     $this->assertEquals($expectedHtml, $actualHtml);
 }
コード例 #19
0
ファイル: AriiDoc.php プロジェクト: AriiPortal/Arii
 public function Parsedown($doc)
 {
     $Parsedown = new \Parsedown();
     $parsedown = $Parsedown->text($doc);
     $parsedown = str_replace('<table>', '<table class="table table-striped table-bordered table-hover">', $parsedown);
     return $parsedown;
 }
コード例 #20
0
 /**
  * @param string $text
  *
  * @return string
  */
 protected function parse_markdown($text)
 {
     static $markdown = null;
     if (is_null($markdown)) {
         $markdown = new \Parsedown();
     }
     return $markdown->text($text);
 }
コード例 #21
0
ファイル: Post.php プロジェクト: asteph/Laravel_Blog
 public static function renderBody($post)
 {
     $Parsedown = new Parsedown();
     $dirty_html = $Parsedown->text($post);
     $purifier = new HTMLPurifier();
     $clean_html = $purifier->purify($dirty_html);
     return $clean_html;
 }
コード例 #22
0
ファイル: Post.php プロジェクト: navarr/magehero
 public function getBodyAsHtml()
 {
     $parseDown = new Parsedown();
     $purifier = new HTMLPurifier(HTMLPurifier_Config::createDefault());
     $body = $parseDown->text($this->get('body'));
     $body = $purifier->purify($body);
     return $body;
 }
コード例 #23
0
ファイル: Blog.php プロジェクト: iamjones/personal-blog
 /**
  * Render a blog post
  *
  * @param  string $path
  * @return string $html
  * @access public
  */
 public function render($name)
 {
     if (!$name) {
         throw new Exception('Blog::render - Required a path for the blog file');
     }
     $parsedown = new \Parsedown();
     return $parsedown->text(file_get_contents(BLOG_PATH . '/' . $this->getFilename($name)));
 }
コード例 #24
0
ファイル: Markdown.php プロジェクト: goribun/goribun-source
 /**
  * convert 
  * 
  * @param string $text 
  * @return string
  */
 public static function convert($text)
 {
     static $parser;
     if (empty($parser)) {
         $parser = new Parsedown();
     }
     return $parser->text($text);
 }
コード例 #25
0
 /**
  * Renders a template and returns the result as a string.
  *
  * throws RuntimeException if $templatePath . $template does not exist
  *
  * @param $template
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  *
  * @return mixed
  */
 public function fetch($template)
 {
     if (!is_file($this->templatePath . $template)) {
         throw new \RuntimeException("View cannot render `{$template}` because the template does not exist");
     }
     $output = $this->parsedown->text(file_get_contents($this->templatePath . $template));
     return $output;
 }
コード例 #26
0
 public function renderBody()
 {
     $parse = new Parsedown();
     $config = HTMLPurifier_Config::createDefault();
     $purifier = new HTMLPurifier($config);
     $body = $parse->text($this->description);
     return $clean_html = $purifier->purify($body);
 }
コード例 #27
0
 /**
  * Process this field based on its template and the received data.
  *
  * @param cbField $field
  * @param array $data
  * @return mixed
  */
 public function process(cbField $field, array $data = array())
 {
     $tpl = $field->get('template');
     //$this->modx->log(modX::LOG_LEVEL_ERROR,"process\n" . print_r($data,true));
     $Parsedown = new Parsedown();
     $data['value'] = $Parsedown->text($data['value']);
     return parent::process($field, $data);
     //return $Parsedown->text($this->contentBlocks->parse($tpl, $data));
 }
コード例 #28
0
ファイル: header.php プロジェクト: niehao100/thedc17_web
function handlestr($str)
{
    //$str=str_replace(" ", "&nbsp;", $str);
    $str = str_replace("<", "&lt;", $str);
    $str = str_replace(">", "&gt;", $str);
    //$str=str_replace("\n", "<br>", $str);
    $Parsedown = new Parsedown();
    return $Parsedown->text($str);
}
コード例 #29
0
ファイル: Setting.php プロジェクト: lutherpros/snipe-it
 public static function getDefaultEula()
 {
     $Parsedown = new Parsedown();
     if (Setting::getSettings()->default_eula_text) {
         return $Parsedown->text(e(Setting::getSettings()->default_eula_text));
     } else {
         return null;
     }
 }
コード例 #30
0
ファイル: advancemarkdown.php プロジェクト: MikeCoder/mblog
function advancemarkdown_savelog($id)
{
    header("Content-Type:text/html;charset=utf-8");
    global $logData, $Log_Model;
    include EMLOG_ROOT . '/content/plugins/advancemarkdown/lib/parsedown.php';
    $Parsedown = new Parsedown();
    $logData['content'] = $Parsedown->text($logData['content']);
    $Log_Model->updateLog($logData, $id);
}