Improves tagging regex

This commit is contained in:
Mouse Reeve
2021-01-06 09:45:36 -08:00
parent f87a138d49
commit a25bc2383b
3 changed files with 53 additions and 7 deletions

View File

@ -293,12 +293,15 @@ def find_mentions(content):
yield (match.group(), mention_user)
def to_markdown(content):
''' catch links and convert to markdown '''
content = re.sub(
def format_links(content):
return re.sub(
r'([^(href=")]|^)(https?:\/\/([\w\.\-_]+\.[a-z]{2,}(\/[\w\.\-_\/]+)?))',
r'\g<1><a href="\g<2>">\g<3></a>',
content)
def to_markdown(content):
''' catch links and convert to markdown '''
content = format_links(content)
content = markdown(content)
# sanitize resulting html
sanitizer = InputHtmlParser()