colors: Replace multiple newlines with a single one.

This commit is contained in:
Damir Jelić 2018-08-21 12:33:08 +02:00
parent 6d299219b0
commit 166ff3b2e3

View file

@ -24,6 +24,7 @@ from collections import namedtuple
from matrix.globals import W, OPTIONS from matrix.globals import W, OPTIONS
from matrix.utils import string_strikethrough from matrix.utils import string_strikethrough
import re
import textwrap import textwrap
import webcolors import webcolors
@ -322,7 +323,7 @@ class Formatted():
return text return text
weechat_strings = map(format_string, self.substrings) weechat_strings = map(format_string, self.substrings)
return "".join(weechat_strings).replace("\n\n", "\n").strip() return re.sub(r'\n+', '\n', "".join(weechat_strings)).strip()
# TODO this should be a typed dict. # TODO this should be a typed dict.