PandocDriver.java
package org.docascode.api.core.converter;
import org.apache.commons.io.FilenameUtils;
import org.docascode.api.core.errors.ProcessingException;
import java.io.IOException;
public class PandocDriver extends AbstractConverter{
private String pandocExec = "pandoc";
@Override
public void convert() throws ProcessingException {
try {
toFile.getParentFile().mkdirs();
ProcessBuilder process = new ProcessBuilder(
String.format("%s",getPandocExec()),
String.format("--extract-media=%s",FilenameUtils.removeExtension(toFile.getAbsolutePath())),
String.format("%s",fromFile.getAbsolutePath()),
String.format("--output=%s",toFile.getAbsolutePath()));
process.start();
} catch (IOException e) {
throw new ProcessingException("Unable to execute pandoc driver",e);
}
}
private String getPandocExec() {
return pandocExec;
}
}