Example #1
0
 public function serveMarkdown($mdFile)
 {
     $basePath = dirname($mdFile) . '/' . basename($mdFile, '.md');
     $source = new Finder();
     $source->append([$mdFile]);
     if (is_dir($basePath)) {
         $children = new Finder();
         $children->in($basePath)->name('*.md')->sortByName();
         $source->append($children);
     }
     $merger = new Merge();
     $content = $merger->mergeFiles($source, $basePath);
     $converter = new Converter();
     $html = $converter->toHtml($content);
     EventManager::dispatch('preHeader');
     header('Content-Type: text/html; charset=utf-8');
     EventManager::dispatch('html', $html);
 }
Example #2
0
<?php

//error_reporting( E_ALL );
//ini_set( 'display_errors', 1 );
define('RMP_MDOC_BASE_DIR', __DIR__);
define('RMP_MDOC_BASE_URL', rtrim($_SERVER['HTTP_HOST'] . str_replace($_SERVER['DOCUMENT_ROOT'], '', getcwd()), '/'));
define('RMP_MDOC_WORKING_DIR', $_SERVER['DOCUMENT_ROOT'] . urldecode($_SERVER['REQUEST_URI']));
require_once __DIR__ . '/Rmp/Helper/Composer.php';
\Rmp\Helper\Composer::load();
\Rmp\Mdoc\EventManager::registerCallable('html', function ($html) {
    require_once __DIR__ . '/templates/md.phtml';
});
$server = new \Rmp\Mdoc\Server();
$server->serve();