in src/main/java/ConvertHtml2Adoc.java [54:98]
private static void convert(File src) {
if (src.toString().contains("docs\\api")) {
// skip 'api' folders
return;
}
if (!src.toString().endsWith(".html")) {
// skip non-html: css, ...
return;
}
try {
String srcName = src.getName();
srcName = srcName.substring(0, srcName.lastIndexOf(".") + 1);
String dstName = srcName + "adoc";
Path srcPath = src.toPath();
Path relPath = basePath.relativize(srcPath);
int count = relPath.getNameCount();
Path fullOutPath;
if (count > 2) {
//System.out.println("re2: " + relPath.subpath(1, count-1).toString());
fullOutPath = Paths.get(basePath.toString(), output, relPath.subpath(1, count-1).toString(), dstName.toString());
} else {
fullOutPath = Paths.get(basePath.toString(), output, dstName.toString());
}
if (!fullOutPath.getParent().toFile().exists()) {
Files.createDirectories(fullOutPath.getParent());
}
Files.deleteIfExists(fullOutPath);
File outFile = Files.createFile(fullOutPath).toFile();
new DocumentConverter()
.fromFile(src, InputFormat.HTML)
.toFile(outFile, OutputFormat.ASCIIDOC)
// .addOption("-s") //optional
// .workingDirectory(new File("/tmp")) //optional
.convert();
postConvert(outFile);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}