Skip to content

Commit

Permalink
Wrap class name in quotes if it contains a space
Browse files Browse the repository at this point in the history
  • Loading branch information
eNeRGy164 committed Oct 25, 2023
1 parent d5775e6 commit 6d1ea9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,16 @@ internal static void ClassBase(this StringBuilder stringBuilder, ClassType type,
stringBuilder.Append(Constant.Symbols.Space);
}

stringBuilder.Append(name);
if (name.Contains(Constant.Symbols.Space))
{
stringBuilder.Append(Constant.Symbols.Quote);
stringBuilder.Append(name);
stringBuilder.Append(Constant.Symbols.Quote);
}
else
{
stringBuilder.Append(name);
}

if (generics is not null)
{
Expand Down
1 change: 1 addition & 0 deletions tests/PlantUml.Builder.Tests/ClassDiagrams/ClassTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ private static IEnumerable<object[]> GetValidNotations()
{
// Define the valid notations and expected results for different overloads
yield return new object[] { new MethodExpectationTestData("Class", "class classA", "classA") };
yield return new object[] { new MethodExpectationTestData("Class", "class \"class A\"", "class A") };
yield return new object[] { new MethodExpectationTestData("Class", "class \"Class A\" as classA", "classA", "Class A") };
yield return new object[] { new MethodExpectationTestData("Class", "abstract class classA", "classA", null, true) };
yield return new object[] { new MethodExpectationTestData("Class", "class classA<Object>", "classA", null, null, "Object") };
Expand Down

0 comments on commit 6d1ea9e

Please sign in to comment.