2 Star 3 Fork 1

daimkdl/flutter-in-action

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
doc.dart 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
wendux 提交于 2019-08-06 19:15 . 更新内容
import 'dart:io';
import 'package:path/path.dart' as path;
void main() async {
await Process.run('cp', ["-r", "docs/imgs/.", "book/imgs"]);
await Process.run('cp', [ "docs/img_des.txt", "book/img_des.txt"]);
await walk("docs", "book");
await Process.run('rm', ["-f","book/README.docx"]);
await Process.run('rm', ["-f","book/SUMMARY.docx"]);
}
//遍历JSON目录生成模板
walk(String srcDir, String distDir) async {
if (srcDir.endsWith("/")) srcDir = srcDir.substring(0, srcDir.length - 1);
if (distDir.endsWith("/")) distDir = distDir.substring(0, distDir.length - 1);
var src = Directory(srcDir);
var list = src.listSync(recursive: true);
if (list.isEmpty) return false;
if (!Directory(distDir).existsSync()) {
Directory(distDir).createSync(recursive: true);
}
for (var f in list) {
String filePath = f.path;
if (FileSystemEntity.isFileSync(filePath)) {
//File file = File(f.path);
var ext = path.extension(filePath);
if (ext != ".md") continue;
var output =
filePath.replaceFirst("docs/", "book/").replaceFirst(".md", ".docx");
var dir = path.dirname(output);
print(dir);
if (!Directory(dir).existsSync()) {
Directory(dir).createSync(recursive: true);
}
await Process.run('pandoc', ["-s", filePath, "-o", output,"--extract-media=docs/imgs"]);
}
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dhopen/flutter-in-action.git
git@gitee.com:dhopen/flutter-in-action.git
dhopen
flutter-in-action
flutter-in-action
master

搜索帮助