コード例 #1
0
ファイル: gen_doc.php プロジェクト: colindj/ssdb-docs
function gen_doc($file, $output_dir, $template = null, $base_url = '')
{
    $name = str_replace('.md', '', basename($file));
    $markdown = array('name' => $name, 'input_file' => $file, 'output_file' => "{$output_dir}/{$name}.html", 'title' => '', 'html' => '', 'base_url' => $base_url);
    if (file_exists($markdown['output_file']) && filemtime($file) < filemtime($markdown['output_file'])) {
        echo "[skip] {$markdown['output_file']} => {$markdown['output_file']}\n";
        return;
    }
    $in_comment = false;
    $lines = file($file);
    foreach ($lines as $line) {
        if ($line[0] == '`') {
            $in_comment = $in_comment ? false : true;
        }
        if ($line[0] == '#' && $line[1] != '#' && !$in_comment) {
            $line = trim($line);
            $line = trim($line, '#');
            $line = trim($line);
            $markdown['title'] = $line;
        }
    }
    $cmd = "python -m markdown.__main__ -x tables -x fenced_code -x headerid {$file}";
    exec($cmd, $result, $retval);
    $markdown['html'] = join("\n", $result);
    if ($template) {
        ob_start();
        include $template;
        $html = ob_get_clean();
    } else {
        $html = default_template($markdown);
    }
    echo "[build] {$markdown['output_file']} => {$markdown['output_file']}\n";
    file_put_contents($markdown['output_file'], $html);
}
コード例 #2
0
ファイル: admin.mtree.php プロジェクト: rsemedo/Apply-Within
     save_templatepage($option);
     break;
 case "cancel_edittemplatepage":
     cancel_edittemplatepage($option);
     break;
 case "cancel_templatepages":
     cancel_templatepages($option);
     break;
 case "new_template":
     new_template($option);
     break;
 case "install_template":
     install_template($option);
     break;
 case "default_template":
     default_template($option);
     break;
 case "delete_template":
     delete_template($option);
     break;
 case 'save_templateparams':
 case 'apply_templateparams':
     save_templateparam($option);
     break;
     /***
      * Configuration
      */
 /***
  * Configuration
  */
 case "config":