From 64d05fd76f3aa954a79542f6a6dee21be1e9fab2 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 4 Nov 2014 11:40:09 +0000 Subject: [PATCH] Remove unnecessary escaping of newline characters in generated snippets --- .../restdocs/core/DocumentationWriter.java | 20 ++----------------- 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationWriter.java b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationWriter.java index c999e8ca..a3bdbc8c 100644 --- a/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationWriter.java +++ b/spring-restdocs-core/src/main/java/org/springframework/restdocs/core/DocumentationWriter.java @@ -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) {