mirror of
https://github.com/kovidgoyal/kitty
synced 2026-07-26 02:02:14 +02:00
hints kitten: Fix detection of URLs in ReStructuredText
This commit is contained in:
@@ -173,12 +173,16 @@ def url(text, s, e):
|
|||||||
e -= len(url) - idx
|
e -= len(url) - idx
|
||||||
while text[e - 1] in '.,?!' and e > 1: # remove trailing punctuation
|
while text[e - 1] in '.,?!' and e > 1: # remove trailing punctuation
|
||||||
e -= 1
|
e -= 1
|
||||||
|
# Restructured Text URLs
|
||||||
|
if e > 3 and text[e-2:e] == '`_':
|
||||||
|
e -= 2
|
||||||
# Remove trailing bracket if matched by leading bracket
|
# 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]]:
|
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
|
e -= 1
|
||||||
# Remove trailing quote if matched by leading quote
|
# 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]:
|
if s > 0 and e < len(text) and text[s-1] in '\'"' and text[e-1] == text[s-1]:
|
||||||
e -= 1
|
e -= 1
|
||||||
|
|
||||||
return s, e
|
return s, e
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,3 +28,4 @@ class TestHints(BaseTest):
|
|||||||
t('({})'.format(u), u)
|
t('({})'.format(u), u)
|
||||||
t(u + '\nxxx', u + 'xxx', len(u))
|
t(u + '\nxxx', u + 'xxx', len(u))
|
||||||
t('link:{}[xxx]'.format(u), u)
|
t('link:{}[xxx]'.format(u), u)
|
||||||
|
t('`xyz <{}>`_.'.format(u), u)
|
||||||
|
|||||||
Reference in New Issue
Block a user