/** * md文件解析 */ public function md() { $file = $this->get('file'); $p = $this->get('p'); // 目录 $directory = MD_FILE_ROOT_PATH . $p . '/'; // 如果不存在自动创建 filesystem::mkdir($directory); // 遍历文件夹所有内容 $path = array(); $dir = filesystem::ls($directory); usort($dir, 'compare'); foreach ($dir as $d) { $path[] = trim($d); } // 解析mk文件 $file = $directory . $file; if (is_file($file)) { $md = new markdown($file); $html = $md->parse(); view::assign('html', $html); } view::assign('path', $path); view::assign('p', $p); view::assign('file', str_replace($directory, '', $file)); }