@@ -1319,17 +1319,17 @@ def _escape_special_chars(self, text: str) -> str:
13191319 is_html_markup = not is_html_markup
13201320 return '' .join (escaped )
13211321
1322+ def _is_auto_link (self , text ):
1323+ if ':' in text and self ._auto_link_re .match (text ):
1324+ return True
1325+ elif '@' in text and self ._auto_email_link_re .match (text ):
1326+ return True
1327+ return False
1328+
13221329 @mark_stage (Stage .HASH_HTML )
13231330 def _hash_html_spans (self , text : str ) -> str :
13241331 # Used for safe_mode.
13251332
1326- def _is_auto_link (s ):
1327- if ':' in s and self ._auto_link_re .match (s ):
1328- return True
1329- elif '@' in s and self ._auto_email_link_re .match (s ):
1330- return True
1331- return False
1332-
13331333 def _is_code_span (index , token ):
13341334 try :
13351335 if token == '<code>' :
@@ -1353,7 +1353,7 @@ def _is_comment(token):
13531353 split_tokens = self ._sorta_html_tokenize_re .split (text )
13541354 is_html_markup = False
13551355 for index , token in enumerate (split_tokens ):
1356- if is_html_markup and not _is_auto_link (token ) and not _is_code_span (index , token ):
1356+ if is_html_markup and not self . _is_auto_link (token ) and not _is_code_span (index , token ):
13571357 is_comment = _is_comment (token )
13581358 if is_comment :
13591359 tokens .append (self ._hash_span (self ._sanitize_html (is_comment .group (1 ))))
@@ -2165,7 +2165,7 @@ def _encode_incomplete_tags(self, text: str) -> str:
21652165 if self .safe_mode not in ("replace" , "escape" ):
21662166 return text
21672167
2168- if text . endswith ( ">" ):
2168+ if self . _is_auto_link ( text ):
21692169 return text # this is not an incomplete tag, this is a link in the form <http://x.y.z>
21702170
21712171 def incomplete_tags_sub (match ):
0 commit comments