diff --git a/kittens/hints/main.py b/kittens/hints/main.py index 6721d73e1..b2e33afd4 100644 --- a/kittens/hints/main.py +++ b/kittens/hints/main.py @@ -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 diff --git a/kitty_tests/hints.py b/kitty_tests/hints.py index 4f6928579..924e61946 100644 --- a/kitty_tests/hints.py +++ b/kitty_tests/hints.py @@ -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)