function parse_markdown_file($file_path, array $params = array(), $mde_template_path = null)
{
    if (is_null($mde_template_path)) {
        $mde_template_path = get_cache_path(settings('mde_template_filename'));
    }
    prepare_markdown_template($mde_template_path);
    $params = array_merge(settings(), $params);
    extract($params);
    $mde_binary = get_demo_builder_file_path($mde_binary);
    $cmd = "{$mde_binary} --template={$mde_template_path} {$file_path}";
    list($ctt, $status) = execute($cmd);
    if ($status == 0) {
        return array(implode(PHP_EOL, $ctt), false);
    } else {
        throw new ErrorException(sprintf('An error occurred while trying to build markdown page view "%s": "%s"!', $file_path, implode('', $ctt)));
    }
}
Пример #2
0
if (!IS_CLI) {
    settings(array('arg_ln' => isset($_GET['ln']) ? $_GET['ln'] : settings('default_language'), 'arg_page' => isset($_GET['page']) ? $_GET['page'] : settings('default_page'), 'arg_action' => isset($_GET['action']) ? $_GET['action'] : null));
}
// distribute
if (is_null($action = settings('arg_action'))) {
    $content = load_page(settings('arg_page'));
    echo $content;
} else {
    switch ($action) {
        case 'template':
            $path = settings('output_path');
            if (empty($path)) {
                $path = get_cache_path(settings('mde_template_filename'));
            }
            $unlinked = file_exists($path) ? unlink($path) : true;
            if ($unlinked && prepare_markdown_template($path)) {
                ok(sprintf('template file created at "%s"', $path));
            } else {
                error(sprintf('template file NOT created! (check user rights on file "%s")', $path));
            }
            break;
        case 'flush':
            if (flush_cache()) {
                ok(sprintf('app-cache has been flushed at "%s"', settings('temporary_directory')));
            } else {
                error(sprintf('app-cache has NOT been flushed! (check user rights on directory "%s")', settings('temporary_directory')));
            }
            break;
        case 'debug':
            $content = load_page(settings('arg_page'));
            header('Content-Type: text/plain');