File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,3 +9,13 @@ def test_getRefs():
99 result = t .urlrefs
1010 expect = {'Google' : 'http://www.google.com' }
1111 assert result == expect
12+
13+ t2 = Textile ()
14+
15+ result = t2 .getRefs ("my ftp [ftp]ftp://example.com" )
16+ expect = 'my ftp '
17+ assert result == expect
18+
19+ result = t2 .urlrefs
20+ expect = {'ftp' : 'ftp://example.com' }
21+ assert result == expect
Original file line number Diff line number Diff line change @@ -612,8 +612,14 @@ def glyphs(self, text):
612612
613613 def getRefs (self , text ):
614614 """Capture and store URL references in self.urlrefs."""
615- pattern = re .compile (r'(?:(?<=^)|(?<=\s))\[(.+)\]((?:http(?:s?):\/\/|\/)\S+)(?=\s|$)' ,
616- re .U )
615+ all_schemes = '|' .join ([
616+ '(?:{0})' .format (scheme )
617+ for scheme in self .url_schemes
618+ ])
619+ pattern = re .compile (
620+ r'(?:(?<=^)|(?<=\s))\[(.+)\]((?:{0}:\/\/|\/)\S+)(?=\s|$)' .format (all_schemes ),
621+ re .U
622+ )
617623 text = pattern .sub (self .refs , text )
618624 return text
619625
You can’t perform that action at this time.
0 commit comments