Remove unnecessary escaping of newline characters in generated snippets

This commit is contained in:
Andy Wilkinson
2014-11-04 11:40:09 +00:00
parent 91498bb5b6
commit 64d05fd76f

View File

@@ -21,8 +21,6 @@ import java.io.PrintWriter;
public class DocumentationWriter extends PrintWriter {
private boolean escapeNewline = false;
public DocumentationWriter(OutputStream stream) {
super(stream, true);
}
@@ -33,27 +31,13 @@ public class DocumentationWriter extends PrintWriter {
@Override
public void perform() throws Exception {
DocumentationWriter.this.print("$ ");
DocumentationWriter.this.escapeNewline = true;
try {
for (DocumentationAction action : actions) {
action.perform();
}
}
finally {
DocumentationWriter.this.escapeNewline = false;
for (DocumentationAction action : actions) {
action.perform();
}
}
});
}
@Override
public void write(String s) {
if (this.escapeNewline) {
s = s.replace("\n", "\\\n");
}
super.write(s);
}
public void codeBlock(String language, DocumentationAction... actions) throws Exception {
println();
if (language != null) {