3
3
from typing import Callable
4
4
from urllib .parse import urlparse , urlunparse , quote , unquote # noqa: F401
5
5
6
+ from .utils import ESCAPABLE
7
+
6
8
# TODO below we port the use of the JS packages:
7
9
# var mdurl = require('mdurl')
8
10
# var punycode = require('punycode')
30
32
# ################# Copied from Commonmark.py #################
31
33
32
34
ENTITY = "&(?:#x[a-f0-9]{1,6}|#[0-9]{1,7}|[a-z][a-z0-9]{1,31});"
33
- ESCAPABLE = "[!\" #$%&'()*+,./:;<=>?@[\\ \\ \\ ]^_`{|}~-]"
34
35
reBackslashOrAmp = re .compile (r"[\\&]" )
35
- reEntityOrEscapedChar = re .compile ("\\ \\ " + ESCAPABLE + "|" + ENTITY , re .IGNORECASE )
36
+ reEntityOrEscapedChar = re .compile (
37
+ "\\ \\ " + "[" + ESCAPABLE + "]|" + ENTITY , re .IGNORECASE
38
+ )
36
39
37
40
38
41
def unescape_char (s ):
@@ -112,13 +115,14 @@ def unescape_unquote(x):
112
115
return unquote (unescape_string (x ))
113
116
114
117
115
- def normalizeLinkText (title ):
118
+ def normalizeLinkText (link ):
116
119
"""Normalize autolink content::
117
120
118
121
<destination>
119
122
~~~~~~~~~~~
120
123
"""
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 ))
122
126
if scheme in RECODE_HOSTNAME_FOR :
123
127
url = urlunparse (
124
128
(
@@ -131,7 +135,7 @@ def normalizeLinkText(title):
131
135
)
132
136
)
133
137
else :
134
- url = unescape_unquote (title )
138
+ url = unescape_unquote (link )
135
139
return url
136
140
137
141
# TODO the selective encoding below should probably be done here,
0 commit comments