|
|
|
@ -86,11 +86,17 @@ def slimdown(text):
|
|
|
|
|
b_pattern = re.compile(r"(\*\*)(.*?)\1") |
|
|
|
|
i_pattern = re.compile(r"(\*)(.*?)\1") |
|
|
|
|
u_pattern = re.compile(r"(__)(.*?)\1") |
|
|
|
|
link_pattern = re.compile(r"\[([^\[]+)\]\(([^\)]+)\)") |
|
|
|
|
|
|
|
|
|
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) |
|
|
|
|
text, n = re.subn(link_pattern, "<a href=\'\\2\'>\\1</a>", text) |
|
|
|
|
return mark_safe(text) |
|
|
|
|
else: |
|
|
|
|
return "" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def strip_links(text): |
|
|
|
|
return re.sub(r'<a[^>]+>', '', text, flags=re.DOTALL).replace('</a>', '') |
|
|
|
|