From ef8287832545833e440883648b15b589a30030f3 Mon Sep 17 00:00:00 2001 From: Erik Stein Date: Mon, 17 Dec 2018 18:12:55 +0100 Subject: [PATCH] - Empty string handling for slimdown. --- shared/utils/text.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/shared/utils/text.py b/shared/utils/text.py index 324cb59..375b963 100644 --- a/shared/utils/text.py +++ b/shared/utils/text.py @@ -87,7 +87,10 @@ def slimdown(text): i_pattern = re.compile(r"(\*)(.*?)\1") u_pattern = re.compile(r"(__)(.*?)\1") - text, n = re.subn(b_pattern, "\\2", text) - text, n = re.subn(i_pattern, "\\2", text) - text, n = re.subn(u_pattern, "\\2", text) - return mark_safe(text) + if text: + text, n = re.subn(b_pattern, "\\2", text) + text, n = re.subn(i_pattern, "\\2", text) + text, n = re.subn(u_pattern, "\\2", text) + return mark_safe(text) + else: + return ""