From 64c675150e8f4e9291ad8056c873dd04993f4e78 Mon Sep 17 00:00:00 2001 From: me Date: Fri, 31 Jan 2020 12:27:39 +0200 Subject: [PATCH] extract escape_amp() method --- bumblebee/output.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bumblebee/output.py b/bumblebee/output.py index 4f8fc6b..cded3ed 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -374,6 +374,11 @@ class WidgetDrawer(object): if self._suffix: self._full_text = u"{}{}".format(self._full_text, self._suffix) + def escape_amp(self): + """escape & in full_text, because pango requires it""" + if self._markup == "pango": + self._full_text = self._full_text.replace("&", "&") + def draw(self, widget, module=None, engine=None): """ Keep the same argument signature as I3BarOutput.draw() @@ -406,8 +411,7 @@ class WidgetDrawer(object): if width: self._full_text = self._full_text.ljust(len(width) + len(self._prefix) + len(self._suffix)) - if self._markup == "pango": - self._full_text = self._full_text.replace("&", "&") + self.escape_amp() self._widgets.append({ u"full_text": self._full_text,