\
) will be deprecated in favor of clearer, more descriptive functions. This document outlines these changes and how to adapt your diagrams accordingly.\
) will be treated as a regular character, just like any other, and will no longer play a special role in escape sequences.Escape sequence | Replacement function | Description |
\n
|
%n() or %newline()
|
Inserts a line break. |
\l
|
%left_align()
|
Aligns text to the left in labels or notes. |
\r
|
%right_align()
|
Aligns text to the right in labels or notes. |
\t
|
%tab()
|
Inserts a tabulation character. |
\\
|
%backslash()
|
Inserts a literal backslash character. |
The functions%n()
and%newline()
are strictly equivalent, so you can choose the one you prefer based on your personal style.
%newline()
and %tab()
explicitly indicate their purpose, improving the clarity and maintainability of PlantUML scripts.
Alice -> Bob : Hello\nHow are you?
note left: This is a\ntest
Alice -> Bob : Hello%newline()How are you?
note left: This is a%newline()test
%breakline()
function%breakline()
has been introduced.%breakline()
do?%breakline()
function explicitly creates a new line in the source code, meaning it behaves as if you had pressed "Enter" to start a new line in your PlantUML script. This is different from %n()
or %newline()
, which only affect how text is rendered in the output diagram.%breakline()
%breakline()
when you need to split long pieces of code or dynamically generate source lines in your PlantUML scripts. It is particularly useful in preprocessor functions or macros that return multi-line outputs.
🎉 Copied!
|
|
In this example,
%breakline()
splits the PlantUML source code into multiple lines, resulting in a diagram where the interactions are processed correctly as separate instructions.%breakline()
different from %n()
or %newline()
?%n()
or %newline()
: These functions create line breaks in rendered text. For example, they are used to format labels, notes, or text displayed in diagrams.%breakline()
: This function creates a line break in the PlantUML source code, affecting how the script is interpreted.
@startuml
' Using %n() to insert a line break in text
Alice -> Bob : Hello%n()How are you?
' Using %breakline() to split source code into two lines
Alice -> Bob : Hello %breakline()Bob -> Alice : Hi!
@enduml
%n()
affects how the message is rendered in the diagram.%breakline()
affects how the script is interpreted, splitting it into two separate interactions.%breakline()
?\n
or ambiguous behaviors when working with line breaks in source code.
The introduction of %breakline()
provides a clean, explicit, and predictable way to handle source-level line breaks, reducing confusion and ensuring consistency in future versions of PlantUML.Version | Release status |
Backslash escape sequences \n
|
%newline()
|
%breakline()
|
Notes |
V1.2025.0 and before | 🚀 | ✅ Supported | ❌ Not officially supported | ❌ Not available | Backslash escape sequences work; new functions are not available. |
V1.2025.1 | 🚧 | ✅ Supported | ✅ Supported | ✅ Supported | Both backslash escape sequences and the new functions work. Facilitates migration. |
V1.2025.2 | 🚧 | ⚠️ Supported but with warnings | ✅ Supported | ✅ Supported | Backslash escape sequences work but show a warning encouraging the use of new functions. |
V1.2025.3 | 🚧 | ❌ Not supported (treated as literal text) | ✅ Supported | ✅ Supported | Backslash escape sequences are no longer recognized and are displayed as-is. |