@@ -1319,17 +1319,17 @@ def _escape_special_chars(self, text: str) -> str:
1319
1319
is_html_markup = not is_html_markup
1320
1320
return '' .join (escaped )
1321
1321
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
+
1322
1329
@mark_stage (Stage .HASH_HTML )
1323
1330
def _hash_html_spans (self , text : str ) -> str :
1324
1331
# Used for safe_mode.
1325
1332
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
-
1333
1333
def _is_code_span (index , token ):
1334
1334
try :
1335
1335
if token == '<code>' :
@@ -1353,7 +1353,7 @@ def _is_comment(token):
1353
1353
split_tokens = self ._sorta_html_tokenize_re .split (text )
1354
1354
is_html_markup = False
1355
1355
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 ):
1357
1357
is_comment = _is_comment (token )
1358
1358
if is_comment :
1359
1359
tokens .append (self ._hash_span (self ._sanitize_html (is_comment .group (1 ))))
@@ -2165,7 +2165,7 @@ def _encode_incomplete_tags(self, text: str) -> str:
2165
2165
if self .safe_mode not in ("replace" , "escape" ):
2166
2166
return text
2167
2167
2168
- if text . endswith ( ">" ):
2168
+ if self . _is_auto_link ( text ):
2169
2169
return text # this is not an incomplete tag, this is a link in the form <http://x.y.z>
2170
2170
2171
2171
def incomplete_tags_sub (match ):
0 commit comments