33from typing import Callable
44from urllib .parse import urlparse , urlunparse , quote , unquote # noqa: F401
55
6+ from .utils import ESCAPABLE
7+
68# TODO below we port the use of the JS packages:
79# var mdurl = require('mdurl')
810# var punycode = require('punycode')
3032# ################# Copied from Commonmark.py #################
3133
3234ENTITY = "&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});"
33- ESCAPABLE = "[!\" #$%&'()*+,./:;<=>?@[\\ \\ \\ ]^_`{|}~-]"
3435reBackslashOrAmp = re .compile (r"[\\&]" )
35- reEntityOrEscapedChar = re .compile ("\\ \\ " + ESCAPABLE + "|" + ENTITY , re .IGNORECASE )
36+ reEntityOrEscapedChar = re .compile (
37+ "\\ \\ " + "[" + ESCAPABLE + "]|" + ENTITY , re .IGNORECASE
38+ )
3639
3740
3841def unescape_char (s ):
@@ -112,13 +115,14 @@ def unescape_unquote(x):
112115 return unquote (unescape_string (x ))
113116
114117
115- def normalizeLinkText (title ):
118+ def normalizeLinkText (link ):
116119 """Normalize autolink content::
117120
118121 <destination>
119122 ~~~~~~~~~~~
120123 """
121- (scheme , netloc , path , params , query , fragment ) = urlparse (title )
124+ (scheme , netloc , path , params , query , fragment ) = urlparse (link )
125+ print ((scheme , netloc , path , params , query , fragment ))
122126 if scheme in RECODE_HOSTNAME_FOR :
123127 url = urlunparse (
124128 (
@@ -131,7 +135,7 @@ def normalizeLinkText(title):
131135 )
132136 )
133137 else :
134- url = unescape_unquote (title )
138+ url = unescape_unquote (link )
135139 return url
136140
137141 # TODO the selective encoding below should probably be done here,
0 commit comments