} catch (Exception e) {
throw new BuildException(String.format("Cannot write to file '%s': %s",tocOutputFile,e.getMessage()),e);
}
try {
TextileToEclipseToc toEclipseToc = new TextileToEclipseToc();
toEclipseToc.setBookTitle(title==null?name:title);
String basePath = baseDir.getAbsolutePath().replace('\\','/');
String outputFilePath = htmlOutputFile.getAbsolutePath().replace('\\','/');
if (outputFilePath.startsWith(basePath)) {
String filePath = outputFilePath.substring(basePath.length());
if (filePath.startsWith("/")) {
filePath = filePath.substring(1);
}
toEclipseToc.setHtmlFile(filePath);
} else {
toEclipseToc.setHtmlFile(htmlOutputFile.getName());
}
String tocXml = toEclipseToc.parse(textile);
try {
writer.write(tocXml);
} catch (Exception e) {
throw new BuildException(String.format("Cannot write to file '%s': %s",tocXml,e.getMessage()),e);