From 1029b8ec6459c8305ed5c65f6591fad9eb1b5cdc Mon Sep 17 00:00:00 2001 From: Henry Hsiao Date: Fri, 19 Jul 2024 16:20:13 +0800 Subject: [PATCH] Update utils.py Fixed two regex that wasn't properly escaped --- evennia/utils/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 360213ba3a..5c6264fc5a 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -473,7 +473,7 @@ def iter_to_str(iterable, sep=",", endsep=", and", addquote=False): list_to_string = iter_to_str iter_to_string = iter_to_str -re_empty = re.compile("\n\s*\n") +re_empty = re.compile("\n\\s*\n") def compress_whitespace(text, max_linebreaks=1, max_spacing=2): @@ -494,7 +494,7 @@ def compress_whitespace(text, max_linebreaks=1, max_spacing=2): # this allows the blank-line compression to eliminate them if needed text = re_empty.sub("\n\n", text) # replace groups of extra spaces with the maximum number of spaces - text = re.sub(f"(?<=\S) {{{max_spacing},}}", " " * max_spacing, text) + text = re.sub(fr"(?<=\S) {{{max_spacing},}}", " " * max_spacing, text) # replace groups of extra newlines with the maximum number of newlines text = re.sub(f"\n{{{max_linebreaks},}}", "\n" * max_linebreaks, text) return text