better auto-link
This commit is contained in:
@@ -11,11 +11,11 @@ RE_EM = re.compile(r"\*(.*?)\*")
|
||||
RE_LIST = re.compile(r"(-|[0-9]\.) .*")
|
||||
|
||||
RE_PLAINURL = re.compile(
|
||||
r"([ |\n])(https?://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-]))[^\)]"
|
||||
r"(?P<pre>^|\s|\n)(?P<url>https?://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-]))(?P<post>\s|\n|$)"
|
||||
)
|
||||
|
||||
def html(text):
|
||||
text = RE_PLAINURL.sub(r'\1[\2](\2)', text)
|
||||
text = RE_PLAINURL.sub(r'\g<pre>[\g<url>](\g<url>)\g<post>', text)
|
||||
return markdown2.markdown(text)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user