|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package UnitTest;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
|
|
import cn.hutool.core.util.RuntimeUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
@ -12,8 +14,18 @@ https://github.com/markmap/markmap
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public class Swdt {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
String workingPath = "D:\\dsWork\\QingLong\\src\\main\\java\\UnitTest\\";
|
|
|
|
|
public static String workingPath = "D:\\dsWork\\QingLong\\src\\main\\java\\UnitTest\\";
|
|
|
|
|
|
|
|
|
|
public static String getColorTxt(String txt, int num, String color) {
|
|
|
|
|
String content = FileUtil.readUtf8String(workingPath + "Swdt_Color.txt");
|
|
|
|
|
content = content.replace("{{color}}", color);
|
|
|
|
|
content = content.replace("{{txt}}", txt);
|
|
|
|
|
content = content.replace("{{num}}", String.valueOf(num));
|
|
|
|
|
return content;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
|
|
|
|
|
String km = "初中物理八年级上(人教版)";
|
|
|
|
|
String sourceJson = "Swdt.json";
|
|
|
|
|
String targetMd = "Swdt.md";
|
|
|
|
@ -25,7 +37,7 @@ public class Swdt {
|
|
|
|
|
String res = "# " + km + "\n";
|
|
|
|
|
for (int i = 0; i < jTree.size(); i++) {
|
|
|
|
|
String title = jTree.getJSONObject(i).getString("title");
|
|
|
|
|
res += "## " + title + "\n";
|
|
|
|
|
res += "## " + getColorTxt(title,99,"#ff5722") + "\n";
|
|
|
|
|
JSONArray jChildren = jTree.getJSONObject(i).getJSONArray("children");
|
|
|
|
|
if (jChildren != null) {
|
|
|
|
|
int rowCount = 3;//每行3个
|
|
|
|
@ -49,5 +61,29 @@ public class Swdt {
|
|
|
|
|
}
|
|
|
|
|
String str = RuntimeUtil.execForStr(cmd);
|
|
|
|
|
System.out.println(str);
|
|
|
|
|
|
|
|
|
|
// 修改html文件
|
|
|
|
|
File file = new File(workingPath + targetHtml);
|
|
|
|
|
FileReader fr = new FileReader(file);
|
|
|
|
|
BufferedReader br = new BufferedReader(fr);
|
|
|
|
|
StringBuilder content = new StringBuilder();
|
|
|
|
|
String line;
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
if (line.indexOf("<title>Markmap</title>") >= 0) {
|
|
|
|
|
String modifiedLine = line.replaceAll("<title>Markmap</title>", "<title>建设情况</title>");
|
|
|
|
|
//读取字体文件,填充内容
|
|
|
|
|
String fontStr = FileUtil.readUtf8String(new File(workingPath + "Swdt_Font.txt"));
|
|
|
|
|
content.append(modifiedLine).append("\n");
|
|
|
|
|
content.append(fontStr).append("\n");
|
|
|
|
|
} else {
|
|
|
|
|
content.append(line).append("\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
br.close();
|
|
|
|
|
|
|
|
|
|
FileWriter fw = new FileWriter(file);
|
|
|
|
|
BufferedWriter bw = new BufferedWriter(fw);
|
|
|
|
|
bw.write(content.toString());
|
|
|
|
|
bw.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|