コード例 #1
0
ファイル: Post.php プロジェクト: stojg/puny
 /**
  * Get this posts content as html transformed through markdown
  *
  * @return string
  */
 public function getContentHTML()
 {
     $markdown = new \dflydev\markdown\MarkdownParser();
     return $markdown->transformMarkdown($this->getContent());
 }
コード例 #2
0
    // create an array that will hold our posts
    $posts = array();
    // loop through our DirectoryIterator
    foreach ($files as $post) {
        // only process .md file extensions
        if ($post->getExtension() === 'md') {
            // get the post file's data
            $post_data = file_get_contents($post->getPathname());
            // parse the file for its meta data
            $post_data = explode('--', $post_data);
            // move the meta data into its array, and decode the json data
            $post_meta_json = array_shift($post_data);
            $post_meta = json_decode($post_meta_json, true);
            // parse the markdown portion into HTML
            $md = new dflydev\markdown\MarkdownParser();
            $post_html = $md->transformMarkdown($post_data[0]);
            // save each post to our array, and store
            // the post details as a new hash
            $posts[strtotime($post_meta['date'])] = array('title' => $post_meta['title'], 'desc' => $post_meta['desc'], 'date' => $post_meta['date'], 'tags' => $post_meta['tags'], 'link' => $post->getBasename('.md'), 'html' => $post_html);
        }
    }
    // sort our posts (inversely) by created date (the key value)
    krsort($posts);
    // return our posts
    return $posts;
};
// ----------------------------------------------------------
// ------------------------ ROUTES --------------------------
// home page
$blog->get('/', function () use($blog, $getMarkdownPosts) {
    // get our posts
コード例 #3
0
ファイル: index.php プロジェクト: raynaldmo/php-education
<?php

require 'vendor/autoload.php';
$md = new \dflydev\markdown\MarkdownParser();
$content = file_get_contents('text.md');
echo $md->transformMarkdown($content);
コード例 #4
0
ファイル: app.php プロジェクト: dragonee/php-silverplate
 public function renderMD($pathname)
 {
     $parser = new \dflydev\markdown\MarkdownParser();
     $contents = $this->parseMDMeta(file_get_contents($pathname));
     return $parser->transformMarkdown(str_replace('path://', App::path(), $contents));
 }
コード例 #5
-1
ファイル: Application.php プロジェクト: researchgate/broker
 public function run()
 {
     $that = $this;
     $app = new \Slim(array('view' => 'rg\\broker\\web\\View', 'templates.path' => './src/rg/broker/web/templates'));
     $this->app = $app;
     $app->get('/', function () use($app, $that) {
         /** @var \Slim $app */
         /** @var Application $that  */
         $mdParser = new \dflydev\markdown\MarkdownParser();
         $content = $mdParser->transformMarkdown(file_get_contents(ROOT . '/README.md'));
         $app->render('home.php', array('repositories' => $that->getRepositories(), 'content' => $content));
     });
     $app->get('/repositories/:repositoryName/', function ($repositoryName) use($app, $that) {
         /** @var \Slim $app */
         /** @var Application $that  */
         $app->render('repository.php', array('repositories' => $that->getRepositories(), 'currentRepository' => $that->getRepository($repositoryName)));
     });
     $app->get('/repositories/:repositoryName/package/:packageName', function ($repositoryName, $packageName) use($app, $that) {
         /** @var \Slim $app */
         /** @var Application $that  */
         $packageName = urldecode($packageName);
         $app->render('package.php', array('repositories' => $that->getRepositories(), 'currentRepository' => $that->getRepository($repositoryName), 'package' => $that->getPackage($repositoryName, $packageName)));
     });
     $app->run();
 }