Commit 7f406004 authored by Syretta Man's avatar Syretta Man

separate pdf and md test

parent 158269d6
Pipeline #112918 passed with stages
in 48 seconds
......@@ -37,7 +37,7 @@ public class WebServer {
if (filetype.equals("html")) {
resultPage.writeTo(resp);
} else if (filetype.equals("markdown") || filetype.equals("pdf")) {
} else if (filetype.equals("markdown")) {
File file = new File("answer.md");
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
......@@ -72,14 +72,35 @@ public class WebServer {
}
file.delete();
if (filetype.equals("pdf")) {
ProcessBuilder pb = new ProcessBuilder();
String[] cm = {"pandoc", "-s", "-o", "sample.pdf", "sample.md"};
pb.command(cm);
pb.start();
} else if (filetype.equals("pdf")) {
File file = new File("answer.md");
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
String answer = resultPage.getAnswer();
// Content
if (answer == null || answer.isEmpty()) {
bw.write("#Sorry\n");
bw.write("Sorry, we didn't understand _" + query + "_");
} else {
bw.write("#" + query + "\n");
bw.write(answer.replace("\n", "<br>"));
}
bw.write("[Back to Search Page](\"/\")");
bw.close();
resp.setContentType("text/markdown");
resp.setHeader("Content-disposition", "attachment; filename=sample.md");
ProcessBuilder pb = new ProcessBuilder();
String[] cm = {"pandoc", "-s", "-o", "sample.pdf", "sample.md"};
pb.command(cm);
pb.start();
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment