diff --git a/structurizr-dsl/src/main/java/com/structurizr/dsl/StructurizrDslParser.java b/structurizr-dsl/src/main/java/com/structurizr/dsl/StructurizrDslParser.java index 1c9750175..66a6717d0 100644 --- a/structurizr-dsl/src/main/java/com/structurizr/dsl/StructurizrDslParser.java +++ b/structurizr-dsl/src/main/java/com/structurizr/dsl/StructurizrDslParser.java @@ -1212,8 +1212,13 @@ private List preProcessLines(List lines) { for (String line : lines) { if (!COMMENT_PATTERN.matcher(line).matches() && line.endsWith(MULTI_LINE_SEPARATOR)) { - buf.append(line, 0, line.length()-1); - lineComplete = false; + if (lineComplete) { + buf.append(line, 0, line.length()-1); + lineComplete = false; + } else { + String strippedLine = line.stripLeading(); + buf.append(strippedLine, 0, strippedLine.length() - 1); + } } else { if (lineComplete) { buf.append(line); diff --git a/structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java b/structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java index b92c0da3c..503fce498 100644 --- a/structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java +++ b/structurizr-dsl/src/test/java/com/structurizr/dsl/DslTests.java @@ -1141,6 +1141,14 @@ void test_MultiLineSupport() throws Exception { assertNotNull(parser.getWorkspace().getModel().getSoftwareSystemWithName("Software System")); } + @Test + void test_MultiLineInTheMiddleOfTheStringSupport() throws Exception { + StructurizrDslParser parser = new StructurizrDslParser(); + parser.parse(new File("src/test/resources/dsl/multi-line-break-string.dsl")); + + assertNotNull(parser.getWorkspace().getModel().getSoftwareSystemWithName("Software System")); + } + @Test void test_MultiLineWithError() { File dslFile = new File("src/test/resources/dsl/multi-line-with-error.dsl"); diff --git a/structurizr-dsl/src/test/resources/dsl/multi-line-break-string.dsl b/structurizr-dsl/src/test/resources/dsl/multi-line-break-string.dsl new file mode 100644 index 000000000..9e45b42b7 --- /dev/null +++ b/structurizr-dsl/src/test/resources/dsl/multi-line-break-string.dsl @@ -0,0 +1,20 @@ +work\ + sp\ + ace { + + mo\ + d\ + el { + soft\ + wareSys\ + tem = \ + soft\ + wareSys\ + tem \ + "Sof\ + tware \ + Sys\ + tem" + } + +} \ No newline at end of file