hints kitten: Fix detection of URLs in ReStructuredText
This commit is contained in:
parent
a59cda8b60
commit
48847cdaf8
@ -173,12 +173,16 @@ def url(text, s, e):
|
||||
e -= len(url) - idx
|
||||
while text[e - 1] in '.,?!' and e > 1: # remove trailing punctuation
|
||||
e -= 1
|
||||
# Restructured Text URLs
|
||||
if e > 3 and text[e-2:e] == '`_':
|
||||
e -= 2
|
||||
# Remove trailing bracket if matched by leading bracket
|
||||
if s > 0 and e < len(text) and text[s-1] in opening_brackets and text[e-1] == closing_bracket_map[text[s-1]]:
|
||||
e -= 1
|
||||
# Remove trailing quote if matched by leading quote
|
||||
if s > 0 and e < len(text) and text[s-1] in '\'"' and text[e-1] == text[s-1]:
|
||||
e -= 1
|
||||
|
||||
return s, e
|
||||
|
||||
|
||||
|
||||
@ -28,3 +28,4 @@ class TestHints(BaseTest):
|
||||
t('({})'.format(u), u)
|
||||
t(u + '\nxxx', u + 'xxx', len(u))
|
||||
t('link:{}[xxx]'.format(u), u)
|
||||
t('`xyz <{}>`_.'.format(u), u)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user