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
@@ -25,8 +24,8 @@ def autolink(state: StateInline, silent: bool) -> bool:
2524 if linkMatch is not None :
2625
2726 url = linkMatch .group (0 )[1 :- 1 ]
28- fullUrl = normalizeLink (url )
29- if not validateLink (fullUrl ):
27+ fullUrl = state . md . normalizeLink (url )
28+ if not state . md . validateLink (fullUrl ):
3029 return False
3130
3231 if not silent :
@@ -36,7 +35,7 @@ def autolink(state: StateInline, silent: bool) -> bool:
3635 token .info = "auto"
3736
3837 token = state .push ("text" , "" , 0 )
39- token .content = normalizeLinkText (url )
38+ token .content = state . md . normalizeLinkText (url )
4039
4140 token = state .push ("link_close" , "a" , - 1 )
4241 token .markup = "autolink"
@@ -49,8 +48,8 @@ def autolink(state: StateInline, silent: bool) -> bool:
4948 if emailMatch is not None :
5049
5150 url = emailMatch .group (0 )[1 :- 1 ]
52- fullUrl = normalizeLink ("mailto:" + url )
53- if not validateLink (fullUrl ):
51+ fullUrl = state . md . normalizeLink ("mailto:" + url )
52+ if not state . md . validateLink (fullUrl ):
5453 return False
5554
5655 if not silent :
@@ -60,7 +59,7 @@ def autolink(state: StateInline, silent: bool) -> bool:
6059 token .info = "auto"
6160
6261 token = state .push ("text" , "" , 0 )
63- token .content = normalizeLinkText (url )
62+ token .content = state . md . normalizeLinkText (url )
6463
6564 token = state .push ("link_close" , "a" , - 1 )
6665 token .markup = "autolink"
0 commit comments