hints kitten: Fix detection of URLs in ReStructuredText

This commit is contained in:
Kovid Goyal
2018-05-21 16:14:49 +05:30
parent a59cda8b60
commit 48847cdaf8
2 changed files with 5 additions and 0 deletions

View File

@@ -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