From 070308c25427ab0a288aa0222716f761e6cd7420 Mon Sep 17 00:00:00 2001 From: Bruno Meneguello <1322552+bkmeneguello@users.noreply.github.com> Date: Tue, 29 Dec 2020 21:24:53 -0300 Subject: [PATCH] Better handling of multiline Cluster labels --- diagrams/__init__.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 19b23152..ca84e75c 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -346,10 +346,12 @@ class Node(_Cluster): icon = self._load_icon() if icon: - self.dot.graph_attr["label"] = '<'\ - ''\ - '
'\ - '' + html.escape(self.label) + '
>' + lines = iter(html.escape(self.label).split("\n")) + self.dot.graph_attr["label"] = '<' +\ + f'' +\ + f'' +\ + ''.join(f'' for line in lines) +\ + '
{next(lines)}
{line}
>' if not self._validate_direction(self._direction): raise ValueError(f'"{self._direction}" is not a valid direction')