From e71536f6345bc2e0c8734f4bd91e9e0097308119 Mon Sep 17 00:00:00 2001 From: Arnaud Roques Date: Tue, 19 Apr 2011 18:22:56 +0200 Subject: [PATCH] Transcoder.class will now add @startuml, to we have to check if it is present before adding it --- .../plantuml/servlet/PlantUmlServlet.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/net/sourceforge/plantuml/servlet/PlantUmlServlet.java b/src/net/sourceforge/plantuml/servlet/PlantUmlServlet.java index 7942df7..72f693a 100644 --- a/src/net/sourceforge/plantuml/servlet/PlantUmlServlet.java +++ b/src/net/sourceforge/plantuml/servlet/PlantUmlServlet.java @@ -167,14 +167,19 @@ public class PlantUmlServlet extends HttpServlet { private void sendImage(HttpServletResponse response, String text, String uri) throws IOException { - StringBuilder plantUmlSource = new StringBuilder(); - plantUmlSource.append("@startuml\n"); - plantUmlSource.append(text); - if (text.endsWith("\n") == false) { - plantUmlSource.append("\n"); - } - plantUmlSource.append("@enduml"); - final String uml = plantUmlSource.toString(); + final String uml; + if (text.startsWith("@startuml")) { + uml = text; + } else { + StringBuilder plantUmlSource = new StringBuilder(); + plantUmlSource.append("@startuml\n"); + plantUmlSource.append(text); + if (text.endsWith("\n") == false) { + plantUmlSource.append("\n"); + } + plantUmlSource.append("@enduml"); + uml = plantUmlSource.toString(); + } // Write the first image to "os" long today = System.currentTimeMillis(); if ( StringUtils.isDiagramCacheable( uml)) {