11# Process autolinks '<protocol:...>'
22import re
33from .state_inline import StateInline
4- from ..common .normalize_url import normalizeLinkText , normalizeLink , validateLink
54
65EMAIL_RE = re .compile (
76 r"^([a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$" # noqa: E501
@@ -34,8 +33,8 @@ def autolink(state: StateInline, silent: bool) -> bool:
3433 url = state .src [start + 1 : pos ]
3534
3635 if AUTOLINK_RE .search (url ) is not None :
37- fullUrl = normalizeLink (url )
38- if not validateLink (fullUrl ):
36+ fullUrl = state . md . normalizeLink (url )
37+ if not state . md . validateLink (fullUrl ):
3938 return False
4039
4140 if not silent :
@@ -45,7 +44,7 @@ def autolink(state: StateInline, silent: bool) -> bool:
4544 token .info = "auto"
4645
4746 token = state .push ("text" , "" , 0 )
48- token .content = normalizeLinkText (url )
47+ token .content = state . md . normalizeLinkText (url )
4948
5049 token = state .push ("link_close" , "a" , - 1 )
5150 token .markup = "autolink"
@@ -55,8 +54,8 @@ def autolink(state: StateInline, silent: bool) -> bool:
5554 return True
5655
5756 if EMAIL_RE .search (url ) is not None :
58- fullUrl = normalizeLink ("mailto:" + url )
59- if not validateLink (fullUrl ):
57+ fullUrl = state . md . normalizeLink ("mailto:" + url )
58+ if not state . md . validateLink (fullUrl ):
6059 return False
6160
6261 if not silent :
@@ -66,7 +65,7 @@ def autolink(state: StateInline, silent: bool) -> bool:
6665 token .info = "auto"
6766
6867 token = state .push ("text" , "" , 0 )
69- token .content = normalizeLinkText (url )
68+ token .content = state . md . normalizeLinkText (url )
7069
7170 token = state .push ("link_close" , "a" , - 1 )
7271 token .markup = "autolink"
0 commit comments