diff --git a/tool/src/org/antlr/v4/gui/TreeViewer.java b/tool/src/org/antlr/v4/gui/TreeViewer.java index 2c000aa90b..5d58aff4ac 100644 --- a/tool/src/org/antlr/v4/gui/TreeViewer.java +++ b/tool/src/org/antlr/v4/gui/TreeViewer.java @@ -273,7 +273,7 @@ protected void generateBox(Writer writer, Tree parent) throws IOException { "fill:orange; stroke:rgb(0,0,0);", "rx=\"1\"")); // draw the text on top of the box (possibly multiple lines) - String line = getText(parent).replace("<","<").replace(">",">"); + String line = getText(parent).replace("&","&").replace("<","<").replace(">",">").replace("\"",""").replace("'","'"); int fontSize = 10; int x = (int) box.x + 2; int y = (int) box.y + fontSize - 1; @@ -588,6 +588,14 @@ private static void generateSVGFile(TreeViewer viewer, JFrame dialog) { } } + public void toSVG(Writer writer) throws IOException { + writer.write(""); + paintSVG(writer); + writer.write(""); + writer.flush(); + writer.close(); + } + private static File generateNonExistingFile(String extension) { final String parent = ".";