Browse Source

- Empty string handling for slimdown.

master
Erik Stein 6 years ago
parent
commit
ef82878325
  1. 11
      shared/utils/text.py

11
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, "<b>\\2</b>", text)
text, n = re.subn(i_pattern, "<i>\\2</i>", text)
text, n = re.subn(u_pattern, "<u>\\2</u>", text)
return mark_safe(text)
if text:
text, n = re.subn(b_pattern, "<b>\\2</b>", text)
text, n = re.subn(i_pattern, "<i>\\2</i>", text)
text, n = re.subn(u_pattern, "<u>\\2</u>", text)
return mark_safe(text)
else:
return ""

Loading…
Cancel
Save